bayserver-core 2.3.2 → 3.0.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/baykit/bayserver/agent/accept_handler.rb +0 -26
- data/lib/baykit/bayserver/agent/channel_listener.rb +6 -6
- data/lib/baykit/bayserver/agent/command_receiver.rb +97 -38
- data/lib/baykit/bayserver/agent/grand_agent.rb +444 -134
- data/lib/baykit/bayserver/agent/letter.rb +30 -0
- data/lib/baykit/bayserver/agent/lifecycle_listener.rb +9 -7
- data/lib/baykit/bayserver/agent/monitor/grand_agent_monitor.rb +298 -0
- data/lib/baykit/bayserver/agent/multiplexer/job_multiplexer.rb +257 -0
- data/lib/baykit/bayserver/agent/multiplexer/job_multiplexer_base.rb +52 -0
- data/lib/baykit/bayserver/agent/multiplexer/multiplexer_base.rb +150 -0
- data/lib/baykit/bayserver/agent/multiplexer/plain_transporter.rb +129 -0
- data/lib/baykit/bayserver/agent/multiplexer/rudder_state.rb +81 -0
- data/lib/baykit/bayserver/agent/multiplexer/secure_transporter.rb +50 -0
- data/lib/baykit/bayserver/agent/multiplexer/spider_multiplexer.rb +561 -0
- data/lib/baykit/bayserver/agent/multiplexer/spin_multiplexer.rb +311 -0
- data/lib/baykit/bayserver/agent/multiplexer/taxi_multiplexer.rb +194 -0
- data/lib/baykit/bayserver/agent/multiplexer/transporter.rb +61 -0
- data/lib/baykit/bayserver/agent/multiplexer/write_unit.rb +30 -0
- data/lib/baykit/bayserver/agent/non_blocking_handler.rb +0 -319
- data/lib/baykit/bayserver/agent/signal/signal_agent.rb +2 -1
- data/lib/baykit/bayserver/agent/timer_handler.rb +1 -1
- data/lib/baykit/bayserver/agent/transporter/data_listener.rb +7 -7
- data/lib/baykit/bayserver/agent/transporter/package.rb +0 -3
- data/lib/baykit/bayserver/agent/transporter/transporter.rb +5 -139
- data/lib/baykit/bayserver/bay_log.rb +1 -0
- data/lib/baykit/bayserver/bayserver.rb +32 -28
- data/lib/baykit/bayserver/{util → common}/groups.rb +1 -1
- data/lib/baykit/bayserver/common/inbound_handler.rb +12 -0
- data/lib/baykit/bayserver/{docker/base → common}/inbound_ship.rb +94 -19
- data/lib/baykit/bayserver/{docker/base → common}/inbound_ship_store.rb +7 -9
- data/lib/baykit/bayserver/common/multiplexer.rb +98 -0
- data/lib/baykit/bayserver/common/postpone.rb +15 -0
- data/lib/baykit/bayserver/common/read_only_ship.rb +42 -0
- data/lib/baykit/bayserver/common/recipient.rb +24 -0
- data/lib/baykit/bayserver/common/vehicle.rb +24 -0
- data/lib/baykit/bayserver/common/vehicle_runner.rb +127 -0
- data/lib/baykit/bayserver/{docker/warp → common}/warp_data.rb +18 -10
- data/lib/baykit/bayserver/common/warp_handler.rb +27 -0
- data/lib/baykit/bayserver/{docker/warp → common}/warp_ship.rb +107 -27
- data/lib/baykit/bayserver/{docker/warp → common}/warp_ship_store.rb +3 -8
- data/lib/baykit/bayserver/docker/base/inbound_data_listener.rb +2 -2
- data/lib/baykit/bayserver/docker/base/port_base.rb +59 -27
- data/lib/baykit/bayserver/docker/{warp/warp_docker.rb → base/warp_base.rb} +43 -50
- data/lib/baykit/bayserver/docker/built_in/built_in_harbor_docker.rb +118 -31
- data/lib/baykit/bayserver/docker/built_in/built_in_log_docker.rb +60 -63
- data/lib/baykit/bayserver/docker/built_in/built_in_permission_docker.rb +11 -10
- data/lib/baykit/bayserver/docker/built_in/built_in_secure_docker.rb +13 -4
- data/lib/baykit/bayserver/docker/city.rb +27 -13
- data/lib/baykit/bayserver/docker/club.rb +8 -8
- data/lib/baykit/bayserver/docker/docker.rb +9 -1
- data/lib/baykit/bayserver/docker/harbor.rb +184 -22
- data/lib/baykit/bayserver/docker/permission.rb +7 -6
- data/lib/baykit/bayserver/docker/port.rb +39 -11
- data/lib/baykit/bayserver/docker/secure.rb +11 -9
- data/lib/baykit/bayserver/docker/send_file/file_content_handler.rb +99 -4
- data/lib/baykit/bayserver/docker/send_file/send_file_docker.rb +6 -2
- data/lib/baykit/bayserver/docker/send_file/send_file_ship.rb +92 -0
- data/lib/baykit/bayserver/docker/town.rb +31 -15
- data/lib/baykit/bayserver/docker/trouble.rb +17 -5
- data/lib/baykit/bayserver/docker/warp.rb +34 -0
- data/lib/baykit/bayserver/mem_usage.rb +9 -9
- data/lib/baykit/bayserver/protocol/command_packer.rb +1 -8
- data/lib/baykit/bayserver/protocol/packet_packer.rb +7 -11
- data/lib/baykit/bayserver/protocol/packet_store.rb +4 -4
- data/lib/baykit/bayserver/protocol/protocol_handler.rb +26 -8
- data/lib/baykit/bayserver/protocol/protocol_handler_store.rb +5 -5
- data/lib/baykit/bayserver/rudders/io_rudder.rb +62 -0
- data/lib/baykit/bayserver/rudders/rudder.rb +29 -0
- data/lib/baykit/bayserver/{watercraft → ships}/ship.rb +65 -41
- data/lib/baykit/bayserver/taxi/taxi.rb +15 -10
- data/lib/baykit/bayserver/taxi/taxi_runner.rb +9 -94
- data/lib/baykit/bayserver/tours/read_file_taxi.rb +2 -2
- data/lib/baykit/bayserver/tours/req_content_handler.rb +16 -13
- data/lib/baykit/bayserver/tours/tour.rb +2 -2
- data/lib/baykit/bayserver/tours/tour_handler.rb +36 -0
- data/lib/baykit/bayserver/tours/tour_req.rb +14 -24
- data/lib/baykit/bayserver/tours/tour_res.rb +5 -89
- data/lib/baykit/bayserver/tours/tour_store.rb +5 -5
- data/lib/baykit/bayserver/train/train_runner.rb +17 -13
- data/lib/baykit/bayserver/util/data_consume_listener.rb +1 -1
- data/lib/baykit/bayserver/util/executor_service.rb +11 -7
- data/lib/baykit/bayserver/util/ip_matcher.rb +9 -39
- data/lib/baykit/bayserver/util/locale.rb +1 -1
- data/lib/baykit/bayserver/util/selector.rb +24 -5
- data/lib/baykit/bayserver/util/sys_util.rb +6 -6
- data/lib/baykit/bayserver/version.rb +1 -1
- metadata +37 -18
- data/lib/baykit/bayserver/agent/grand_agent_monitor.rb +0 -231
- data/lib/baykit/bayserver/agent/transporter/plain_transporter.rb +0 -55
- data/lib/baykit/bayserver/agent/transporter/secure_transporter.rb +0 -81
- data/lib/baykit/bayserver/docker/base/inbound_handler.rb +0 -42
- data/lib/baykit/bayserver/docker/warp/package.rb +0 -4
- data/lib/baykit/bayserver/docker/warp/warp_data_listener.rb +0 -112
- data/lib/baykit/bayserver/docker/warp/warp_handler.rb +0 -38
- /data/lib/baykit/bayserver/{util → common}/cities.rb +0 -0
@@ -0,0 +1,127 @@
|
|
1
|
+
require 'baykit/bayserver/bayserver'
|
2
|
+
require 'baykit/bayserver/agent/grand_agent'
|
3
|
+
require 'baykit/bayserver/agent/timer_handler'
|
4
|
+
require 'baykit/bayserver/agent/lifecycle_listener'
|
5
|
+
require 'baykit/bayserver/util/executor_service'
|
6
|
+
require 'baykit/bayserver/sink'
|
7
|
+
|
8
|
+
module Baykit
|
9
|
+
module BayServer
|
10
|
+
module Common
|
11
|
+
class VehicleRunner
|
12
|
+
|
13
|
+
class AgentListener
|
14
|
+
include Baykit::BayServer::Agent::LifecycleListener # implements
|
15
|
+
include Baykit::BayServer::Agent
|
16
|
+
|
17
|
+
attr :runner
|
18
|
+
def initialize(runner)
|
19
|
+
@runner = runner
|
20
|
+
end
|
21
|
+
|
22
|
+
def add(agt_id)
|
23
|
+
while @runner.services.length < agt_id
|
24
|
+
@runner.services << nil
|
25
|
+
end
|
26
|
+
@runner.services[agt_id - 1] = VehicleRunner::VehicleService.new(GrandAgent.get(agt_id), @runner)
|
27
|
+
end
|
28
|
+
|
29
|
+
def remove(agt_id)
|
30
|
+
BayLog.debug("agt#%d remove VehicleRunner", agt_id)
|
31
|
+
@runner.services[agt_id - 1].terminate
|
32
|
+
@runner.services[agt_id - 1] = nil
|
33
|
+
end
|
34
|
+
end
|
35
|
+
|
36
|
+
|
37
|
+
class VehicleService
|
38
|
+
include Baykit::BayServer::Util
|
39
|
+
|
40
|
+
attr :agent
|
41
|
+
attr :exe
|
42
|
+
attr :runnings
|
43
|
+
attr :runnings_lock
|
44
|
+
|
45
|
+
def initialize(agt, runner)
|
46
|
+
@agent = agt
|
47
|
+
@agent.add_timer_handler(self)
|
48
|
+
@runnings = []
|
49
|
+
@runnings_lock = Mutex.new
|
50
|
+
@exe = ExecutorService.new("Runner", runner.max_vehicles)
|
51
|
+
end
|
52
|
+
|
53
|
+
########################################
|
54
|
+
# Implements TimerHandler
|
55
|
+
########################################
|
56
|
+
def on_timer
|
57
|
+
@runnings_lock.synchronize do
|
58
|
+
@runnings.each do |vcl|
|
59
|
+
vcl.on_timer
|
60
|
+
end
|
61
|
+
end
|
62
|
+
end
|
63
|
+
|
64
|
+
|
65
|
+
########################################
|
66
|
+
# Private methods
|
67
|
+
########################################
|
68
|
+
|
69
|
+
def terminate()
|
70
|
+
@agent.remove_timer_handler(self)
|
71
|
+
@exe.shutdown
|
72
|
+
end
|
73
|
+
|
74
|
+
def submit(vcl)
|
75
|
+
@exe.submit() do
|
76
|
+
if @agent.aborted
|
77
|
+
BayLog.error("%s Agent is aborted", @agent)
|
78
|
+
return
|
79
|
+
end
|
80
|
+
|
81
|
+
@runnings_lock.synchronize do
|
82
|
+
@runnings << vcl
|
83
|
+
end
|
84
|
+
|
85
|
+
begin
|
86
|
+
vcl.run
|
87
|
+
rescue => e
|
88
|
+
BayLog.fatal_e(e)
|
89
|
+
@agent.req_shutdown
|
90
|
+
ensure
|
91
|
+
@runnings_lock.synchronize do
|
92
|
+
@runnings.delete(vcl)
|
93
|
+
end
|
94
|
+
end
|
95
|
+
end
|
96
|
+
end
|
97
|
+
end
|
98
|
+
|
99
|
+
include Baykit::BayServer::Agent
|
100
|
+
|
101
|
+
attr :max_vehicles
|
102
|
+
attr :services
|
103
|
+
|
104
|
+
def initialize
|
105
|
+
@max_vehicles = 0
|
106
|
+
@services = []
|
107
|
+
end
|
108
|
+
|
109
|
+
########################################
|
110
|
+
# Custom methods
|
111
|
+
########################################
|
112
|
+
def init(max)
|
113
|
+
if(max <= 0)
|
114
|
+
raise Sink.new()
|
115
|
+
end
|
116
|
+
@max_vehicles = max
|
117
|
+
GrandAgent.add_lifecycle_listener(AgentListener.new(self))
|
118
|
+
end
|
119
|
+
|
120
|
+
def post(agt_id, vcl)
|
121
|
+
@services[agt_id - 1].submit(vcl)
|
122
|
+
end
|
123
|
+
|
124
|
+
end
|
125
|
+
end
|
126
|
+
end
|
127
|
+
end
|
@@ -1,12 +1,13 @@
|
|
1
|
+
require 'baykit/bayserver/agent/grand_agent'
|
1
2
|
require 'baykit/bayserver/tours/req_content_handler'
|
2
3
|
|
3
4
|
module Baykit
|
4
5
|
module BayServer
|
5
|
-
module
|
6
|
-
module Warp
|
6
|
+
module Common
|
7
7
|
class WarpData
|
8
8
|
include Baykit::BayServer::Tours::ReqContentHandler # implements
|
9
9
|
include Baykit::BayServer::Util
|
10
|
+
include Baykit::BayServer::Agent
|
10
11
|
|
11
12
|
attr :warp_ship
|
12
13
|
attr :warp_ship_id
|
@@ -26,7 +27,10 @@ module Baykit
|
|
26
27
|
@ended = false
|
27
28
|
end
|
28
29
|
|
29
|
-
|
30
|
+
################################
|
31
|
+
# Implements ReqContentHandler
|
32
|
+
################################
|
33
|
+
def on_read_req_content(tur, buf, start, len, &lis)
|
30
34
|
BayLog.debug("%s Read req content tur=%s len=%d", @warp_ship, tur, len);
|
31
35
|
@warp_ship.check_ship_id(@warp_ship_id)
|
32
36
|
max_len = @warp_ship.protocol_handler.max_req_packet_data_size()
|
@@ -44,34 +48,39 @@ module Baykit
|
|
44
48
|
buf = buf.dup()
|
45
49
|
end
|
46
50
|
|
47
|
-
@warp_ship.warp_handler.
|
51
|
+
@warp_ship.warp_handler.send_res_content(
|
48
52
|
tur,
|
49
53
|
buf,
|
50
54
|
start + pos,
|
51
55
|
post_len) do
|
52
|
-
tur.req.consumed(tur_id, len)
|
56
|
+
tur.req.consumed(tur_id, len, &lis)
|
53
57
|
end
|
54
58
|
pos += max_len
|
55
59
|
end
|
56
60
|
end
|
57
61
|
|
58
|
-
def
|
62
|
+
def on_end_req_content(tur)
|
59
63
|
BayLog.debug("%s End req content tur=%s", @warp_ship, tur)
|
60
64
|
@warp_ship.check_ship_id(@warp_ship_id)
|
61
|
-
@warp_ship.warp_handler.
|
65
|
+
@warp_ship.warp_handler.send_end_tour(tur, false) do
|
66
|
+
agt = GrandAgent.get(@warp_ship.agent_id)
|
67
|
+
agt.net_multiplexer.req_read(@warp_ship.rudder)
|
68
|
+
end
|
62
69
|
end
|
63
70
|
|
64
|
-
def
|
71
|
+
def on_abort_req(tur)
|
65
72
|
BayLog.debug("%s on req abort tur=%s", @warp_ship, tur)
|
66
73
|
@warp_ship.check_ship_id(@warp_ship_id)
|
67
74
|
@warp_ship.abort(@warp_ship_id)
|
68
75
|
return false # not aborted immediately
|
69
76
|
end
|
70
77
|
|
78
|
+
################################
|
79
|
+
# Other methods
|
80
|
+
################################
|
71
81
|
|
72
82
|
def start
|
73
83
|
if !@started
|
74
|
-
@warp_ship.protocol_handler.command_packer.flush(@warp_ship)
|
75
84
|
BayLog.debug("%s Start Warp tour", self)
|
76
85
|
@warp_ship.flush()
|
77
86
|
@started = true
|
@@ -86,7 +95,6 @@ module Baykit
|
|
86
95
|
return tur.req.content_handler
|
87
96
|
end
|
88
97
|
end
|
89
|
-
end
|
90
98
|
end
|
91
99
|
end
|
92
100
|
end
|
@@ -0,0 +1,27 @@
|
|
1
|
+
require 'baykit/bayserver/tours/tour_handler'
|
2
|
+
|
3
|
+
module Baykit
|
4
|
+
module BayServer
|
5
|
+
module Common
|
6
|
+
module WarpHandler # interface
|
7
|
+
include Baykit::BayServer::Tours::TourHandler
|
8
|
+
|
9
|
+
def next_warp_id()
|
10
|
+
raise NotImplementedError.new
|
11
|
+
end
|
12
|
+
|
13
|
+
def new_warp_data(warp_id)
|
14
|
+
raise NotImplementedError.new
|
15
|
+
end
|
16
|
+
|
17
|
+
#
|
18
|
+
# Verify if protocol is allowed
|
19
|
+
#
|
20
|
+
def verify_protocol(protocol)
|
21
|
+
raise NotImplementedError.new
|
22
|
+
end
|
23
|
+
|
24
|
+
end
|
25
|
+
end
|
26
|
+
end
|
27
|
+
end
|
@@ -1,20 +1,20 @@
|
|
1
1
|
require 'baykit/bayserver/util/counter'
|
2
2
|
require 'baykit/bayserver/util/http_status'
|
3
|
-
require 'baykit/bayserver/
|
3
|
+
require 'baykit/bayserver/common/warp_ship'
|
4
4
|
|
5
5
|
module Baykit
|
6
6
|
module BayServer
|
7
|
-
|
8
|
-
|
9
|
-
class WarpShip < Baykit::BayServer::WaterCraft::Ship
|
7
|
+
module Common
|
8
|
+
class WarpShip < Baykit::BayServer::Ships::Ship
|
10
9
|
include Baykit::BayServer::Agent
|
11
|
-
include Baykit::BayServer::
|
10
|
+
include Baykit::BayServer::Ships
|
12
11
|
include Baykit::BayServer::Tours
|
13
12
|
include Baykit::BayServer::Util
|
14
13
|
|
15
14
|
attr :tour_map
|
16
15
|
attr :docker
|
17
16
|
|
17
|
+
attr :protocol_handler
|
18
18
|
attr_accessor :connected
|
19
19
|
attr :socket_timeout_sec
|
20
20
|
attr :lock
|
@@ -30,17 +30,29 @@ module Baykit
|
|
30
30
|
@cmd_buf = []
|
31
31
|
end
|
32
32
|
|
33
|
+
def init_warp(rd, agt_id, tp, dkr, proto_hnd)
|
34
|
+
init(agt_id, rd, tp)
|
35
|
+
@docker = dkr
|
36
|
+
@socket_timeout_sec = @docker.timeout_sec >= 0 ? @docker.timeout_sec : BayServer.harbor.socket_timeout_sec
|
37
|
+
@protocol_handler = proto_hnd
|
38
|
+
@protocol_handler.init(self)
|
39
|
+
end
|
40
|
+
|
33
41
|
def to_s()
|
34
|
-
|
42
|
+
protocol = ""
|
43
|
+
if @protocol_handler != nil
|
44
|
+
protocol = "[#{@protocol_handler.protocol}]"
|
45
|
+
end
|
46
|
+
return "agt##{agent_id} wsip##{@ship_id}/#{@object_id}[#{protocol}]"
|
35
47
|
end
|
36
48
|
|
37
49
|
def inspect
|
38
50
|
to_s
|
39
51
|
end
|
40
52
|
|
41
|
-
|
53
|
+
#########################################
|
42
54
|
# Implements Reusable
|
43
|
-
|
55
|
+
#########################################
|
44
56
|
|
45
57
|
def reset()
|
46
58
|
super
|
@@ -52,19 +64,89 @@ module Baykit
|
|
52
64
|
@cmd_buf = []
|
53
65
|
end
|
54
66
|
|
67
|
+
#########################################
|
68
|
+
# Implements Ship
|
69
|
+
#########################################
|
70
|
+
def notify_handshake_done(proto)
|
71
|
+
@protocol_handler.verify_protocol(protocol)
|
72
|
+
NextSocketAction::CONTINUE
|
73
|
+
end
|
55
74
|
|
56
|
-
|
57
|
-
|
58
|
-
|
59
|
-
|
60
|
-
|
61
|
-
|
62
|
-
|
63
|
-
|
75
|
+
def notify_connect()
|
76
|
+
@connected = true
|
77
|
+
@tour_map.values.each do |pair|
|
78
|
+
tur = pair[1]
|
79
|
+
tur.check_tour_id pair[0]
|
80
|
+
WarpData.get(tur).start
|
81
|
+
end
|
82
|
+
NextSocketAction::CONTINUE
|
64
83
|
end
|
65
84
|
|
85
|
+
def notify_read(buf)
|
86
|
+
return @protocol_handler.bytes_received(buf)
|
87
|
+
end
|
88
|
+
|
89
|
+
def notify_eof()
|
90
|
+
BayLog.debug("%s EOF detected", self)
|
91
|
+
|
92
|
+
if @tour_map.empty?
|
93
|
+
BayLog.debug("%s No warp tours. only close", self)
|
94
|
+
return NextSocketAction::CLOSE
|
95
|
+
end
|
96
|
+
|
97
|
+
@tour_map.each do |warp_id, pair|
|
98
|
+
tur = pair[1]
|
99
|
+
tur.check_tour_id pair[0]
|
100
|
+
|
101
|
+
begin
|
102
|
+
if !tur.res.header_sent
|
103
|
+
BayLog.debug("%s Send ServiceUnavailable: tur=%s", self, tur)
|
104
|
+
tur.res.send_error(Tour::TOUR_ID_NOCHECK, HttpStatus::SERVICE_UNAVAILABLE, "Server closed on reading headers")
|
105
|
+
else
|
106
|
+
# NOT treat EOF as Error
|
107
|
+
BayLog.debug("%s EOF is not an error: tur=%s", self, tur)
|
108
|
+
tur.res.end_res_content(Tour::TOUR_ID_NOCHECK)
|
109
|
+
end
|
110
|
+
rescue IOError => e
|
111
|
+
BayLog::debug_e(e)
|
112
|
+
end
|
113
|
+
end
|
114
|
+
|
115
|
+
@tour_map.clear()
|
116
|
+
return NextSocketAction::CLOSE
|
117
|
+
end
|
118
|
+
|
119
|
+
def notify_error(e)
|
120
|
+
BayLog.error_e(e, "notify_error")
|
121
|
+
end
|
122
|
+
|
123
|
+
def notify_protocol_error(e)
|
124
|
+
BayLog.error_e(e)
|
125
|
+
notify_error_to_owner_tour(HttpStatus::SERVICE_UNAVAILABLE, e.message)
|
126
|
+
true
|
127
|
+
end
|
128
|
+
|
129
|
+
def notify_close
|
130
|
+
BayLog.debug("%s notifyClose", self)
|
131
|
+
notify_error_to_owner_tour(HttpStatus::SERVICE_UNAVAILABLE, "#{self} server closed")
|
132
|
+
end_ship()
|
133
|
+
end
|
134
|
+
|
135
|
+
def check_timeout(duration_sec)
|
136
|
+
if is_timeout(duration_sec)
|
137
|
+
notify_error_to_owner_tour(HttpStatus::GATEWAY_TIMEOUT, "#{self} server timeout")
|
138
|
+
true
|
139
|
+
else
|
140
|
+
false
|
141
|
+
end
|
142
|
+
end
|
143
|
+
|
144
|
+
################################
|
145
|
+
# Other methods
|
146
|
+
################################
|
147
|
+
|
66
148
|
def warp_handler
|
67
|
-
return @protocol_handler
|
149
|
+
return @protocol_handler.command_handler
|
68
150
|
end
|
69
151
|
|
70
152
|
def start_warp_tour(tur)
|
@@ -80,7 +162,7 @@ module Baykit
|
|
80
162
|
end
|
81
163
|
|
82
164
|
@tour_map[warp_id] = [tur.id(), tur]
|
83
|
-
w_hnd.
|
165
|
+
w_hnd.send_res_headers(tur)
|
84
166
|
|
85
167
|
if @connected
|
86
168
|
BayLog.debug("%s is already connected. Start warp tour:%s", wdat, tur);
|
@@ -97,7 +179,7 @@ module Baykit
|
|
97
179
|
else
|
98
180
|
@tour_map.delete wdat.warp_id
|
99
181
|
end
|
100
|
-
@docker.
|
182
|
+
@docker.keep(self)
|
101
183
|
end
|
102
184
|
|
103
185
|
def notify_service_unavailable(msg)
|
@@ -137,7 +219,7 @@ module Baykit
|
|
137
219
|
BayLog.error_e(e)
|
138
220
|
end
|
139
221
|
else
|
140
|
-
tur.res.
|
222
|
+
tur.res.end_res_content(Tour::TOUR_ID_NOCHECK)
|
141
223
|
end
|
142
224
|
end
|
143
225
|
@tour_map.clear
|
@@ -146,13 +228,12 @@ module Baykit
|
|
146
228
|
|
147
229
|
|
148
230
|
def end_ship()
|
149
|
-
@docker.
|
150
|
-
@docker.return_ship(self)
|
231
|
+
@docker.on_end_ship(self)
|
151
232
|
end
|
152
233
|
|
153
234
|
def abort(check_id)
|
154
235
|
check_ship_id(check_id)
|
155
|
-
@
|
236
|
+
@transporter.req_close(@rudder)
|
156
237
|
end
|
157
238
|
|
158
239
|
def is_timeout(duration)
|
@@ -170,14 +251,14 @@ module Baykit
|
|
170
251
|
return timeout
|
171
252
|
end
|
172
253
|
|
173
|
-
def post(cmd, listener
|
254
|
+
def post(cmd, &listener)
|
174
255
|
if !@connected
|
175
256
|
@cmd_buf << [cmd, listener]
|
176
257
|
else
|
177
258
|
if cmd == nil
|
178
259
|
listener.call()
|
179
260
|
else
|
180
|
-
@protocol_handler.
|
261
|
+
@protocol_handler.post(cmd, &listener)
|
181
262
|
end
|
182
263
|
end
|
183
264
|
end
|
@@ -188,13 +269,12 @@ module Baykit
|
|
188
269
|
if cmd == nil
|
189
270
|
lis.call()
|
190
271
|
else
|
191
|
-
@protocol_handler.
|
272
|
+
@protocol_handler.post(cmd, &lis)
|
192
273
|
end
|
193
274
|
end
|
194
275
|
@cmd_buf = []
|
195
276
|
end
|
196
277
|
end
|
197
278
|
end
|
198
|
-
end
|
199
279
|
end
|
200
280
|
end
|
@@ -1,14 +1,13 @@
|
|
1
1
|
require 'baykit/bayserver/protocol/packet_store'
|
2
|
-
require 'baykit/bayserver/
|
2
|
+
require 'baykit/bayserver/common/warp_ship'
|
3
3
|
|
4
4
|
module Baykit
|
5
5
|
module BayServer
|
6
|
-
module
|
7
|
-
module Warp
|
6
|
+
module Common
|
8
7
|
class WarpShipStore < Baykit::BayServer::Util::ObjectStore
|
9
8
|
include Baykit::BayServer::Protocol
|
10
9
|
include Baykit::BayServer::Util
|
11
|
-
include Baykit::BayServer::
|
10
|
+
include Baykit::BayServer::Common
|
12
11
|
|
13
12
|
attr :keep_list
|
14
13
|
attr :busy_list
|
@@ -49,9 +48,6 @@ module Baykit
|
|
49
48
|
if wsip == nil
|
50
49
|
raise Sink.new("BUG! ship is null")
|
51
50
|
end
|
52
|
-
if wsip.postman != nil && wsip.postman.zombie?
|
53
|
-
raise Sink("channel is zombie: %s", wsip)
|
54
|
-
end
|
55
51
|
@busy_list.append(wsip)
|
56
52
|
|
57
53
|
BayLog.trace(" rent keepList=%s busyList=%s", @keep_list, @busy_list)
|
@@ -105,7 +101,6 @@ module Baykit
|
|
105
101
|
super
|
106
102
|
end
|
107
103
|
end
|
108
|
-
end
|
109
104
|
end
|
110
105
|
end
|
111
106
|
end
|
@@ -1,6 +1,6 @@
|
|
1
1
|
require 'baykit/bayserver/agent/next_socket_action'
|
2
2
|
require 'baykit/bayserver/agent/transporter/data_listener'
|
3
|
-
require 'baykit/bayserver/
|
3
|
+
require 'baykit/bayserver/ships/ship'
|
4
4
|
require 'baykit/bayserver/tours/package'
|
5
5
|
|
6
6
|
module Baykit
|
@@ -50,7 +50,7 @@ module Baykit
|
|
50
50
|
if BayLog.debug_mode?
|
51
51
|
BayLog.error_e(err)
|
52
52
|
end
|
53
|
-
return @ship.protocol_handler.
|
53
|
+
return @ship.protocol_handler.on_protocol_error(err)
|
54
54
|
end
|
55
55
|
|
56
56
|
def notify_close
|
@@ -1,13 +1,13 @@
|
|
1
1
|
require 'baykit/bayserver/protocol/protocol_handler_store'
|
2
2
|
require 'baykit/bayserver/bcf/package'
|
3
|
-
require 'baykit/bayserver/agent/
|
3
|
+
require 'baykit/bayserver/agent/multiplexer/plain_transporter'
|
4
|
+
require 'baykit/bayserver/rudders/io_rudder'
|
4
5
|
require 'baykit/bayserver/util/object_store'
|
5
6
|
require 'baykit/bayserver/util/object_factory'
|
6
7
|
|
7
8
|
require 'baykit/bayserver/docker/port'
|
8
9
|
require 'baykit/bayserver/docker/base/docker_base'
|
9
|
-
require 'baykit/bayserver/
|
10
|
-
require 'baykit/bayserver/docker/base/inbound_ship_store'
|
10
|
+
require 'baykit/bayserver/common/inbound_ship_store'
|
11
11
|
|
12
12
|
module Baykit
|
13
13
|
module BayServer
|
@@ -18,12 +18,14 @@ module Baykit
|
|
18
18
|
|
19
19
|
include Baykit::BayServer::Bcf
|
20
20
|
include Baykit::BayServer::Agent
|
21
|
-
include Baykit::BayServer::Agent::
|
21
|
+
include Baykit::BayServer::Agent::Multiplexer
|
22
22
|
include Baykit::BayServer::Docker
|
23
23
|
include Baykit::BayServer::Docker::Base
|
24
24
|
include Baykit::BayServer::WaterCraft
|
25
25
|
include Baykit::BayServer::Protocol
|
26
|
+
include Baykit::BayServer::Rudders
|
26
27
|
include Baykit::BayServer::Util
|
28
|
+
include Baykit::BayServer::Common
|
27
29
|
|
28
30
|
attr :permission_list
|
29
31
|
attr :host
|
@@ -48,18 +50,18 @@ module Baykit
|
|
48
50
|
end
|
49
51
|
|
50
52
|
def to_s()
|
51
|
-
return super + "[
|
53
|
+
return super + "[#{@port}]"
|
52
54
|
end
|
53
55
|
|
54
56
|
######################################################
|
55
57
|
# Abstract methods
|
56
58
|
######################################################
|
57
59
|
def support_anchored()
|
58
|
-
raise NotImplementedError
|
60
|
+
raise NotImplementedError.new
|
59
61
|
end
|
60
62
|
|
61
63
|
def support_unanchored()
|
62
|
-
raise NotImplementedError
|
64
|
+
raise NotImplementedError.new
|
63
65
|
end
|
64
66
|
|
65
67
|
######################################################
|
@@ -178,46 +180,76 @@ module Baykit
|
|
178
180
|
return @secure_docker != nil
|
179
181
|
end
|
180
182
|
|
181
|
-
def check_admitted(skt)
|
182
|
-
@permission_list.each do |perm_dkr|
|
183
|
-
perm_dkr.socket_admitted(skt)
|
184
|
-
end
|
185
|
-
end
|
186
183
|
|
187
184
|
def find_city(name)
|
188
185
|
return @cities.find_city(name)
|
189
186
|
end
|
190
187
|
|
191
|
-
def
|
192
|
-
|
188
|
+
def on_connected(agt_id, rd)
|
189
|
+
|
190
|
+
check_admitted(rd)
|
191
|
+
|
192
|
+
sip = PortBase.get_ship_store(agt_id).rent()
|
193
|
+
agt = GrandAgent.get(agt_id)
|
194
|
+
|
193
195
|
if secure()
|
194
|
-
tp = @secure_docker.
|
196
|
+
tp = @secure_docker.new_transporter(
|
197
|
+
agt_id,
|
198
|
+
sip,
|
199
|
+
IOUtil.get_sock_recv_buf_size(rd.io))
|
200
|
+
|
201
|
+
ssl_socket = tp.new_ssl_socket(rd.io)
|
202
|
+
rd = IORudder.new(ssl_socket)
|
203
|
+
if agt.net_multiplexer.is_non_blocking
|
204
|
+
rd.set_non_blocking
|
205
|
+
end
|
206
|
+
|
195
207
|
else
|
196
|
-
|
208
|
+
size = IOUtil.get_sock_recv_buf_size(rd.io)
|
209
|
+
|
210
|
+
tp = PlainTransporter.new(
|
211
|
+
agt.net_multiplexer,
|
212
|
+
sip,
|
213
|
+
true,
|
214
|
+
size,
|
215
|
+
false)
|
197
216
|
end
|
198
217
|
|
199
|
-
proto_hnd = PortBase.get_protocol_handler_store(protocol(),
|
200
|
-
sip.init_inbound(
|
201
|
-
|
202
|
-
|
218
|
+
proto_hnd = PortBase.get_protocol_handler_store(protocol(), agt_id).rent()
|
219
|
+
sip.init_inbound(rd, agt_id, tp, self, proto_hnd)
|
220
|
+
|
221
|
+
st = RudderState.new(rd, tp)
|
222
|
+
agt.net_multiplexer.add_rudder_state(rd, st)
|
223
|
+
agt.net_multiplexer.req_read(rd)
|
203
224
|
end
|
204
225
|
|
205
|
-
def return_protocol_handler(
|
226
|
+
def return_protocol_handler(agt_id, proto_hnd)
|
206
227
|
BayLog.debug("%s Return protocol handler", proto_hnd)
|
207
|
-
PortBase.get_protocol_handler_store(proto_hnd.protocol,
|
228
|
+
PortBase.get_protocol_handler_store(proto_hnd.protocol, agt_id).Return(proto_hnd)
|
208
229
|
end
|
209
230
|
|
210
231
|
def return_ship(sip)
|
211
232
|
BayLog.debug("%s end (return ship)", sip)
|
212
|
-
PortBase.get_ship_store(sip.
|
233
|
+
PortBase.get_ship_store(sip.agent_id).Return(sip)
|
234
|
+
end
|
235
|
+
|
236
|
+
######################################################
|
237
|
+
# Private methods
|
238
|
+
######################################################
|
239
|
+
private
|
240
|
+
|
241
|
+
def check_admitted(rd)
|
242
|
+
@permission_list.each do |perm_dkr|
|
243
|
+
perm_dkr.socket_admitted(rd)
|
244
|
+
end
|
213
245
|
end
|
214
246
|
|
215
|
-
def PortBase.get_ship_store(
|
216
|
-
return InboundShipStore.get_store(
|
247
|
+
def PortBase.get_ship_store(agt_id)
|
248
|
+
return InboundShipStore.get_store(agt_id)
|
217
249
|
end
|
218
250
|
|
219
|
-
def PortBase.get_protocol_handler_store(proto,
|
220
|
-
return ProtocolHandlerStore.get_store(proto, true,
|
251
|
+
def PortBase.get_protocol_handler_store(proto, agt_id)
|
252
|
+
return ProtocolHandlerStore.get_store(proto, true, agt_id)
|
221
253
|
end
|
222
254
|
|
223
255
|
end
|