Class: DRbQS::Node::Connection
- Inherits:
-
Object
- Object
- DRbQS::Node::Connection
- Defined in:
- lib/drbqs/node/connection.rb
Overview
The class of connection to server.
Instance Attribute Summary collapse
-
#id ⇒ Object
readonly
Returns the value of attribute id.
-
#node_number ⇒ Object
readonly
Returns the value of attribute node_number.
Instance Method Summary collapse
- #get_finalization ⇒ Object
- #get_initialization ⇒ Object
-
#initialize(message, logger = DRbQS::Misc::LoggerDummy.new) ⇒ Connection
constructor
A new instance of Connection.
- #respond_signal ⇒ Object
- #send_node_error(error_message) ⇒ Object
Constructor Details
#initialize(message, logger = DRbQS::Misc::LoggerDummy.new) ⇒ Connection
Returns a new instance of Connection.
7 8 9 10 11 12 |
# File 'lib/drbqs/node/connection.rb', line 7 def initialize(, logger = DRbQS::Misc::LoggerDummy.new) @message = @logger = logger @node_number = nil @id = create_id_string end |
Instance Attribute Details
#id ⇒ Object (readonly)
Returns the value of attribute id.
5 6 7 |
# File 'lib/drbqs/node/connection.rb', line 5 def id @id end |
#node_number ⇒ Object (readonly)
Returns the value of attribute node_number.
5 6 7 |
# File 'lib/drbqs/node/connection.rb', line 5 def node_number @node_number end |
Instance Method Details
#get_finalization ⇒ Object
41 42 43 |
# File 'lib/drbqs/node/connection.rb', line 41 def get_finalization get_special_task(:finalize) end |
#get_initialization ⇒ Object
37 38 39 |
# File 'lib/drbqs/node/connection.rb', line 37 def get_initialization get_special_task(:initialize) end |
#respond_signal ⇒ Object
45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 |
# File 'lib/drbqs/node/connection.rb', line 45 def respond_signal begin node_id, sym = @message.take([@node_number, Symbol], 0) @logger.info("Get signal: #{sym.inspect}") case sym when :alive_p @message.write([:server, :alive, @node_number]) @logger.info("Send alive signal of node id #{@node_number}") when :exit, :finalize, :exit_after_task, :sleep, :wake return sym else raise "Get invalid signal: #{sym.inspect}" end rescue Rinda::RequestExpiredError end end |
#send_node_error(error_message) ⇒ Object
62 63 64 |
# File 'lib/drbqs/node/connection.rb', line 62 def send_node_error() @message.write([:server, :node_error, [@node_number, ]]) end |