bayserver-core 2.2.2 → 2.3.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/command_receiver.rb +1 -1
- data/lib/baykit/bayserver/agent/grand_agent.rb +89 -76
- data/lib/baykit/bayserver/agent/grand_agent_monitor.rb +1 -0
- data/lib/baykit/bayserver/agent/lifecycle_listener.rb +16 -0
- data/lib/baykit/bayserver/agent/non_blocking_handler.rb +37 -8
- data/lib/baykit/bayserver/agent/signal/signal_sender.rb +1 -0
- data/lib/baykit/bayserver/agent/spin_handler.rb +16 -0
- data/lib/baykit/bayserver/agent/timer_handler.rb +15 -0
- data/lib/baykit/bayserver/docker/base/inbound_ship.rb +20 -51
- data/lib/baykit/bayserver/docker/base/inbound_ship_store.rb +2 -1
- data/lib/baykit/bayserver/docker/built_in/built_in_log_docker.rb +3 -2
- data/lib/baykit/bayserver/docker/built_in/write_file_taxi.rb +8 -2
- data/lib/baykit/bayserver/docker/warp/warp_data.rb +8 -0
- data/lib/baykit/bayserver/docker/warp/warp_data_listener.rb +9 -9
- data/lib/baykit/bayserver/docker/warp/warp_docker.rb +2 -1
- data/lib/baykit/bayserver/docker/warp/warp_ship.rb +32 -3
- data/lib/baykit/bayserver/mem_usage.rb +2 -1
- data/lib/baykit/bayserver/protocol/packet_store.rb +2 -1
- data/lib/baykit/bayserver/protocol/protocol_handler_store.rb +2 -1
- data/lib/baykit/bayserver/taxi/taxi.rb +1 -0
- data/lib/baykit/bayserver/taxi/taxi_runner.rb +94 -5
- data/lib/baykit/bayserver/tours/read_file_taxi.rb +46 -23
- data/lib/baykit/bayserver/tours/send_file_yacht.rb +5 -1
- data/lib/baykit/bayserver/tours/tour.rb +5 -6
- data/lib/baykit/bayserver/tours/tour_req.rb +28 -28
- data/lib/baykit/bayserver/tours/tour_res.rb +93 -31
- data/lib/baykit/bayserver/tours/tour_store.rb +2 -1
- data/lib/baykit/bayserver/util/executor_service.rb +27 -10
- data/lib/baykit/bayserver/version.rb +1 -1
- metadata +4 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 2f0a7628ec3be8f1d727392730648c785b8018968fb343dc20434549ae60abae
|
4
|
+
data.tar.gz: 0ef73388d47ef99c304a1b0aaaa951eec6d25222a5fbb0bd71e7f6aeb37edebd
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: cd9122b0cfaf0eae17477d39ec7fd9e323a7944210222a6182861a91a11087da69560d4e70bca2f25c14f76804af0e57ffbf09c3c5fd2f5337b80351e98a74d6
|
7
|
+
data.tar.gz: 32b56a60249f626736a1102681cabbc1dec4f7dca68ee8e156c5a42930a04b38c69ca77aeef8eedc979d3ca419b5371ccb12ee1d758675c1af1b3facda28f439
|
@@ -37,7 +37,7 @@ module Baykit
|
|
37
37
|
when GrandAgent::CMD_MEM_USAGE
|
38
38
|
@agent.print_usage()
|
39
39
|
when GrandAgent::CMD_SHUTDOWN
|
40
|
-
@agent.
|
40
|
+
@agent.req_shutdown()
|
41
41
|
@aborted = true
|
42
42
|
when GrandAgent::CMD_ABORT
|
43
43
|
IOUtil.write_int32(@communication_channel, GrandAgent::CMD_OK)
|
@@ -1,4 +1,5 @@
|
|
1
1
|
require 'socket'
|
2
|
+
require 'objspace'
|
2
3
|
|
3
4
|
require 'baykit/bayserver/sink'
|
4
5
|
require 'baykit/bayserver/agent/accept_handler'
|
@@ -23,15 +24,6 @@ module Baykit
|
|
23
24
|
include Baykit::BayServer::Agent::Signal
|
24
25
|
include Baykit::BayServer::Util
|
25
26
|
|
26
|
-
module GrandAgentLifecycleListener
|
27
|
-
#
|
28
|
-
# interface
|
29
|
-
#
|
30
|
-
# void add(int agentId);
|
31
|
-
# void remove(int agentId);
|
32
|
-
#
|
33
|
-
end
|
34
|
-
|
35
27
|
SELECT_TIMEOUT_SEC = 10
|
36
28
|
|
37
29
|
CMD_OK = 0
|
@@ -54,6 +46,7 @@ module Baykit
|
|
54
46
|
attr :unanchorable_transporters
|
55
47
|
attr :aborted
|
56
48
|
attr :command_receiver
|
49
|
+
attr :timer_handlers
|
57
50
|
|
58
51
|
class << self
|
59
52
|
attr :agents
|
@@ -83,6 +76,7 @@ module Baykit
|
|
83
76
|
@agent_id = agent_id
|
84
77
|
@anchorable = anchorable
|
85
78
|
|
79
|
+
@timer_handlers = []
|
86
80
|
if @anchorable
|
87
81
|
@accept_handler = AcceptHandler.new(self, GrandAgent.anchorable_port_map)
|
88
82
|
else
|
@@ -102,7 +96,7 @@ module Baykit
|
|
102
96
|
|
103
97
|
|
104
98
|
def to_s()
|
105
|
-
return "
|
99
|
+
return "agt#" + @agent_id.to_s
|
106
100
|
end
|
107
101
|
|
108
102
|
|
@@ -131,92 +125,90 @@ module Baykit
|
|
131
125
|
busy = true
|
132
126
|
begin
|
133
127
|
while not @aborted
|
134
|
-
|
135
|
-
|
136
|
-
|
137
|
-
|
138
|
-
|
139
|
-
|
140
|
-
|
141
|
-
|
142
|
-
|
143
|
-
|
144
|
-
|
145
|
-
end
|
128
|
+
|
129
|
+
count = -1
|
130
|
+
|
131
|
+
if @accept_handler
|
132
|
+
test_busy = @accept_handler.ch_count >= @max_inbound_ships
|
133
|
+
if test_busy != busy
|
134
|
+
busy = test_busy
|
135
|
+
if busy
|
136
|
+
@accept_handler.on_busy()
|
137
|
+
else
|
138
|
+
@accept_handler.on_free()
|
146
139
|
end
|
147
140
|
end
|
141
|
+
end
|
148
142
|
|
149
|
-
|
150
|
-
|
151
|
-
|
152
|
-
|
153
|
-
|
143
|
+
if !busy && @selector.count() == 2
|
144
|
+
# agent finished
|
145
|
+
BayLog.debug("%s Selector has no key", self)
|
146
|
+
break
|
147
|
+
end
|
154
148
|
|
155
|
-
|
156
|
-
|
157
|
-
|
158
|
-
|
159
|
-
|
149
|
+
if !@spin_handler.empty?
|
150
|
+
timeout = 0
|
151
|
+
else
|
152
|
+
timeout = @select_timeout_sec
|
153
|
+
end
|
160
154
|
|
161
|
-
|
162
|
-
|
163
|
-
|
155
|
+
if @aborted
|
156
|
+
BayLog.info("%s aborted by another thread", self)
|
157
|
+
break
|
158
|
+
end
|
159
|
+
#@BayServer.debug("Selecting... read=" + read_list.to_s)
|
160
|
+
selected_map = @selector.select(timeout)
|
161
|
+
#BayLog.debug("%s selected: %s", self, selected_map)
|
164
162
|
|
165
|
-
|
163
|
+
processed = @non_blocking_handler.register_channel_ops() > 0
|
166
164
|
|
167
|
-
|
168
|
-
|
169
|
-
|
170
|
-
|
165
|
+
if @aborted
|
166
|
+
BayLog.info("%s aborted by another thread", self)
|
167
|
+
break
|
168
|
+
end
|
171
169
|
|
172
|
-
|
173
|
-
|
174
|
-
|
175
|
-
|
176
|
-
elsif ch == @command_receiver.communication_channel
|
177
|
-
@command_receiver.on_pipe_readable()
|
178
|
-
elsif @accept_handler && @accept_handler.server_socket?(ch)
|
179
|
-
@accept_handler.on_acceptable(ch)
|
180
|
-
else
|
181
|
-
@non_blocking_handler.handle_channel(ch, selected_map[ch])
|
182
|
-
end
|
183
|
-
processed = true
|
184
|
-
end
|
170
|
+
if selected_map.length == 0
|
171
|
+
# No channel is selected
|
172
|
+
processed |= @spin_handler.process_data()
|
173
|
+
end
|
185
174
|
|
186
|
-
|
187
|
-
|
188
|
-
|
189
|
-
|
175
|
+
selected_map.keys().each do |ch|
|
176
|
+
if ch == @select_wakeup_pipe[0]
|
177
|
+
# Waked up by ask_to_*
|
178
|
+
on_waked_up(ch)
|
179
|
+
elsif ch == @command_receiver.communication_channel
|
180
|
+
@command_receiver.on_pipe_readable()
|
181
|
+
elsif @accept_handler && @accept_handler.server_socket?(ch)
|
182
|
+
@accept_handler.on_acceptable(ch)
|
183
|
+
else
|
184
|
+
@non_blocking_handler.handle_channel(ch, selected_map[ch])
|
190
185
|
end
|
186
|
+
processed = true
|
187
|
+
end
|
191
188
|
|
192
|
-
|
193
|
-
|
189
|
+
if not processed
|
190
|
+
# timeout check
|
191
|
+
@timer_handlers.each do |h|
|
192
|
+
h.on_timer()
|
193
|
+
end
|
194
194
|
end
|
195
|
+
|
195
196
|
end # while
|
196
197
|
|
197
198
|
rescue => e
|
198
|
-
BayLog.
|
199
|
-
raise e
|
199
|
+
BayLog.fatal(e)
|
200
200
|
ensure
|
201
201
|
BayLog.info("%s end", self)
|
202
|
-
|
202
|
+
shutdown()
|
203
203
|
end
|
204
204
|
end
|
205
205
|
|
206
206
|
def shutdown()
|
207
|
-
BayLog.
|
207
|
+
BayLog.info("%s shutdown", self)
|
208
|
+
|
208
209
|
if @accept_handler != nil
|
209
210
|
@accept_handler.shutdown()
|
210
211
|
end
|
211
|
-
@aborted = true
|
212
|
-
wakeup()
|
213
|
-
end
|
214
|
-
|
215
|
-
def abort_agent(err = nil, status = 1)
|
216
|
-
if err
|
217
|
-
BayLog.fatal("%s abort", self)
|
218
|
-
BayLog.fatal_e(err)
|
219
|
-
end
|
220
212
|
|
221
213
|
@command_receiver.end()
|
222
214
|
GrandAgent.listeners.each do |lis|
|
@@ -224,14 +216,20 @@ module Baykit
|
|
224
216
|
end
|
225
217
|
|
226
218
|
GrandAgent.agents.delete(@agent_id)
|
219
|
+
clean()
|
227
220
|
|
228
221
|
if BayServer.harbor.multi_core
|
229
222
|
exit(1)
|
230
|
-
else
|
231
|
-
clean()
|
232
223
|
end
|
224
|
+
end
|
233
225
|
|
226
|
+
def abort_agent()
|
227
|
+
BayLog.info("%s abort", self)
|
228
|
+
end
|
229
|
+
|
230
|
+
def req_shutdown()
|
234
231
|
@aborted = true
|
232
|
+
wakeup()
|
235
233
|
end
|
236
234
|
|
237
235
|
def reload_cert()
|
@@ -248,8 +246,15 @@ module Baykit
|
|
248
246
|
|
249
247
|
def print_usage()
|
250
248
|
# print memory usage
|
251
|
-
BayLog.info("
|
252
|
-
|
249
|
+
BayLog.info("%s MemUsage", self)
|
250
|
+
BayLog.info(" Ruby version: %s", RUBY_VERSION)
|
251
|
+
memsize = ObjectSpace.memsize_of_all
|
252
|
+
# formatted by comma
|
253
|
+
msize_comma = memsize.to_s.reverse.gsub(/(\d{3})(?=\d)/, '\\1,').reverse.then do |str|
|
254
|
+
str[0] == ',' ? str[1..-1] : str
|
255
|
+
end
|
256
|
+
BayLog.info(" Total object size: %s bytes", msize_comma)
|
257
|
+
MemUsage.get(@agent_id).print_usage(1)
|
253
258
|
end
|
254
259
|
|
255
260
|
def wakeup
|
@@ -261,6 +266,14 @@ module Baykit
|
|
261
266
|
@command_receiver = CommandReceiver.new(self, com_channel)
|
262
267
|
end
|
263
268
|
|
269
|
+
def add_timer_handler(handler)
|
270
|
+
@timer_handlers << handler
|
271
|
+
end
|
272
|
+
|
273
|
+
def remove_timer_handler(handler)
|
274
|
+
@timer_handlers.delete(handler)
|
275
|
+
end
|
276
|
+
|
264
277
|
private
|
265
278
|
def on_waked_up(pipe_fd)
|
266
279
|
#BayLog.debug("%s waked up", self)
|
@@ -11,6 +11,7 @@ module Baykit
|
|
11
11
|
# Sockets or file descriptors are kinds of channel
|
12
12
|
#
|
13
13
|
class NonBlockingHandler
|
14
|
+
include Baykit::BayServer::Agent::TimerHandler # implements
|
14
15
|
include Baykit::BayServer::Agent
|
15
16
|
include Baykit::BayServer::Util
|
16
17
|
|
@@ -78,6 +79,8 @@ module Baykit
|
|
78
79
|
@ch_count = 0
|
79
80
|
@operations = []
|
80
81
|
@operations_lock = Monitor.new()
|
82
|
+
|
83
|
+
@agent.add_timer_handler(self)
|
81
84
|
end
|
82
85
|
|
83
86
|
|
@@ -85,6 +88,18 @@ module Baykit
|
|
85
88
|
return @agent.to_s()
|
86
89
|
end
|
87
90
|
|
91
|
+
######################################################
|
92
|
+
# Implements TimerHandler
|
93
|
+
######################################################
|
94
|
+
|
95
|
+
def on_timer()
|
96
|
+
self.close_timeout_sockets()
|
97
|
+
end
|
98
|
+
|
99
|
+
######################################################
|
100
|
+
# Custom methods
|
101
|
+
######################################################
|
102
|
+
|
88
103
|
def handle_channel(ch, op)
|
89
104
|
|
90
105
|
ch_state = find_channel_state(ch)
|
@@ -106,8 +121,15 @@ module Baykit
|
|
106
121
|
next_action = ch_state.listener.on_connectable(ch)
|
107
122
|
if next_action == nil
|
108
123
|
raise Sink.new("unknown next action")
|
109
|
-
elsif next_action == NextSocketAction::
|
110
|
-
|
124
|
+
elsif next_action == NextSocketAction::READ
|
125
|
+
# "Write-OP Off"
|
126
|
+
op = @agent.selector.get_op(ch)
|
127
|
+
op = op & ~Selector::OP_WRITE
|
128
|
+
if op == 0
|
129
|
+
@agent.selector.unregister(ch)
|
130
|
+
else
|
131
|
+
@agent.selector.modify(ch, op)
|
132
|
+
end
|
111
133
|
end
|
112
134
|
|
113
135
|
else
|
@@ -253,9 +275,14 @@ module Baykit
|
|
253
275
|
now = DateTime.now
|
254
276
|
@ch_map.values.each do |ch_state|
|
255
277
|
if ch_state.listener != nil
|
256
|
-
|
257
|
-
|
258
|
-
|
278
|
+
begin
|
279
|
+
duration = ((now - ch_state.last_access_time) * 86400).to_i
|
280
|
+
if ch_state.listener.check_timeout(ch_state.channel, duration)
|
281
|
+
BayLog.debug("%s timeout: ch=%s", @agent, ch_state.channel)
|
282
|
+
close_list << ch_state
|
283
|
+
end
|
284
|
+
rescue IOError => e
|
285
|
+
BayLog.error_e(e)
|
259
286
|
close_list << ch_state
|
260
287
|
end
|
261
288
|
end
|
@@ -283,7 +310,7 @@ module Baykit
|
|
283
310
|
|
284
311
|
def ask_to_connect(ch, addr)
|
285
312
|
ch_state = find_channel_state(ch)
|
286
|
-
BayLog.debug("%s askToConnect addr=%s skt=%s chState=%s", @agent, addr, ch, ch_state)
|
313
|
+
BayLog.debug("%s askToConnect addr=%s skt=%s chState=%s", @agent, addr.ip_address, ch, ch_state)
|
287
314
|
|
288
315
|
begin
|
289
316
|
ch.connect_nonblock(addr)
|
@@ -292,7 +319,7 @@ module Baykit
|
|
292
319
|
end
|
293
320
|
|
294
321
|
ch_state.connecting = true
|
295
|
-
add_operation(ch, Selector::
|
322
|
+
add_operation(ch, Selector::OP_WRITE, true)
|
296
323
|
end
|
297
324
|
|
298
325
|
def ask_to_read(ch)
|
@@ -379,9 +406,12 @@ module Baykit
|
|
379
406
|
def close_channel(ch, ch_state)
|
380
407
|
BayLog.debug("%s Close chState=%s", @agent, ch_state)
|
381
408
|
|
409
|
+
ch.close()
|
410
|
+
|
382
411
|
if ch_state == nil
|
383
412
|
ch_state = find_channel_state(ch)
|
384
413
|
end
|
414
|
+
|
385
415
|
if ch_state.accepted and @agent.accept_handler
|
386
416
|
agent.accept_handler.on_closed
|
387
417
|
end
|
@@ -398,7 +428,6 @@ module Baykit
|
|
398
428
|
BayLog.warn_e(e)
|
399
429
|
end
|
400
430
|
|
401
|
-
ch.close()
|
402
431
|
end
|
403
432
|
|
404
433
|
def add_channel_state(ch, ch_state)
|
@@ -68,6 +68,7 @@ module Baykit
|
|
68
68
|
begin
|
69
69
|
a = Addrinfo.tcp(host, port)
|
70
70
|
s = Socket.new(a.ipv4? ? Socket::AF_INET : Socket::AF_INET6, Socket::SOCK_STREAM)
|
71
|
+
s.setsockopt(Socket::SOL_SOCKET, Socket::SO_RCVTIMEO, [60, 0].pack("l_2"))
|
71
72
|
s.connect(a)
|
72
73
|
s.write(cmd + "\n")
|
73
74
|
s.flush();
|
@@ -1,9 +1,12 @@
|
|
1
|
+
require 'baykit/bayserver/agent/timer_handler'
|
1
2
|
|
2
3
|
module Baykit
|
3
4
|
module BayServer
|
4
5
|
module Agent
|
5
6
|
class SpinHandler
|
6
7
|
|
8
|
+
include Baykit::BayServer::Agent::TimerHandler # implements
|
9
|
+
|
7
10
|
module SpinListener
|
8
11
|
#
|
9
12
|
# interface
|
@@ -35,12 +38,25 @@ module Baykit
|
|
35
38
|
@lock = Mutex.new
|
36
39
|
@agent = agt
|
37
40
|
@spin_count = 0
|
41
|
+
@agent.add_timer_handler(self)
|
38
42
|
end
|
39
43
|
|
40
44
|
def to_s()
|
41
45
|
return @agent.to_s()
|
42
46
|
end
|
43
47
|
|
48
|
+
######################################################
|
49
|
+
# Implements TimerHandler
|
50
|
+
######################################################
|
51
|
+
|
52
|
+
def on_timer()
|
53
|
+
stop_timeout_spins()
|
54
|
+
end
|
55
|
+
|
56
|
+
######################################################
|
57
|
+
# Custom methods
|
58
|
+
######################################################
|
59
|
+
#
|
44
60
|
def process_data()
|
45
61
|
if @listeners.empty?
|
46
62
|
return false
|
@@ -65,13 +65,13 @@ module Baykit
|
|
65
65
|
# Other methods
|
66
66
|
######################################################
|
67
67
|
|
68
|
-
def get_tour(tur_key)
|
68
|
+
def get_tour(tur_key, force=false, rent=true)
|
69
69
|
tur = nil
|
70
70
|
store_key = InboundShip.uniq_key(@ship_id, tur_key)
|
71
71
|
@lock.synchronize do
|
72
72
|
tur = @tour_store.get(store_key)
|
73
|
-
if tur == nil
|
74
|
-
tur = @tour_store.rent(store_key,
|
73
|
+
if tur == nil && rent
|
74
|
+
tur = @tour_store.rent(store_key, force)
|
75
75
|
if tur == nil
|
76
76
|
return nil
|
77
77
|
end
|
@@ -135,13 +135,7 @@ module Baykit
|
|
135
135
|
@port_docker.additional_headers.each do |nv|
|
136
136
|
tur.res.headers.add(nv[0], nv[1])
|
137
137
|
end
|
138
|
-
|
139
|
-
@protocol_handler.send_res_headers(tur)
|
140
|
-
rescue IOError => e
|
141
|
-
BayLog.debug_e(e, "%s abort: %s", tur, e)
|
142
|
-
tur.change_state(Tour::TOUR_ID_NOCHECK, Tour::TourState::ABORTED)
|
143
|
-
raise e
|
144
|
-
end
|
138
|
+
@protocol_handler.send_res_headers(tur)
|
145
139
|
end
|
146
140
|
end
|
147
141
|
|
@@ -163,28 +157,12 @@ module Baykit
|
|
163
157
|
|
164
158
|
check_ship_id(check_id)
|
165
159
|
|
166
|
-
if tur.zombie? || tur.aborted?
|
167
|
-
# Don't send peer any data
|
168
|
-
BayLog::debug("%s Aborted or zombie tour. do nothing: %s state=%s", self, tur, tur.state)
|
169
|
-
tur.change_state(Tour::TOUR_ID_NOCHECK, TourState::ENDED)
|
170
|
-
if callback != nil
|
171
|
-
callback.call()
|
172
|
-
end
|
173
|
-
return
|
174
|
-
end
|
175
|
-
|
176
160
|
max_len = @protocol_handler.max_res_packet_data_size();
|
177
161
|
if len > max_len
|
178
162
|
send_res_content(Ship::SHIP_ID_NOCHECK, tur, bytes, ofs, max_len)
|
179
163
|
send_res_content(Ship::SHIP_ID_NOCHECK, tur, bytes, ofs + max_len, len - max_len, &callback)
|
180
164
|
else
|
181
|
-
|
182
|
-
@protocol_handler.send_res_content(tur, bytes, ofs, len, &callback)
|
183
|
-
rescue IOError => e
|
184
|
-
BayLog.debug_e(e, "%s abort: %s", tur, e)
|
185
|
-
tur.change_state(Tour::TOUR_ID_NOCHECK, Tour::TourState::ABORTED)
|
186
|
-
raise e
|
187
|
-
end
|
165
|
+
@protocol_handler.send_res_content(tur, bytes, ofs, len, &callback)
|
188
166
|
end
|
189
167
|
end
|
190
168
|
|
@@ -193,34 +171,25 @@ module Baykit
|
|
193
171
|
check_ship_id(chk_ship_id)
|
194
172
|
BayLog.debug("%s sendEndTour: %s state=%s", self, tur, tur.state)
|
195
173
|
|
196
|
-
if tur.
|
197
|
-
|
198
|
-
|
199
|
-
|
200
|
-
|
201
|
-
|
202
|
-
if
|
203
|
-
|
174
|
+
if !tur.valid?
|
175
|
+
raise Sink.new("Tour is not valid")
|
176
|
+
end
|
177
|
+
keep_alive = false
|
178
|
+
if tur.req.headers.get_connection() == Headers::CONNECTION_KEEP_ALIVE
|
179
|
+
keep_alive = true
|
180
|
+
if keep_alive
|
181
|
+
res_conn = tur.res.headers.get_connection()
|
182
|
+
keep_alive = (res_conn == Headers::CONNECTION_KEEP_ALIVE) ||
|
183
|
+
(res_conn == Headers::CONNECTION_UNKOWN)
|
204
184
|
end
|
205
|
-
keep_alive
|
206
|
-
|
207
|
-
|
208
|
-
if keep_alive
|
209
|
-
res_conn = tur.res.headers.get_connection()
|
210
|
-
keep_alive = (res_conn == Headers::CONNECTION_KEEP_ALIVE) ||
|
211
|
-
(res_conn == Headers::CONNECTION_UNKOWN)
|
212
|
-
end
|
213
|
-
if keep_alive
|
214
|
-
if tur.res.headers.content_length() < 0
|
215
|
-
keep_alive = false
|
216
|
-
end
|
185
|
+
if keep_alive
|
186
|
+
if tur.res.headers.content_length() < 0
|
187
|
+
keep_alive = false
|
217
188
|
end
|
218
189
|
end
|
219
|
-
|
220
|
-
tur.change_state(Tour::TOUR_ID_NOCHECK, Tour::TourState::ENDED)
|
221
|
-
|
222
|
-
@protocol_handler.send_end_tour(tur, keep_alive, &callback)
|
223
190
|
end
|
191
|
+
|
192
|
+
@protocol_handler.send_end_tour(tur, keep_alive, &callback)
|
224
193
|
end
|
225
194
|
end
|
226
195
|
|
@@ -1,4 +1,5 @@
|
|
1
1
|
require 'baykit/bayserver/agent/grand_agent'
|
2
|
+
require 'baykit/bayserver/agent/lifecycle_listener'
|
2
3
|
|
3
4
|
require 'baykit/bayserver/docker/base/inbound_ship'
|
4
5
|
require 'baykit/bayserver/docker/base/inbound_ship_store'
|
@@ -16,7 +17,7 @@ module Baykit
|
|
16
17
|
include Baykit::BayServer::Agent
|
17
18
|
|
18
19
|
class AgentListener
|
19
|
-
include Baykit::BayServer::Agent::
|
20
|
+
include Baykit::BayServer::Agent::LifecycleListener # implements
|
20
21
|
|
21
22
|
def add(agt)
|
22
23
|
InboundShipStore.stores[agt.agent_id] = InboundShipStore.new();
|
@@ -1,4 +1,5 @@
|
|
1
1
|
require 'baykit/bayserver/agent/grand_agent'
|
2
|
+
require 'baykit/bayserver/agent/lifecycle_listener'
|
2
3
|
require 'baykit/bayserver/agent/transporter/plain_transporter'
|
3
4
|
require 'baykit/bayserver/agent/transporter/spin_write_transporter'
|
4
5
|
require 'baykit/bayserver/docker/built_in/write_file_taxi'
|
@@ -20,7 +21,7 @@ module Baykit
|
|
20
21
|
include Baykit::BayServer::Bcf
|
21
22
|
|
22
23
|
class AgentListener
|
23
|
-
include Baykit::BayServer::Agent::
|
24
|
+
include Baykit::BayServer::Agent::LifecycleListener # implements
|
24
25
|
include Baykit::BayServer::Agent::Transporter
|
25
26
|
|
26
27
|
attr :log_docker
|
@@ -45,7 +46,7 @@ module Baykit
|
|
45
46
|
|
46
47
|
when LOG_WRITE_METHOD_TAXI
|
47
48
|
tp = WriteFileTaxi.new()
|
48
|
-
tp.init(File.open(file_name, "a"), boat)
|
49
|
+
tp.init(agt.agent_id, File.open(file_name, "a"), boat)
|
49
50
|
|
50
51
|
end
|
51
52
|
|
@@ -19,6 +19,7 @@ module Baykit
|
|
19
19
|
attr :data_listener
|
20
20
|
attr :write_queue
|
21
21
|
attr :lock
|
22
|
+
attr :agent_id
|
22
23
|
|
23
24
|
def initialize()
|
24
25
|
super
|
@@ -26,7 +27,8 @@ module Baykit
|
|
26
27
|
@lock = Mutex.new()
|
27
28
|
end
|
28
29
|
|
29
|
-
def init(out, data_listener)
|
30
|
+
def init(agt_id, out, data_listener)
|
31
|
+
@agent_id = agt_id
|
30
32
|
@outfile = out
|
31
33
|
@data_listener = data_listener
|
32
34
|
@ch_valid = true
|
@@ -81,6 +83,10 @@ module Baykit
|
|
81
83
|
end
|
82
84
|
end
|
83
85
|
|
86
|
+
def on_timer()
|
87
|
+
|
88
|
+
end
|
89
|
+
|
84
90
|
def post(data, adr, tag)
|
85
91
|
@lock.synchronize do
|
86
92
|
empty = @write_queue.empty?
|
@@ -92,7 +98,7 @@ module Baykit
|
|
92
98
|
end
|
93
99
|
|
94
100
|
def next_run()
|
95
|
-
TaxiRunner.post(self)
|
101
|
+
TaxiRunner.post(@agent_id, self)
|
96
102
|
end
|
97
103
|
end
|
98
104
|
end
|