Class: RSMP::Node
- Inherits:
-
Object
- Object
- RSMP::Node
- Includes:
- EventSource, Logging, Task
- Defined in:
- lib/rsmp/node/node.rb
Overview
Base class for sites and supervisors.
Direct Known Subclasses
Instance Attribute Summary collapse
-
#archive ⇒ Object
readonly
Returns the value of attribute archive.
-
#clock ⇒ Object
readonly
Returns the value of attribute clock.
-
#collector ⇒ Object
readonly
Returns the value of attribute collector.
-
#deferred ⇒ Object
readonly
Returns the value of attribute deferred.
-
#logger ⇒ Object
readonly
Returns the value of attribute logger.
-
#task ⇒ Object
readonly
Returns the value of attribute task.
Attributes included from EventSource
Instance Method Summary collapse
- #author ⇒ Object
- #check_required_settings(settings, required) ⇒ Object
- #clear_deferred ⇒ Object
- #defer(key, item = nil) ⇒ Object
- #do_deferred(key, item = nil) ⇒ Object
-
#initialize(options = {}) ⇒ Node
constructor
A new instance of Node.
- #inspect ⇒ Object
- #now ⇒ Object
- #process_deferred ⇒ Object
-
#stop_subtasks ⇒ Object
stop proxies, then call super.
Methods included from EventSource
#add_event_receiver, #initialize_event_source, #publish_event, #remove_event_receiver
Methods included from Task
#initialize_task, #restart, #run, #start, #stop, #stop_task, #task_status, #wait, #wait_for_condition, #wait_for_condition!, #wait_for_termination
Methods included from Logging
Constructor Details
#initialize(options = {}) ⇒ Node
10 11 12 13 14 15 16 17 |
# File 'lib/rsmp/node/node.rb', line 10 def initialize( = {}) initialize_logging initialize_task initialize_event_source @deferred = [] @clock = Clock.new @collect = [:collect] end |
Instance Attribute Details
#archive ⇒ Object (readonly)
Returns the value of attribute archive.
8 9 10 |
# File 'lib/rsmp/node/node.rb', line 8 def archive @archive end |
#clock ⇒ Object (readonly)
Returns the value of attribute clock.
8 9 10 |
# File 'lib/rsmp/node/node.rb', line 8 def clock @clock end |
#collector ⇒ Object (readonly)
Returns the value of attribute collector.
8 9 10 |
# File 'lib/rsmp/node/node.rb', line 8 def collector @collector end |
#deferred ⇒ Object (readonly)
Returns the value of attribute deferred.
8 9 10 |
# File 'lib/rsmp/node/node.rb', line 8 def deferred @deferred end |
#logger ⇒ Object (readonly)
Returns the value of attribute logger.
8 9 10 |
# File 'lib/rsmp/node/node.rb', line 8 def logger @logger end |
#task ⇒ Object (readonly)
Returns the value of attribute task.
8 9 10 |
# File 'lib/rsmp/node/node.rb', line 8 def task @task end |
Instance Method Details
#author ⇒ Object
60 61 62 |
# File 'lib/rsmp/node/node.rb', line 60 def site_id end |
#check_required_settings(settings, required) ⇒ Object
52 53 54 55 56 57 58 |
# File 'lib/rsmp/node/node.rb', line 52 def check_required_settings(settings, required) raise ArgumentError, 'Settings is empty' unless settings required.each do |setting| raise ArgumentError, "Missing setting: #{setting}" unless settings.include? setting.to_s end end |
#clear_deferred ⇒ Object
48 49 50 |
# File 'lib/rsmp/node/node.rb', line 48 def clear_deferred @deferred.clear end |
#defer(key, item = nil) ⇒ Object
34 35 36 |
# File 'lib/rsmp/node/node.rb', line 34 def defer(key, item = nil) @deferred << [key, item] end |
#do_deferred(key, item = nil) ⇒ Object
46 |
# File 'lib/rsmp/node/node.rb', line 46 def do_deferred(key, item = nil); end |
#inspect ⇒ Object
19 20 21 |
# File 'lib/rsmp/node/node.rb', line 19 def inspect "#<#{self.class.name}:#{object_id} id: #{site_id}}>" end |
#now ⇒ Object
23 24 25 |
# File 'lib/rsmp/node/node.rb', line 23 def now clock.now end |
#process_deferred ⇒ Object
38 39 40 41 42 43 44 |
# File 'lib/rsmp/node/node.rb', line 38 def process_deferred cloned = @deferred.clone # clone in case do_deferred restarts the current task @deferred.clear cloned.each do |pair| do_deferred pair.first, pair.last end end |
#stop_subtasks ⇒ Object
stop proxies, then call super
28 29 30 31 32 |
# File 'lib/rsmp/node/node.rb', line 28 def stop_subtasks @proxies.each(&:stop) @proxies.clear super end |