Class: DRbQS::Server::NodeList
- Inherits:
-
Object
- Object
- DRbQS::Server::NodeList
- Defined in:
- lib/drbqs/server/node_list.rb
Instance Attribute Summary collapse
-
#history ⇒ Object
readonly
Returns the value of attribute history.
-
#list ⇒ Object
readonly
Returns the value of attribute list.
Instance Method Summary collapse
- #add_to_preparation_to_exit(node_id) ⇒ Object
- #delete(id, history_state) ⇒ Object
- #delete_not_alive ⇒ Object
- #each(&block) ⇒ Object
- #empty? ⇒ Boolean
- #exist?(id) ⇒ Boolean
- #get_new_id(id_str) ⇒ Object
-
#initialize ⇒ NodeList
constructor
A new instance of NodeList.
- #prepare_to_exit?(node_id) ⇒ Boolean
- #set_alive(id) ⇒ Object
- #set_check_connection ⇒ Object
Constructor Details
Instance Attribute Details
#history ⇒ Object (readonly)
Returns the value of attribute history.
6 7 8 |
# File 'lib/drbqs/server/node_list.rb', line 6 def history @history end |
#list ⇒ Object (readonly)
Returns the value of attribute list.
6 7 8 |
# File 'lib/drbqs/server/node_list.rb', line 6 def list @list end |
Instance Method Details
#add_to_preparation_to_exit(node_id) ⇒ Object
62 63 64 65 66 67 |
# File 'lib/drbqs/server/node_list.rb', line 62 def add_to_preparation_to_exit(node_id) unless prepare_to_exit?(node_id) @history.set(node_id, :set_exitting) @prepare_to_exit << node_id end end |
#delete(id, history_state) ⇒ Object
31 32 33 34 35 |
# File 'lib/drbqs/server/node_list.rb', line 31 def delete(id, history_state) @list.delete(id) @prepare_to_exit.delete(id) @history.set(id, history_state) end |
#delete_not_alive ⇒ Object
37 38 39 40 41 42 43 44 |
# File 'lib/drbqs/server/node_list.rb', line 37 def delete_not_alive @check.each do |id| delete(id, :disconnect) end deleted = @check @check = [] deleted end |
#each(&block) ⇒ Object
23 24 25 |
# File 'lib/drbqs/server/node_list.rb', line 23 def each(&block) @list.each(&block) end |
#empty? ⇒ Boolean
50 51 52 |
# File 'lib/drbqs/server/node_list.rb', line 50 def empty? @list.size == 0 end |
#exist?(id) ⇒ Boolean
54 55 56 |
# File 'lib/drbqs/server/node_list.rb', line 54 def exist?(id) @list.find { |a| a[0] == id } end |
#get_new_id(id_str) ⇒ Object
16 17 18 19 20 21 |
# File 'lib/drbqs/server/node_list.rb', line 16 def get_new_id(id_str) @id += 1 @list[@id] = id_str @history.set(@id, :connect, @list[@id]) @id end |
#prepare_to_exit?(node_id) ⇒ Boolean
58 59 60 |
# File 'lib/drbqs/server/node_list.rb', line 58 def prepare_to_exit?(node_id) @prepare_to_exit.include?(node_id) end |
#set_alive(id) ⇒ Object
46 47 48 |
# File 'lib/drbqs/server/node_list.rb', line 46 def set_alive(id) @check.delete(id) end |
#set_check_connection ⇒ Object
27 28 29 |
# File 'lib/drbqs/server/node_list.rb', line 27 def set_check_connection @check = @list.keys end |