Class: Baykit::BayServer::Agent::CommandReceiver
Overview
CommandReceiver receives commands from GrandAgentMonitor
Constant Summary
Constants inherited
from Ships::Ship
Ships::Ship::INVALID_SHIP_ID, Ships::Ship::SHIP_ID_NOCHECK
Instance Attribute Summary collapse
Attributes inherited from Ships::Ship
#agent_id, #initialized, #keeping, #object_id, #rudder, #ship_id, #transporter
Instance Method Summary
collapse
Methods inherited from Ships::Ship
#check_ship_id, #id, #initialize, #post_close, #reset, #resume_read
#reset
Instance Attribute Details
#closed ⇒ Object
Returns the value of attribute closed.
17
18
19
|
# File 'lib/baykit/bayserver/agent/command_receiver.rb', line 17
def closed
@closed
end
|
Instance Method Details
#check_timeout(duration_sec) ⇒ Object
62
63
64
|
# File 'lib/baykit/bayserver/agent/command_receiver.rb', line 62
def check_timeout(duration_sec)
return false
end
|
#close ⇒ Object
124
125
126
127
128
129
130
131
|
# File 'lib/baykit/bayserver/agent/command_receiver.rb', line 124
def close
if @closed
return
end
@rudder.close
@closed = true
end
|
#end ⇒ Object
113
114
115
116
117
118
119
120
121
122
|
# File 'lib/baykit/bayserver/agent/command_receiver.rb', line 113
def end
BayLog.debug("%s send end to monitor", self)
begin
send_command_to_monitor(nil, GrandAgent::CMD_CLOSE, true)
rescue IOError => e
BayLog.error_e(e)
end
close
end
|
#init(agt_id, rd, tp) ⇒ Object
19
20
21
22
|
# File 'lib/baykit/bayserver/agent/command_receiver.rb', line 19
def init(agt_id, rd, tp)
super
@closed = false
end
|
#notify_close ⇒ Object
59
60
|
# File 'lib/baykit/bayserver/agent/command_receiver.rb', line 59
def notify_close
end
|
#notify_connect ⇒ Object
35
36
37
|
# File 'lib/baykit/bayserver/agent/command_receiver.rb', line 35
def notify_connect
raise Sink.new
end
|
#notify_eof ⇒ Object
46
47
48
49
|
# File 'lib/baykit/bayserver/agent/command_receiver.rb', line 46
def notify_eof
BayLog.debug("%s notify_eof", self)
return NextSocketAction::CLOSE
end
|
#notify_error(e) ⇒ Object
51
52
53
|
# File 'lib/baykit/bayserver/agent/command_receiver.rb', line 51
def notify_error(e)
BayLog.error_e(e)
end
|
#notify_handshake_done(proto) ⇒ Object
31
32
33
|
# File 'lib/baykit/bayserver/agent/command_receiver.rb', line 31
def notify_handshake_done(proto)
raise Sink.new
end
|
#notify_protocol_error(e) ⇒ Object
55
56
57
|
# File 'lib/baykit/bayserver/agent/command_receiver.rb', line 55
def notify_protocol_error(e)
raise Sink.new
end
|
#notify_read(buf) ⇒ Object
39
40
41
42
43
44
|
# File 'lib/baykit/bayserver/agent/command_receiver.rb', line 39
def notify_read(buf)
BayLog.debug("%s notify_read", self)
cmd = GrandAgentMonitor.buffer_to_int(buf)
on_read_command(cmd)
return NextSocketAction::CONTINUE
end
|
#on_read_command(cmd) ⇒ Object
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
|
# File 'lib/baykit/bayserver/agent/command_receiver.rb', line 69
def on_read_command(cmd)
agt = GrandAgent.get(@agent_id)
BayLog.debug("%s receive command %d rd=%s", self, cmd, @rudder)
begin
if cmd == nil
BayLog.debug("%s pipe closed", self)
agt.abort_agent
else
case cmd
when GrandAgent::CMD_RELOAD_CERT
agt.reload_cert
when GrandAgent::CMD_MEM_USAGE
agt.print_usage
when GrandAgent::CMD_SHUTDOWN
agt.req_shutdown
when GrandAgent::CMD_ABORT
send_command_to_monitor(agt, GrandAgent::CMD_OK, true)
agt.abort_agent
return
when GrandAgent::CMD_CATCHUP
agt.catch_up
return
else
BayLog.error("Unknown command: %d", cmd)
end
send_command_to_monitor(agt, GrandAgent::CMD_OK, false)
end
rescue IOError => e
BayLog.error_e(e, "%s Command thread aborted(end)", self)
close
ensure
BayLog.debug("%s Command ended", self)
end
end
|
#send_command_to_monitor(agt, cmd, sync) ⇒ Object
106
107
108
109
110
111
|
# File 'lib/baykit/bayserver/agent/command_receiver.rb', line 106
def send_command_to_monitor(agt, cmd, sync)
buf = GrandAgentMonitor.int_to_buffer(cmd)
if sync
end
end
|
#to_s ⇒ Object
24
25
26
|
# File 'lib/baykit/bayserver/agent/command_receiver.rb', line 24
def to_s()
return "ComReceiver##{@agent_id}"
end
|