Class: Pione::Command::PioneTaskWorker
- Inherits:
-
BasicCommand
- Object
- BasicCommand
- Pione::Command::PioneTaskWorker
- Defined in:
- lib/pione/command/pione-task-worker.rb
Overview
This is a body for pione-task-worker command.
Instance Attribute Summary collapse
-
#agent ⇒ Object
readonly
instance methods.
-
#tuple_space_server ⇒ Object
readonly
Returns the value of attribute tuple_space_server.
Attributes inherited from BasicCommand
Class Method Summary collapse
-
.spawn(features, tuple_space_id) ⇒ Object
Create a new process of
pione-task-workercommand.
Instance Method Summary collapse
-
#execute_agent ⇒ Object
Start task worker activity and wait the termination.
-
#execute_job_terminator ⇒ Object
Start the job terminator.
-
#setup_agent ⇒ Object
Create a task worker agent.
-
#setup_base_location ⇒ Object
Setup base location.
-
#setup_job_terminator ⇒ Object
Create a job terminator and setup the action.
-
#setup_tuple_space ⇒ Object
Get tuple space from parent process and test the connection.
-
#terminate_agent ⇒ Object
Terminate task worker agent.
-
#terminate_job_terminator ⇒ Object
Terminate job terminator.
Methods inherited from BasicCommand
#abort, command_banner, command_front, command_name, #enter_phase, execute, #execution?, execution_phase, #exit, handle_exception, handle_execution_exception, handle_setup_exception, handle_termination_exception, inherited, init, #init?, init_phase, #initialize, option_parser_mode, #run, run, setup, #setup?, setup_phase, #terminate, terminate, #termination?, termination_phase
Constructor Details
This class inherits a constructor from Pione::Command::BasicCommand
Instance Attribute Details
#agent ⇒ Object (readonly)
instance methods
67 68 69 |
# File 'lib/pione/command/pione-task-worker.rb', line 67 def agent @agent end |
#tuple_space_server ⇒ Object (readonly)
Returns the value of attribute tuple_space_server.
68 69 70 |
# File 'lib/pione/command/pione-task-worker.rb', line 68 def tuple_space_server @tuple_space_server end |
Class Method Details
.spawn(features, tuple_space_id) ⇒ Object
Create a new process of pione-task-worker command.
42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 |
# File 'lib/pione/command/pione-task-worker.rb', line 42 def self.spawn(features, tuple_space_id) spawner = Spawner.new("pione-task-worker") # debug options spawner.option("--debug=system") if Global.debug_system spawner.option("--debug=ignored_exception") if Global.debug_ignored_exception spawner.option("--debug=rule_engine") if Global.debug_rule_engine spawner.option("--debug=communication") if Global.debug_communication spawner.option("--debug=presence_notification") if Global.debug_presence_notification # requisite options spawner.option("--parent-front", Global.front.uri) spawner.option("--tuple-space-id", tuple_space_id) spawner.option("--features", features) if features # optionals spawner.option("--color") if Global.color_enabled spawner.spawn # this method returns child front end |
Instance Method Details
#execute_agent ⇒ Object
Start task worker activity and wait the termination.
141 142 143 144 |
# File 'lib/pione/command/pione-task-worker.rb', line 141 def execute_agent @agent.start @agent.wait_until_terminated(nil) end |
#execute_job_terminator ⇒ Object
Start the job terminator.
136 137 138 |
# File 'lib/pione/command/pione-task-worker.rb', line 136 def execute_job_terminator @job_terminator.start end |
#setup_agent ⇒ Object
Create a task worker agent.
95 96 97 98 99 |
# File 'lib/pione/command/pione-task-worker.rb', line 95 def setup_agent @agent = Agent::TaskWorker.new(@tuple_space, Global.expressional_features) rescue Agent::TupleSpaceError => e abort(e.) end |
#setup_base_location ⇒ Object
Setup base location.
102 103 104 105 106 107 108 109 |
# File 'lib/pione/command/pione-task-worker.rb', line 102 def setup_base_location if @tuple_space.base_location.kind_of?(Location::DropboxLocation) Location::Dropbox.init(@tuple_space) unless Location::Dropbox.ready? abort("You aren't ready to access Dropbox.") end end end |
#setup_job_terminator ⇒ Object
Create a job terminator and setup the action.
112 113 114 115 116 117 118 119 120 |
# File 'lib/pione/command/pione-task-worker.rb', line 112 def setup_job_terminator @job_terminator = Agent::JobTerminator.new(@tuple_space) do |status| if status.error? abort("pione-task-worker catched the error: %s" % status.exception.) else terminate end end end |
#setup_tuple_space ⇒ Object
Get tuple space from parent process and test the connection.
82 83 84 85 86 87 88 89 90 91 92 |
# File 'lib/pione/command/pione-task-worker.rb', line 82 def setup_tuple_space @tuple_space = option[:parent_front].get_tuple_space(option[:tuple_space_id]) unless @tuple_space abort("%s cannot get tuple space \"%s\"." % [command_name, option[:tuple_space_id]]) end if Util.error?(:timeout => 3) {@tuple_space.uuid} abort("%s cannot connect to tuple space." % command_name) end end |
#terminate_agent ⇒ Object
Terminate task worker agent.
163 164 165 166 167 168 |
# File 'lib/pione/command/pione-task-worker.rb', line 163 def terminate_agent if @agent @agent.terminate @agent.wait_until_terminated(nil) end end |
#terminate_job_terminator ⇒ Object
Terminate job terminator.
156 157 158 159 160 |
# File 'lib/pione/command/pione-task-worker.rb', line 156 def terminate_job_terminator if @job_terminator and not(@job_terminator.terminated?) @job_terminator.terminate end end |