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.
Files changed (96) hide show
  1. checksums.yaml +4 -4
  2. data/lib/baykit/bayserver/agent/accept_handler.rb +0 -26
  3. data/lib/baykit/bayserver/agent/channel_listener.rb +6 -6
  4. data/lib/baykit/bayserver/agent/command_receiver.rb +97 -38
  5. data/lib/baykit/bayserver/agent/grand_agent.rb +444 -134
  6. data/lib/baykit/bayserver/agent/letter.rb +30 -0
  7. data/lib/baykit/bayserver/agent/lifecycle_listener.rb +9 -7
  8. data/lib/baykit/bayserver/agent/monitor/grand_agent_monitor.rb +298 -0
  9. data/lib/baykit/bayserver/agent/multiplexer/job_multiplexer.rb +257 -0
  10. data/lib/baykit/bayserver/agent/multiplexer/job_multiplexer_base.rb +52 -0
  11. data/lib/baykit/bayserver/agent/multiplexer/multiplexer_base.rb +150 -0
  12. data/lib/baykit/bayserver/agent/multiplexer/plain_transporter.rb +129 -0
  13. data/lib/baykit/bayserver/agent/multiplexer/rudder_state.rb +81 -0
  14. data/lib/baykit/bayserver/agent/multiplexer/secure_transporter.rb +50 -0
  15. data/lib/baykit/bayserver/agent/multiplexer/spider_multiplexer.rb +561 -0
  16. data/lib/baykit/bayserver/agent/multiplexer/spin_multiplexer.rb +311 -0
  17. data/lib/baykit/bayserver/agent/multiplexer/taxi_multiplexer.rb +194 -0
  18. data/lib/baykit/bayserver/agent/multiplexer/transporter.rb +61 -0
  19. data/lib/baykit/bayserver/agent/multiplexer/write_unit.rb +30 -0
  20. data/lib/baykit/bayserver/agent/non_blocking_handler.rb +0 -319
  21. data/lib/baykit/bayserver/agent/signal/signal_agent.rb +2 -1
  22. data/lib/baykit/bayserver/agent/timer_handler.rb +1 -1
  23. data/lib/baykit/bayserver/agent/transporter/data_listener.rb +7 -7
  24. data/lib/baykit/bayserver/agent/transporter/package.rb +0 -3
  25. data/lib/baykit/bayserver/agent/transporter/transporter.rb +5 -139
  26. data/lib/baykit/bayserver/bay_log.rb +1 -0
  27. data/lib/baykit/bayserver/bayserver.rb +32 -28
  28. data/lib/baykit/bayserver/{util → common}/groups.rb +1 -1
  29. data/lib/baykit/bayserver/common/inbound_handler.rb +12 -0
  30. data/lib/baykit/bayserver/{docker/base → common}/inbound_ship.rb +94 -19
  31. data/lib/baykit/bayserver/{docker/base → common}/inbound_ship_store.rb +7 -9
  32. data/lib/baykit/bayserver/common/multiplexer.rb +98 -0
  33. data/lib/baykit/bayserver/common/postpone.rb +15 -0
  34. data/lib/baykit/bayserver/common/read_only_ship.rb +42 -0
  35. data/lib/baykit/bayserver/common/recipient.rb +24 -0
  36. data/lib/baykit/bayserver/common/vehicle.rb +24 -0
  37. data/lib/baykit/bayserver/common/vehicle_runner.rb +127 -0
  38. data/lib/baykit/bayserver/{docker/warp → common}/warp_data.rb +18 -10
  39. data/lib/baykit/bayserver/common/warp_handler.rb +27 -0
  40. data/lib/baykit/bayserver/{docker/warp → common}/warp_ship.rb +107 -27
  41. data/lib/baykit/bayserver/{docker/warp → common}/warp_ship_store.rb +3 -8
  42. data/lib/baykit/bayserver/docker/base/inbound_data_listener.rb +2 -2
  43. data/lib/baykit/bayserver/docker/base/port_base.rb +59 -27
  44. data/lib/baykit/bayserver/docker/{warp/warp_docker.rb → base/warp_base.rb} +43 -50
  45. data/lib/baykit/bayserver/docker/built_in/built_in_harbor_docker.rb +118 -31
  46. data/lib/baykit/bayserver/docker/built_in/built_in_log_docker.rb +60 -63
  47. data/lib/baykit/bayserver/docker/built_in/built_in_permission_docker.rb +11 -10
  48. data/lib/baykit/bayserver/docker/built_in/built_in_secure_docker.rb +13 -4
  49. data/lib/baykit/bayserver/docker/city.rb +27 -13
  50. data/lib/baykit/bayserver/docker/club.rb +8 -8
  51. data/lib/baykit/bayserver/docker/docker.rb +9 -1
  52. data/lib/baykit/bayserver/docker/harbor.rb +184 -22
  53. data/lib/baykit/bayserver/docker/permission.rb +7 -6
  54. data/lib/baykit/bayserver/docker/port.rb +39 -11
  55. data/lib/baykit/bayserver/docker/secure.rb +11 -9
  56. data/lib/baykit/bayserver/docker/send_file/file_content_handler.rb +99 -4
  57. data/lib/baykit/bayserver/docker/send_file/send_file_docker.rb +6 -2
  58. data/lib/baykit/bayserver/docker/send_file/send_file_ship.rb +92 -0
  59. data/lib/baykit/bayserver/docker/town.rb +31 -15
  60. data/lib/baykit/bayserver/docker/trouble.rb +17 -5
  61. data/lib/baykit/bayserver/docker/warp.rb +34 -0
  62. data/lib/baykit/bayserver/mem_usage.rb +9 -9
  63. data/lib/baykit/bayserver/protocol/command_packer.rb +1 -8
  64. data/lib/baykit/bayserver/protocol/packet_packer.rb +7 -11
  65. data/lib/baykit/bayserver/protocol/packet_store.rb +4 -4
  66. data/lib/baykit/bayserver/protocol/protocol_handler.rb +26 -8
  67. data/lib/baykit/bayserver/protocol/protocol_handler_store.rb +5 -5
  68. data/lib/baykit/bayserver/rudders/io_rudder.rb +62 -0
  69. data/lib/baykit/bayserver/rudders/rudder.rb +29 -0
  70. data/lib/baykit/bayserver/{watercraft → ships}/ship.rb +65 -41
  71. data/lib/baykit/bayserver/taxi/taxi.rb +15 -10
  72. data/lib/baykit/bayserver/taxi/taxi_runner.rb +9 -94
  73. data/lib/baykit/bayserver/tours/read_file_taxi.rb +2 -2
  74. data/lib/baykit/bayserver/tours/req_content_handler.rb +16 -13
  75. data/lib/baykit/bayserver/tours/tour.rb +2 -2
  76. data/lib/baykit/bayserver/tours/tour_handler.rb +36 -0
  77. data/lib/baykit/bayserver/tours/tour_req.rb +14 -24
  78. data/lib/baykit/bayserver/tours/tour_res.rb +5 -89
  79. data/lib/baykit/bayserver/tours/tour_store.rb +5 -5
  80. data/lib/baykit/bayserver/train/train_runner.rb +17 -13
  81. data/lib/baykit/bayserver/util/data_consume_listener.rb +1 -1
  82. data/lib/baykit/bayserver/util/executor_service.rb +11 -7
  83. data/lib/baykit/bayserver/util/ip_matcher.rb +9 -39
  84. data/lib/baykit/bayserver/util/locale.rb +1 -1
  85. data/lib/baykit/bayserver/util/selector.rb +24 -5
  86. data/lib/baykit/bayserver/util/sys_util.rb +6 -6
  87. data/lib/baykit/bayserver/version.rb +1 -1
  88. metadata +37 -18
  89. data/lib/baykit/bayserver/agent/grand_agent_monitor.rb +0 -231
  90. data/lib/baykit/bayserver/agent/transporter/plain_transporter.rb +0 -55
  91. data/lib/baykit/bayserver/agent/transporter/secure_transporter.rb +0 -81
  92. data/lib/baykit/bayserver/docker/base/inbound_handler.rb +0 -42
  93. data/lib/baykit/bayserver/docker/warp/package.rb +0 -4
  94. data/lib/baykit/bayserver/docker/warp/warp_data_listener.rb +0 -112
  95. data/lib/baykit/bayserver/docker/warp/warp_handler.rb +0 -38
  96. /data/lib/baykit/bayserver/{util → common}/cities.rb +0 -0
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: ef1870c148ef4f045575bdd31e28b5e13808013fa159e0642a627471e0b80962
4
- data.tar.gz: 0247c5d8b92f4c9f1cf95b20ae02687202d524c6edd82158711bce98fa5e8e6e
3
+ metadata.gz: fbe7b085db08c0c14d26ea84e167218110e22e8907fd736aadefb15510141b39
4
+ data.tar.gz: 91cd0fcc14b62444677caf841fbefee54eec8037e27da5c9feee1cd7048e8071
5
5
  SHA512:
6
- metadata.gz: c3460ae4f7b5d50945fb20e5f6072838fe7277ccf6d6b9f0cd9d8e51e4ecd3c87a729121cc1d502edb8ddb120841e99377a63ba62324515a74de06d27fe769b6
7
- data.tar.gz: 22d1f706b151704256cf55526e8b4bc6d29a04c2ab543c9803cb32316719239140997390d7b88b500e1d248cc8281821e68666ba68f2abdddd247880a2dbc698
6
+ metadata.gz: fc5aa1296c8bc2b7f81ddc8cc9dad21f8ebb8c57024e72475a6ef1a0230fdcaf351135dad2c3e7bb05d687f71837e044a370ea5633738562a57e95b81eb46e95
7
+ data.tar.gz: 73d2bc985423266e152eebc168cae10978f292cc05e9c958787b393c6bc1b67995804400d62189ebbeec38faf4e3bfcca18a62b0de61355cbb44b149a2b56ec6
@@ -23,32 +23,6 @@ module Baykit
23
23
  end
24
24
 
25
25
  def on_acceptable(server_skt)
26
- port_dkr = @port_map[server_skt]
27
-
28
- begin
29
- client_skt, = server_skt.accept_nonblock
30
- rescue IO::WaitReadable
31
- # Maybe another agent get socket
32
- BayLog.debug("Accept failed (must wait readable)")
33
- return
34
- end
35
-
36
- BayLog.debug("Accepted: skt=%d", client_skt.fileno)
37
-
38
- begin
39
- port_dkr.check_admitted(client_skt)
40
- rescue => e
41
- BayLog.error_e(e)
42
- client_skt.close()
43
- return
44
- end
45
-
46
- client_skt.fcntl(Fcntl::F_SETFL, Fcntl::O_NONBLOCK)
47
-
48
- tp = port_dkr.new_transporter(@agent, client_skt)
49
- @agent.non_blocking_handler.ask_to_start(client_skt)
50
- @agent.non_blocking_handler.ask_to_read(client_skt)
51
- @ch_count += 1
52
26
  end
53
27
 
54
28
  def on_closed()
@@ -5,27 +5,27 @@ module Baykit
5
5
  module ChannelListener # interface
6
6
 
7
7
  def on_readable(chk_ch)
8
- raise NotImplementedError()
8
+ raise NotImplementedError.new
9
9
  end
10
10
 
11
11
  def on_writable(chk_ch)
12
- raise NotImplementedError()
12
+ raise NotImplementedError.new
13
13
  end
14
14
 
15
15
  def on_connectable(chk_ch)
16
- raise NotImplementedError()
16
+ raise NotImplementedError.new
17
17
  end
18
18
 
19
19
  def on_error(chk_ch, e)
20
- raise NotImplementedError()
20
+ raise NotImplementedError.new
21
21
  end
22
22
 
23
23
  def on_closed(chk_ch)
24
- raise NotImplementedError()
24
+ raise NotImplementedError.new
25
25
  end
26
26
 
27
27
  def check_timeout(chk_ch, duration)
28
- raise NotImplementedError()
28
+ raise NotImplementedError.new
29
29
  end
30
30
 
31
31
  end
@@ -1,5 +1,6 @@
1
1
 
2
-
2
+ require 'baykit/bayserver/agent/monitor/grand_agent_monitor'
3
+ require 'baykit/bayserver/ships/ship'
3
4
 
4
5
  module Baykit
5
6
  module BayServer
@@ -7,66 +8,124 @@ module Baykit
7
8
  #
8
9
  # CommandReceiver receives commands from GrandAgentMonitor
9
10
  #
10
- class CommandReceiver
11
+ class CommandReceiver < Baykit::BayServer::Ships::Ship
12
+
13
+ include Baykit::BayServer
14
+ include Baykit::BayServer::Agent::Monitor
11
15
  include Baykit::BayServer::Util
12
- attr :agent
13
- attr :communication_channel
14
- attr :aborted
15
-
16
- def initialize(agent, com_ch)
17
- @agent = agent
18
- @communication_channel = com_ch
19
- @aborted = false
16
+
17
+
18
+ def init(agt_id, rd, tp)
19
+ super
20
20
  end
21
21
 
22
22
  def to_s()
23
- return "ComReceiver##{@agent.agent_id}"
23
+ return "ComReceiver##{@agent_id}"
24
+ end
25
+
26
+ #########################################
27
+ # Implements Ship
28
+ #########################################
29
+ def notify_handshake_done(proto)
30
+ raise Sink.new
31
+ end
32
+
33
+ def notify_connect
34
+ raise Sink.new
35
+ end
36
+
37
+ def notify_read(buf)
38
+ BayLog.debug("%s notify_read", self)
39
+ cmd = GrandAgentMonitor.buffer_to_int(buf)
40
+ on_read_command(cmd)
41
+ return NextSocketAction::CONTINUE
42
+ end
43
+
44
+ def notify_eof
45
+ BayLog.debug("%s notify_eof", self)
46
+ return NextSocketAction::CLOSE
47
+ end
48
+
49
+ def notify_error(e)
50
+ BayLog.error_e(e)
51
+ end
52
+
53
+ def notify_protocol_error(e)
54
+ raise Sink.new
24
55
  end
25
56
 
26
- def on_pipe_readable()
27
- cmd = IOUtil.read_int32(@communication_channel)
28
- if cmd == nil
29
- BayLog.debug("%s pipe closed: %d", self, @communication_channel)
30
- @agent.abort_agent()
31
- else
32
- BayLog.debug("%s receive command %d pipe=%d", self, cmd, @communication_channel)
33
- begin
57
+ def notify_close
58
+ end
59
+
60
+ def check_timeout(duration_sec)
61
+ return false
62
+ end
63
+
64
+ #########################################
65
+ # Custom methods
66
+ #########################################
67
+ def on_read_command(cmd)
68
+ agt = GrandAgent.get(@agent_id)
69
+
70
+ BayLog.debug("%s receive command %d rd=%s", self, cmd, @rudder)
71
+ begin
72
+ if cmd == nil
73
+ BayLog.debug("%s pipe closed", self)
74
+ agt.abort_agent
75
+ else
34
76
  case cmd
35
77
  when GrandAgent::CMD_RELOAD_CERT
36
- @agent.reload_cert()
78
+ agt.reload_cert
37
79
  when GrandAgent::CMD_MEM_USAGE
38
- @agent.print_usage()
80
+ agt.print_usage
39
81
  when GrandAgent::CMD_SHUTDOWN
40
- @agent.req_shutdown()
41
- @aborted = true
82
+ agt.req_shutdown
42
83
  when GrandAgent::CMD_ABORT
43
- IOUtil.write_int32(@communication_channel, GrandAgent::CMD_OK)
44
- @agent.abort_agent()
84
+ send_command_to_monitor(agt, GrandAgent::CMD_OK, true)
85
+ agt.abort_agent
86
+ return
87
+ when GrandAgent::CMD_CATCHUP
88
+ agt.catch_up
45
89
  return
46
90
  else
47
91
  BayLog.error("Unknown command: %d", cmd)
48
92
  end
49
- IOUtil.write_int32(@communication_channel, GrandAgent::CMD_OK)
50
- rescue IOError => e
51
- BayLog.debug("%s Read failed (maybe agent shut down): %s", self, e)
52
- ensure
53
- BayLog.debug("%s Command ended", self)
93
+
94
+ send_command_to_monitor(agt, GrandAgent::CMD_OK, false)
54
95
  end
96
+ rescue IOError => e
97
+ BayLog.error_e(e, "%s Command thread aborted(end)", self)
98
+ close
99
+ ensure
100
+ BayLog.debug("%s Command ended", self)
55
101
  end
56
102
  end
57
103
 
58
- def end()
59
- BayLog.debug("%s end", self)
104
+ def send_command_to_monitor(agt, cmd, sync)
105
+ buf = GrandAgentMonitor.int_to_buffer(cmd)
106
+ if sync
107
+
108
+ end
109
+ end
110
+
111
+ def end
112
+ BayLog.debug("%s send end to monitor", self)
60
113
  begin
61
- IOUtil.write_int32(@communication_channel, GrandAgent::CMD_CLOSE)
62
- rescue => e
63
- BayLog.error_e(e, "%s Write error", @agent);
114
+ send_command_to_monitor(nil, GrandAgent::CMD_CLOSE, true)
115
+ rescue IOError => e
116
+ BayLog.error_e(e)
64
117
  end
65
- close()
118
+
119
+ close
66
120
  end
67
121
 
68
- def close()
69
- @communication_channel.close()
122
+ def close
123
+ if @closed
124
+ return
125
+ end
126
+
127
+ @rudder.close
128
+ @closed = true
70
129
  end
71
130
 
72
131
  end