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
@@ -1,81 +0,0 @@
1
- require 'openssl'
2
-
3
- require 'baykit/bayserver/agent/transporter/transporter'
4
- require 'baykit/bayserver/agent/next_socket_action'
5
-
6
- module Baykit
7
- module BayServer
8
- module Agent
9
- module Transporter
10
- class SecureTransporter < Transporter
11
- include OpenSSL
12
- include Baykit::BayServer::Protocol
13
-
14
- attr :sslctx
15
- attr :ssl_socket
16
-
17
- def initialize(sslctx, server_mode, bufsize, trace_ssl)
18
- super(server_mode, bufsize, trace_ssl)
19
- @sslctx = sslctx
20
- end
21
-
22
-
23
- def init(nb_hnd, sip, lis)
24
- super
25
- @ssl_socket = SSL::SSLSocket.new(@ch, @sslctx)
26
- @handshaked = false
27
- end
28
-
29
- def reset()
30
- super
31
- @ssl_socket = nil
32
- end
33
-
34
- def to_s()
35
- "stp[#{@data_listener}]"
36
- end
37
-
38
- ######################################################
39
- # Implements Transporter
40
- ######################################################
41
-
42
- def secure()
43
- return true
44
- end
45
-
46
- def handshake_nonblock()
47
- if @server_mode
48
- @ssl_socket.accept_nonblock()
49
- else
50
- @ssl_socket.connect_nonblock()
51
- end
52
-
53
-
54
- BayLog.debug("%s Handshake done", self)
55
- app_protocols = @ssl_socket.context.alpn_protocols
56
-
57
- # HELP ME
58
- # This code does not work!
59
- # We cannot get application protocol name
60
- proto = nil
61
- if app_protocols != nil && app_protocols.length > 0
62
- proto = app_protocols[0]
63
- end
64
- @data_listener.notify_handshake_done(proto)
65
- end
66
-
67
- def read_nonblock
68
- @ssl_socket.read_nonblock(@capacity, @read_buf)
69
- return nil # client address (for UDP)
70
- end
71
-
72
- def write_nonblock(buf, adr)
73
- @ssl_socket.write(buf)
74
- end
75
-
76
- end
77
- end
78
-
79
- end
80
- end
81
- end
@@ -1,42 +0,0 @@
1
- module Baykit
2
- module BayServer
3
- module Docker
4
- module Base
5
- module InboundHandler # interface
6
-
7
- #
8
- # Send protocol error
9
- # return true if connection must be closed
10
- #
11
- def send_req_protocol_error(protocol_ex)
12
- raise NotImplementedError()
13
- end
14
-
15
- #
16
- # Send HTTP headers to client
17
- #
18
- def send_res_headers(tur)
19
- raise NotImplementedError()
20
- end
21
-
22
- #
23
- # Send Contents to client
24
- #
25
- def send_res_content(tur, bytes, ofs, len, &callback)
26
- raise NotImplementedError()
27
- end
28
-
29
- #
30
- # Send end of contents to client.
31
- # sendEnd cannot refer Tour instance because it is discarded before call.
32
- #
33
- def send_end_tour(tur, keep_alive, &callback)
34
- raise NotImplementedError()
35
- end
36
-
37
- end
38
- end
39
- end
40
- end
41
- end
42
-
@@ -1,4 +0,0 @@
1
- require 'baykit/bayserver/docker/warp/warp_docker'
2
- require 'baykit/bayserver/docker/warp/warp_handler'
3
- require 'baykit/bayserver/docker/warp/warp_ship'
4
- require 'baykit/bayserver/docker/warp/warp_data'
@@ -1,112 +0,0 @@
1
- require 'baykit/bayserver/agent/next_socket_action'
2
- require 'baykit/bayserver/agent/transporter/data_listener'
3
- require 'baykit/bayserver/docker/warp/warp_ship'
4
- require 'baykit/bayserver/tours/tour'
5
- require 'baykit/bayserver/util/counter'
6
- require 'baykit/bayserver/util/http_status'
7
-
8
- module Baykit
9
- module BayServer
10
- module Docker
11
- module Warp
12
- class WarpDataListener
13
-
14
- include Baykit::BayServer::Agent::Transporter::DataListener # implements
15
-
16
- include Baykit::BayServer::Agent
17
- include Baykit::BayServer::Util
18
- include Baykit::BayServer::Tours
19
-
20
- attr :ship
21
-
22
- def initialize(sip)
23
- @ship = sip
24
- end
25
-
26
- def to_s()
27
- return @ship.to_s
28
- end
29
-
30
- ######################################################
31
- # Implements DataListener
32
- ######################################################
33
-
34
- def notify_handshake_done(protocol)
35
- @ship.protocol_handler.verify_protocol(protocol)
36
-
37
- # Send pending packet
38
- @ship.agent.non_blocking_handler.ask_to_write(@ship.socket)
39
- NextSocketAction::CONTINUE
40
- end
41
-
42
- def notify_connect
43
- @ship.connected = true
44
- @ship.tour_map.values.each do |pair|
45
- tur = pair[1]
46
- tur.check_tour_id pair[0]
47
- WarpData.get(tur).start
48
- end
49
- NextSocketAction::CONTINUE
50
- end
51
-
52
- def notify_read(buf, adr)
53
- return @ship.protocol_handler.bytes_received(buf)
54
- end
55
-
56
- def notify_eof
57
- BayLog.debug("%s EOF detected", self)
58
-
59
- if @ship.tour_map.empty?
60
- BayLog.debug("%s No warp tours. only close", self)
61
- return NextSocketAction::CLOSE
62
- end
63
-
64
- @ship.tour_map.keys.each do |warp_id|
65
- pair = @ship.tour_map[warp_id]
66
- tur = pair[1]
67
- tur.check_tour_id pair[0]
68
-
69
- begin
70
- if !tur.res.header_sent
71
- BayLog.debug("%s Send ServiceUnavailable: tur=%s", self, tur)
72
- tur.res.send_error(Tour::TOUR_ID_NOCHECK, HttpStatus::SERVICE_UNAVAILABLE, "Server closed on reading headers")
73
- else
74
- # NOT treat EOF as Error
75
- BayLog.debug("%s EOF is not an error: tur=%s", self, tur)
76
- tur.res.end_content(Tour::TOUR_ID_NOCHECK)
77
- end
78
- rescue IOError => e
79
- BayLog::debug_e(e)
80
- end
81
- end
82
-
83
- @ship.tour_map.clear()
84
- return NextSocketAction::CLOSE
85
- end
86
-
87
- def notify_protocol_error(err)
88
- BayLog.error_e(err)
89
- self.ship.notify_error_to_owner_tour(HttpStatus::SERVICE_UNAVAILABLE, err.message)
90
- true
91
- end
92
-
93
- def check_timeout(duration_sec)
94
- if @ship.is_timeout(duration_sec)
95
- self.ship.notify_error_to_owner_tour(HttpStatus::GATEWAY_TIMEOUT, "#{self} server timeout")
96
- true
97
- else
98
- false
99
- end
100
- end
101
-
102
- def notify_close()
103
- BayLog.debug("%s notifyClose", self)
104
- self.ship.notify_error_to_owner_tour(HttpStatus::SERVICE_UNAVAILABLE, "#{self} server closed")
105
- self.ship.end_ship()
106
- end
107
-
108
- end
109
- end
110
- end
111
- end
112
- end
@@ -1,38 +0,0 @@
1
- module Baykit
2
- module BayServer
3
- module Docker
4
- module Warp
5
- module WarpHandler # interface
6
-
7
- def next_warp_id()
8
- raise NotImplementedError()
9
- end
10
-
11
- def new_warp_data(warp_id)
12
- raise NotImplementedError()
13
- end
14
-
15
- def post_warp_headers(tur)
16
- raise NotImplementedError()
17
- end
18
-
19
- def post_warp_contents(tur, buf, start, len, &callback)
20
- raise NotImplementedError()
21
- end
22
-
23
- def post_warp_end(tur)
24
- raise NotImplementedError()
25
- end
26
-
27
- #
28
- # Verify if protocol is allowed
29
- #
30
- def verify_protocol(protocol)
31
- raise NotImplementedError()
32
- end
33
-
34
- end
35
- end
36
- end
37
- end
38
- end
File without changes