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
@@ -2,25 +2,28 @@ require 'uri'
|
|
2
2
|
|
3
3
|
require 'baykit/bayserver/agent/grand_agent'
|
4
4
|
require 'baykit/bayserver/agent/lifecycle_listener'
|
5
|
+
require 'baykit/bayserver/agent/multiplexer/rudder_state'
|
6
|
+
require 'baykit/bayserver/docker/warp'
|
5
7
|
require 'baykit/bayserver/docker/base/club_base'
|
6
|
-
require 'baykit/bayserver/
|
7
|
-
require 'baykit/bayserver/
|
8
|
-
require 'baykit/bayserver/docker/warp/warp_ship_store'
|
8
|
+
require 'baykit/bayserver/common/warp_data'
|
9
|
+
require 'baykit/bayserver/common/warp_ship_store'
|
9
10
|
|
10
11
|
module Baykit
|
11
12
|
module BayServer
|
12
13
|
module Docker
|
13
|
-
module
|
14
|
-
class
|
14
|
+
module Base
|
15
|
+
class WarpBase < Baykit::BayServer::Docker::Base::ClubBase
|
16
|
+
include Baykit::BayServer::Docker::Warp # implements
|
15
17
|
|
16
18
|
include Baykit::BayServer::Agent
|
19
|
+
include Baykit::BayServer::Agent::Multiplexer
|
17
20
|
include Baykit::BayServer::Protocol
|
18
|
-
include Baykit::BayServer::Bcf
|
19
21
|
include Baykit::BayServer::Util
|
20
|
-
include Baykit::BayServer::
|
22
|
+
include Baykit::BayServer::Rudders
|
21
23
|
|
22
24
|
class AgentListener
|
23
|
-
include Baykit::BayServer::Agent::LifecycleListener
|
25
|
+
include Baykit::BayServer::Agent::LifecycleListener # implements
|
26
|
+
include Baykit::BayServer::Common
|
24
27
|
|
25
28
|
attr :warp_docker
|
26
29
|
|
@@ -28,25 +31,12 @@ module Baykit
|
|
28
31
|
@warp_docker = dkr
|
29
32
|
end
|
30
33
|
|
31
|
-
def add(
|
32
|
-
@warp_docker.stores[
|
34
|
+
def add(agt_id)
|
35
|
+
@warp_docker.stores[agt_id] = WarpShipStore.new(@warp_docker.max_ships);
|
33
36
|
end
|
34
37
|
|
35
|
-
def remove(
|
36
|
-
@warp_docker.stores.delete(
|
37
|
-
end
|
38
|
-
end
|
39
|
-
|
40
|
-
|
41
|
-
class WarpShipHolder
|
42
|
-
attr :owner_id
|
43
|
-
attr :ship_id
|
44
|
-
attr :ship
|
45
|
-
|
46
|
-
def initialize(owner_id, ship_id, ship)
|
47
|
-
@owner_id = owner_id
|
48
|
-
@ship_id = ship_id
|
49
|
-
@ship = ship
|
38
|
+
def remove(agt_id)
|
39
|
+
@warp_docker.stores.delete(agt_id);
|
50
40
|
end
|
51
41
|
end
|
52
42
|
|
@@ -55,7 +45,6 @@ module Baykit
|
|
55
45
|
attr :port
|
56
46
|
attr :warp_base
|
57
47
|
attr :max_ships
|
58
|
-
attr :cur_ships
|
59
48
|
attr :host_addr
|
60
49
|
attr :timeout_sec
|
61
50
|
attr :tour_list
|
@@ -67,13 +56,21 @@ module Baykit
|
|
67
56
|
######################################################
|
68
57
|
# Abstract methods
|
69
58
|
######################################################
|
70
|
-
|
71
|
-
|
72
|
-
|
73
|
-
|
74
|
-
|
75
|
-
|
59
|
+
def secure
|
60
|
+
raise NotImplementedError.new
|
61
|
+
end
|
62
|
+
|
63
|
+
def protocol
|
64
|
+
raise NotImplementedError.new
|
65
|
+
end
|
76
66
|
|
67
|
+
def new_transporter(agent, rd, ship)
|
68
|
+
raise NotImplementedError.new
|
69
|
+
end
|
70
|
+
|
71
|
+
######################################################
|
72
|
+
# Initialize methods
|
73
|
+
######################################################
|
77
74
|
def initialize
|
78
75
|
super
|
79
76
|
@scheme = nil
|
@@ -81,7 +78,6 @@ module Baykit
|
|
81
78
|
@port = 0
|
82
79
|
@warp_base = nil
|
83
80
|
@max_ships = -1
|
84
|
-
@cur_ships = 0
|
85
81
|
@host_addr = nil
|
86
82
|
@tour_list = []
|
87
83
|
@timeout_sec = -1 # -1 means "Use harbor.socketTimeoutSec"
|
@@ -180,7 +176,7 @@ module Baykit
|
|
180
176
|
######################################################
|
181
177
|
|
182
178
|
def arrive(tur)
|
183
|
-
agt = tur.ship.
|
179
|
+
agt = GrandAgent.get(tur.ship.agent_id)
|
184
180
|
sto = get_ship_store(agt.agent_id)
|
185
181
|
|
186
182
|
wsip = sto.rent()
|
@@ -199,12 +195,12 @@ module Baykit
|
|
199
195
|
else
|
200
196
|
skt = Socket.new(@host_addr[1].ipv4? ? Socket::AF_INET : Socket::AF_INET6, Socket::SOCK_STREAM, 0)
|
201
197
|
end
|
202
|
-
|
198
|
+
rd = IORudder.new(skt)
|
203
199
|
|
204
|
-
tp = new_transporter(agt,
|
200
|
+
tp = new_transporter(agt, rd, wsip)
|
205
201
|
proto_hnd = ProtocolHandlerStore.get_store(protocol(), false, agt.agent_id).rent()
|
206
|
-
wsip.init_warp(
|
207
|
-
|
202
|
+
wsip.init_warp(rd, agt.agent_id, tp, self, proto_hnd)
|
203
|
+
|
208
204
|
BayLog.debug("%s init warp ship", wsip)
|
209
205
|
BayLog.debug("%s Connect to %s:%d skt=%s", wsip, @host, @port, skt)
|
210
206
|
|
@@ -218,8 +214,8 @@ module Baykit
|
|
218
214
|
wsip.start_warp_tour(tur)
|
219
215
|
|
220
216
|
if need_connect
|
221
|
-
agt.
|
222
|
-
agt.
|
217
|
+
agt.net_multiplexer.add_rudder_state(wsip.rudder, RudderState.new(wsip.rudder, tp))
|
218
|
+
agt.net_multiplexer.get_transporter(wsip.rudder).req_connect(wsip.rudder, @host_addr[1])
|
223
219
|
end
|
224
220
|
|
225
221
|
rescue SystemCallError => e
|
@@ -234,21 +230,18 @@ module Baykit
|
|
234
230
|
|
235
231
|
|
236
232
|
######################################################
|
237
|
-
# Implements
|
233
|
+
# Implements Warp
|
238
234
|
######################################################
|
239
|
-
def
|
235
|
+
def keep(wsip)
|
240
236
|
BayLog.debug("%s keepShip: %s", self, wsip)
|
241
|
-
get_ship_store(wsip.
|
237
|
+
get_ship_store(wsip.agent_id).keep(wsip)
|
242
238
|
end
|
243
239
|
|
244
|
-
def
|
240
|
+
def on_end_ship(wsip)
|
241
|
+
BayLog.debug("%s Return protocol handler: ", wsip)
|
242
|
+
get_protocol_handler_store(wsip.agent_id).Return(wsip.protocol_handler)
|
245
243
|
BayLog.debug("%s return ship: %s", self, wsip);
|
246
|
-
get_ship_store(wsip.
|
247
|
-
end
|
248
|
-
|
249
|
-
def return_protocol_handler(agt, phnd)
|
250
|
-
BayLog.debug("%s Return protocol handler: ", phnd)
|
251
|
-
get_protocol_handler_store(agt.agent_id).Return(phnd)
|
244
|
+
get_ship_store(wsip.agent_id).Return(wsip)
|
252
245
|
end
|
253
246
|
|
254
247
|
######################################################
|
@@ -4,7 +4,7 @@ require 'baykit/bayserver/docker/base/docker_base'
|
|
4
4
|
require 'baykit/bayserver/constants'
|
5
5
|
require 'baykit/bayserver/config_exception'
|
6
6
|
|
7
|
-
require 'baykit/bayserver/
|
7
|
+
require 'baykit/bayserver/common/groups'
|
8
8
|
require 'baykit/bayserver/util/sys_util'
|
9
9
|
|
10
10
|
|
@@ -19,6 +19,7 @@ module Baykit
|
|
19
19
|
include Baykit::BayServer
|
20
20
|
include Baykit::BayServer::Bcf
|
21
21
|
include Baykit::BayServer::Util
|
22
|
+
include Baykit::BayServer::Common
|
22
23
|
include Baykit::BayServer::Constants
|
23
24
|
|
24
25
|
DEFAULT_MAX_SHIPS = 256
|
@@ -33,7 +34,11 @@ module Baykit
|
|
33
34
|
DEFAULT_CONTROL_PORT = -1
|
34
35
|
DEFAULT_MULTI_CORE = true
|
35
36
|
DEFAULT_GZIP_COMP = false
|
36
|
-
|
37
|
+
DEFAULT_NET_MULTIPLEXER = MULTIPLEXER_TYPE_SPIDER
|
38
|
+
DEFAULT_FILE_MULTIPLEXER = MULTIPLEXER_TYPE_SPIDER
|
39
|
+
DEFAULT_LOG_MULTIPLEXER = MULTIPLEXER_TYPE_SPIDER
|
40
|
+
DEFAULT_CGI_MULTIPLEXER = MULTIPLEXER_TYPE_SPIDER
|
41
|
+
DEFAULT_RECIPIENT = RECIPIENT_TYPE_SPIDER
|
37
42
|
DEFAULT_PID_FILE = "bayserver.pid"
|
38
43
|
|
39
44
|
# Default charset
|
@@ -84,8 +89,20 @@ module Baykit
|
|
84
89
|
# Multi core flag
|
85
90
|
attr :multi_core
|
86
91
|
|
87
|
-
#
|
88
|
-
attr :
|
92
|
+
# Multiplexer type of network I/O
|
93
|
+
attr :net_multiplexer
|
94
|
+
|
95
|
+
# Multiplexer type of file read
|
96
|
+
attr :file_multiplexer
|
97
|
+
|
98
|
+
# Multiplexer type of log output
|
99
|
+
attr :log_multiplexer
|
100
|
+
|
101
|
+
# Multiplexer type of CGI input
|
102
|
+
attr :cgi_multiplexer
|
103
|
+
|
104
|
+
# Recipient type
|
105
|
+
attr :recipient
|
89
106
|
|
90
107
|
# PID file name
|
91
108
|
attr :pid_file
|
@@ -105,7 +122,11 @@ module Baykit
|
|
105
122
|
@control_port = DEFAULT_CONTROL_PORT
|
106
123
|
@multi_core = DEFAULT_MULTI_CORE
|
107
124
|
@gzip_comp = DEFAULT_GZIP_COMP
|
108
|
-
@
|
125
|
+
@net_multiplexer = DEFAULT_NET_MULTIPLEXER
|
126
|
+
@file_multiplexer = DEFAULT_FILE_MULTIPLEXER
|
127
|
+
@log_multiplexer = DEFAULT_LOG_MULTIPLEXER
|
128
|
+
@cgi_multiplexer = DEFAULT_CGI_MULTIPLEXER
|
129
|
+
@recipient = DEFAULT_RECIPIENT
|
109
130
|
@pid_file = DEFAULT_PID_FILE
|
110
131
|
end
|
111
132
|
|
@@ -128,22 +149,61 @@ module Baykit
|
|
128
149
|
BayLog.warn(BayMessage.get(:CFG_MAX_SHIPS_IS_TO_SMALL, @max_ships))
|
129
150
|
end
|
130
151
|
|
131
|
-
if @
|
132
|
-
|
133
|
-
|
152
|
+
if @net_multiplexer == MULTIPLEXER_TYPE_TAXI ||
|
153
|
+
@net_multiplexer == MULTIPLEXER_TYPE_TRAIN ||
|
154
|
+
@net_multiplexer == MULTIPLEXER_TYPE_SPIN
|
155
|
+
BayLog.warn(
|
156
|
+
BayMessage.get(
|
157
|
+
:CFG_NET_MULTIPLEXER_NOT_SUPPORTED,
|
158
|
+
Harbor::get_multiplexer_type_name(@net_multiplexer),
|
159
|
+
Harbor::get_multiplexer_type_name(DEFAULT_NET_MULTIPLEXER)))
|
160
|
+
@net_multiplexer = DEFAULT_NET_MULTIPLEXER
|
134
161
|
end
|
135
162
|
|
136
|
-
if @
|
137
|
-
|
138
|
-
|
163
|
+
if @file_multiplexer == MULTIPLEXER_TYPE_SPIDER and !SysUtil.support_select_file ||
|
164
|
+
@file_multiplexer == MULTIPLEXER_TYPE_SPIN and !SysUtil.support_nonblock_file_read ||
|
165
|
+
@file_multiplexer == MULTIPLEXER_TYPE_TRAIN
|
166
|
+
BayLog.warn(
|
167
|
+
BayMessage.get(
|
168
|
+
:CFG_FILE_MULTIPLEXER_NOT_SUPPORTED,
|
169
|
+
Harbor::get_multiplexer_type_name(@file_multiplexer),
|
170
|
+
Harbor::get_multiplexer_type_name(DEFAULT_FILE_MULTIPLEXER)))
|
171
|
+
@file_multiplexer = DEFAULT_FILE_MULTIPLEXER
|
139
172
|
end
|
140
173
|
|
174
|
+
if @log_multiplexer == MULTIPLEXER_TYPE_SPIDER and !SysUtil.support_select_file ||
|
175
|
+
@log_multiplexer == MULTIPLEXER_TYPE_SPIN and !SysUtil.support_nonblock_file_write ||
|
176
|
+
@log_multiplexer == MULTIPLEXER_TYPE_TRAIN
|
177
|
+
BayLog.warn(
|
178
|
+
BayMessage.get(
|
179
|
+
:CFG_LOG_MULTIPLEXER_NOT_SUPPORTED,
|
180
|
+
Harbor::get_multiplexer_type_name(@log_multiplexer),
|
181
|
+
Harbor::get_multiplexer_type_name(DEFAULT_LOG_MULTIPLEXER)))
|
182
|
+
@log_multiplexer = DEFAULT_LOG_MULTIPLEXER
|
183
|
+
end
|
141
184
|
|
142
|
-
|
185
|
+
if @log_multiplexer == MULTIPLEXER_TYPE_SPIN ||
|
186
|
+
@log_multiplexer == MULTIPLEXER_TYPE_PIGEON
|
187
|
+
BayLog.warn(
|
188
|
+
BayMessage.get(
|
189
|
+
:CFG_CGI_MULTIPLEXER_NOT_SUPPORTED,
|
190
|
+
Harbor::get_multiplexer_type_name(@cgi_multiplexer),
|
191
|
+
Harbor::get_multiplexer_type_name(DEFAULT_CGI_MULTIPLEXER)))
|
192
|
+
@cgi_multiplexer = DEFAULT_CGI_MULTIPLEXER
|
193
|
+
end
|
143
194
|
|
144
|
-
|
145
|
-
|
146
|
-
|
195
|
+
if @net_multiplexer == MULTIPLEXER_TYPE_SPIDER &&
|
196
|
+
@recipient != RECIPIENT_TYPE_SPIDER
|
197
|
+
BayLog.warn(
|
198
|
+
BayMessage.get(
|
199
|
+
:CFG_NET_MULTIPLEXER_DOES_NOT_SUPPORT_THIS_RECIPIENT,
|
200
|
+
Harbor::get_multiplexer_type_name(@net_multiplexer),
|
201
|
+
Harbor::get_recipient_type_name(@recipient),
|
202
|
+
Harbor::get_recipient_type_name(RECIPIENT_TYPE_SPIDER)))
|
203
|
+
@recipient = RECIPIENT_TYPE_SPIDER
|
204
|
+
end
|
205
|
+
|
206
|
+
end
|
147
207
|
|
148
208
|
def init_docker(dkr)
|
149
209
|
if dkr.instance_of?(Trouble)
|
@@ -193,17 +253,47 @@ module Baykit
|
|
193
253
|
@multi_core = StringUtil.parse_bool(kv.value)
|
194
254
|
when "gzipcomp"
|
195
255
|
@gzip_comp = StringUtil.parse_bool(kv.value)
|
196
|
-
|
197
|
-
|
198
|
-
|
199
|
-
@
|
200
|
-
|
201
|
-
|
202
|
-
|
203
|
-
@file_send_method = FILE_SEND_METHOD_TAXI
|
204
|
-
else
|
205
|
-
raise ConfigException.new(kv.file_name, kv.line_no, BayMessage.get(:CFG_INVALID_PARAMETER_VALUE, kv.value))
|
256
|
+
|
257
|
+
when "netmultiplexer"
|
258
|
+
begin
|
259
|
+
@net_multiplexer = Harbor::get_multiplexer_type(kv.value.downcase)
|
260
|
+
rescue => e
|
261
|
+
BayLog.error_e(e)
|
262
|
+
raise ConfigException.new(kv.file_name, kv.line_no, BayMessage::get(:CFG_INVALID_PARAMETER_VALUE, kv.value))
|
206
263
|
end
|
264
|
+
|
265
|
+
when "filemultiplexer"
|
266
|
+
begin
|
267
|
+
@file_multiplexer = Harbor::get_multiplexer_type(kv.value.downcase)
|
268
|
+
rescue => e
|
269
|
+
BayLog.error_e(e)
|
270
|
+
raise ConfigException.new(kv.file_name, kv.line_no, BayMessage::get(:CFG_INVALID_PARAMETER_VALUE, kv.value))
|
271
|
+
end
|
272
|
+
|
273
|
+
when "logmultiplexer"
|
274
|
+
begin
|
275
|
+
@log_multiplexer = Harbor.get_multiplexer_type(kv.value.downcase)
|
276
|
+
rescue => e
|
277
|
+
BayLog.error_e(e)
|
278
|
+
raise ConfigException.new(kv.file_name, kv.line_no, BayMessage::get(:CFG_INVALID_PARAMETER_VALUE, kv.value))
|
279
|
+
end
|
280
|
+
|
281
|
+
when "cgimultiplexer"
|
282
|
+
begin
|
283
|
+
@cgi_multiplexer = Harbor.get_multiplexer_type(kv.value.downcase)
|
284
|
+
rescue => e
|
285
|
+
BayLog.error_e(e)
|
286
|
+
raise ConfigException.new(kv.file_name, kv.line_no, BayMessage::get(:CFG_INVALID_PARAMETER_VALUE, kv.value))
|
287
|
+
end
|
288
|
+
|
289
|
+
when "recipient"
|
290
|
+
begin
|
291
|
+
@recipient = Harbor.get_recipient_type(kv.value.downcase)
|
292
|
+
rescue => e
|
293
|
+
BayLog.error_e(e)
|
294
|
+
raise ConfigException.new(kv.file_name, kv.line_no, BayMessage::get(:CFG_INVALID_PARAMETER_VALUE, kv.value))
|
295
|
+
end
|
296
|
+
|
207
297
|
when "pidfile"
|
208
298
|
@pid_file = kv.value
|
209
299
|
else
|
@@ -212,13 +302,10 @@ module Baykit
|
|
212
302
|
true
|
213
303
|
end
|
214
304
|
|
215
|
-
|
216
|
-
|
217
|
-
|
305
|
+
#######################
|
306
|
+
# Implements Harbor
|
307
|
+
#######################
|
218
308
|
|
219
|
-
def multi_core?
|
220
|
-
@multi_core
|
221
|
-
end
|
222
309
|
end
|
223
310
|
end
|
224
311
|
end
|
@@ -1,7 +1,8 @@
|
|
1
1
|
require 'baykit/bayserver/agent/grand_agent'
|
2
2
|
require 'baykit/bayserver/agent/lifecycle_listener'
|
3
|
-
require 'baykit/bayserver/agent/
|
4
|
-
require 'baykit/bayserver/agent/
|
3
|
+
require 'baykit/bayserver/agent/multiplexer/plain_transporter'
|
4
|
+
require 'baykit/bayserver/agent/multiplexer/rudder_state'
|
5
|
+
require 'baykit/bayserver/rudders/io_rudder'
|
5
6
|
require 'baykit/bayserver/docker/built_in/write_file_taxi'
|
6
7
|
require 'baykit/bayserver/docker/log'
|
7
8
|
require 'baykit/bayserver/docker/built_in/log_items'
|
@@ -14,15 +15,18 @@ module Baykit
|
|
14
15
|
module BuiltIn
|
15
16
|
class BuiltInLogDocker < Baykit::BayServer::Docker::Base::DockerBase
|
16
17
|
include Baykit::BayServer::Docker::Log # implements
|
17
|
-
include Baykit::BayServer::Agent::Transporter
|
18
|
-
include Baykit::BayServer::Agent
|
19
|
-
include Baykit::BayServer::Util
|
20
18
|
|
19
|
+
include Baykit::BayServer::Docker
|
20
|
+
include Baykit::BayServer::Util
|
21
21
|
include Baykit::BayServer::Bcf
|
22
|
+
include Baykit::BayServer::Agent
|
22
23
|
|
23
24
|
class AgentListener
|
25
|
+
include Baykit::BayServer::Agent::Multiplexer
|
24
26
|
include Baykit::BayServer::Agent::LifecycleListener # implements
|
25
27
|
include Baykit::BayServer::Agent::Transporter
|
28
|
+
include Baykit::BayServer::Agent
|
29
|
+
include Baykit::BayServer::Rudders
|
26
30
|
|
27
31
|
attr :log_docker
|
28
32
|
|
@@ -30,48 +34,58 @@ module Baykit
|
|
30
34
|
@log_docker = dkr
|
31
35
|
end
|
32
36
|
|
33
|
-
def add(
|
34
|
-
file_name = "#{@log_docker.file_prefix}_#{
|
37
|
+
def add(agt_id)
|
38
|
+
file_name = "#{@log_docker.file_prefix}_#{agt_id}.#{@log_docker.file_ext}"
|
39
|
+
size = 0
|
40
|
+
if ::File.exist?(file_name)
|
41
|
+
size = ::File.size(file_name)
|
42
|
+
end
|
43
|
+
agt = GrandAgent.get(agt_id)
|
35
44
|
|
36
|
-
|
45
|
+
begin
|
46
|
+
f = File.open(file_name, "a")
|
47
|
+
rescue => e
|
48
|
+
BayLog.fatal(BayMessage.get(:INT_CANNOT_OPEN_LOG_FILE, file_name))
|
49
|
+
BayLog.fatal_e(e);
|
50
|
+
end
|
37
51
|
|
38
|
-
|
39
|
-
when LOG_WRITE_METHOD_SELECT
|
40
|
-
tp = PlainTransporter.new(false, 0, true) # write only
|
41
|
-
tp.init(agt.non_blocking_handler, File.open(file_name, "a"), boat)
|
52
|
+
rd = IORudder.new(f)
|
42
53
|
|
43
|
-
|
44
|
-
|
45
|
-
|
54
|
+
case BayServer::harbor.log_multiplexer
|
55
|
+
when Harbor::MULTIPLEXER_TYPE_TAXI
|
56
|
+
mpx = agt.taxi_multiplexer
|
46
57
|
|
47
|
-
when
|
48
|
-
|
49
|
-
tp.init(agt.agent_id, File.open(file_name, "a"), boat)
|
58
|
+
when Harbor::MULTIPLEXER_TYPE_SPIN
|
59
|
+
mpx = agt.spin_multiplexer
|
50
60
|
|
51
|
-
|
61
|
+
when Harbor::MULTIPLEXER_TYPE_SPIDER
|
62
|
+
mpx = agt.spider_multiplexer
|
52
63
|
|
53
|
-
|
54
|
-
|
55
|
-
|
56
|
-
|
57
|
-
|
64
|
+
when Harbor::MULTIPLEXER_TYPE_JOB
|
65
|
+
mpx = agt.job_multiplexer
|
66
|
+
|
67
|
+
else
|
68
|
+
raise Sink.new
|
58
69
|
end
|
59
70
|
|
60
|
-
|
71
|
+
st = RudderState.new(rd)
|
72
|
+
st.bytes_wrote = size
|
73
|
+
mpx.add_rudder_state(rd, st)
|
74
|
+
|
75
|
+
@log_docker.multiplexers[agt_id] = mpx
|
76
|
+
@log_docker.rudders[agt_id] = rd
|
61
77
|
end
|
62
78
|
|
63
79
|
|
64
|
-
def remove(
|
65
|
-
@log_docker.
|
80
|
+
def remove(agt_id)
|
81
|
+
rd = @log_docker.rudders[agt_id]
|
82
|
+
@log_docker.multiplexers[agt_id].req_close(rd)
|
83
|
+
@log_docker.multiplexers[agt_id] = nil
|
84
|
+
@log_docker.rudders[agt_id] = nil
|
66
85
|
end
|
67
86
|
end
|
68
87
|
|
69
88
|
|
70
|
-
LOG_WRITE_METHOD_SELECT = 1
|
71
|
-
LOG_WRITE_METHOD_SPIN = 2
|
72
|
-
LOG_WRITE_METHOD_TAXI = 3
|
73
|
-
DEFAULT_LOG_WRITE_METHOD = LOG_WRITE_METHOD_TAXI
|
74
|
-
|
75
89
|
class << self
|
76
90
|
# Mapping table for format
|
77
91
|
attr :log_item_map
|
@@ -91,14 +105,17 @@ module Baykit
|
|
91
105
|
# Log items
|
92
106
|
attr :log_items
|
93
107
|
|
94
|
-
|
95
|
-
|
108
|
+
attr :rudders
|
109
|
+
|
110
|
+
# Multiplexer to write to file
|
111
|
+
attr :multiplexers
|
96
112
|
|
97
113
|
def initialize
|
98
114
|
@loggers = {}
|
99
115
|
@format = nil
|
100
116
|
@log_items = []
|
101
|
-
@
|
117
|
+
@rudders = {}
|
118
|
+
@multiplexers = {}
|
102
119
|
end
|
103
120
|
|
104
121
|
def init(elm, parent)
|
@@ -130,17 +147,6 @@ module Baykit
|
|
130
147
|
# Parse format
|
131
148
|
compile(@format, @log_items, elm.file_name, elm.line_no)
|
132
149
|
|
133
|
-
# Check log write method
|
134
|
-
if @log_write_method == LOG_WRITE_METHOD_SELECT and !SysUtil.support_select_file()
|
135
|
-
BayLog.warn(BayMessage.get(:CFG_LOG_WRITE_METHOD_SELECT_NOT_SUPPORTED))
|
136
|
-
@log_write_method = LOG_WRITE_METHOD_TAXI
|
137
|
-
end
|
138
|
-
|
139
|
-
if @log_write_method == LOG_WRITE_METHOD_SPIN and !SysUtil.support_nonblock_file_write()
|
140
|
-
BayLog.warn(BayMessage.get(:CFG_LOG_WRITE_METHOD_SPIN_NOT_SUPPORTED))
|
141
|
-
@log_write_method = LOG_WRITE_METHOD_TAXI
|
142
|
-
end
|
143
|
-
|
144
150
|
GrandAgent.add_lifecycle_listener(AgentListener.new(self));
|
145
151
|
end
|
146
152
|
|
@@ -148,17 +154,7 @@ module Baykit
|
|
148
154
|
case kv.key.downcase
|
149
155
|
when "format"
|
150
156
|
@format = kv.value
|
151
|
-
|
152
|
-
case kv.value.downcase()
|
153
|
-
when "select"
|
154
|
-
@log_write_method = LOG_WRITE_METHOD_SELECT
|
155
|
-
when "spin"
|
156
|
-
@log_write_method = LOG_WRITE_METHOD_SPIN
|
157
|
-
when "taxi"
|
158
|
-
@log_write_method = LOG_WRITE_METHOD_TAXI
|
159
|
-
else
|
160
|
-
raise ConfigException.new(kv.file_name, kv.line_no, BayMessage.get(:CFG_INVALID_PARAMETER_VALUE, kv.value))
|
161
|
-
end
|
157
|
+
|
162
158
|
else
|
163
159
|
return false
|
164
160
|
end
|
@@ -178,17 +174,18 @@ module Baykit
|
|
178
174
|
|
179
175
|
# If threre are message to write, write it
|
180
176
|
if sb.length > 0
|
181
|
-
|
177
|
+
@multiplexers[tour.ship.agent_id].req_write(
|
178
|
+
@rudders[tour.ship.agent_id],
|
179
|
+
sb,
|
180
|
+
nil,
|
181
|
+
"log",
|
182
|
+
nil
|
183
|
+
)
|
182
184
|
end
|
183
185
|
end
|
184
186
|
|
185
187
|
private
|
186
188
|
|
187
|
-
def get_logger(agt)
|
188
|
-
return @loggers[agt.agent_id]
|
189
|
-
end
|
190
|
-
|
191
|
-
|
192
189
|
|
193
190
|
#
|
194
191
|
# Compile format pattern
|
@@ -3,7 +3,7 @@ require 'ipaddr'
|
|
3
3
|
require 'baykit/bayserver/http_exception'
|
4
4
|
require 'baykit/bayserver/bcf/package'
|
5
5
|
require 'baykit/bayserver/docker/permission'
|
6
|
-
require 'baykit/bayserver/
|
6
|
+
require 'baykit/bayserver/common/groups'
|
7
7
|
require 'baykit/bayserver/util/headers'
|
8
8
|
require 'baykit/bayserver/util/http_status'
|
9
9
|
require 'baykit/bayserver/util/host_matcher'
|
@@ -20,6 +20,7 @@ module Baykit
|
|
20
20
|
include Baykit::BayServer
|
21
21
|
include Baykit::BayServer::Bcf
|
22
22
|
include Baykit::BayServer::Util
|
23
|
+
include Baykit::BayServer::Common
|
23
24
|
|
24
25
|
class CheckItem
|
25
26
|
attr :matcher
|
@@ -30,8 +31,8 @@ module Baykit
|
|
30
31
|
@admit = admit
|
31
32
|
end
|
32
33
|
|
33
|
-
def socket_admitted(
|
34
|
-
matcher.match_socket(
|
34
|
+
def socket_admitted(rd)
|
35
|
+
matcher.match_socket(rd) == @admit
|
35
36
|
end
|
36
37
|
|
37
38
|
def tour_admitted(tur)
|
@@ -41,12 +42,12 @@ module Baykit
|
|
41
42
|
|
42
43
|
module PermissionMatcher # interface
|
43
44
|
|
44
|
-
def match_socket(
|
45
|
-
raise NotImplementedError
|
45
|
+
def match_socket(rd)
|
46
|
+
raise NotImplementedError.new
|
46
47
|
end
|
47
48
|
|
48
49
|
def match_tour(tur)
|
49
|
-
raise NotImplementedError
|
50
|
+
raise NotImplementedError.new
|
50
51
|
end
|
51
52
|
end
|
52
53
|
|
@@ -61,8 +62,8 @@ module Baykit
|
|
61
62
|
@mch = HostMatcher.new(hostPtn)
|
62
63
|
end
|
63
64
|
|
64
|
-
def match_socket(
|
65
|
-
return @mch.match(
|
65
|
+
def match_socket(rd)
|
66
|
+
return @mch.match(rd.io.remote_address.getnameinfo[0])
|
66
67
|
end
|
67
68
|
|
68
69
|
def match_tour(tur)
|
@@ -80,8 +81,8 @@ module Baykit
|
|
80
81
|
@mch = IpMatcher.new(ip_desc)
|
81
82
|
end
|
82
83
|
|
83
|
-
def match_socket(
|
84
|
-
return @mch.match(
|
84
|
+
def match_socket(rd)
|
85
|
+
return @mch.match(rd.io.remote_address.ip_address)
|
85
86
|
end
|
86
87
|
|
87
88
|
def match_tour(tur)
|