Class: Pione::Agent::JobTerminator

Inherits:
TupleSpaceClient show all
Defined in:
lib/pione/agent/job-terminator.rb

Overview

JobTerminator is an agent that terminates the target agent when "terminate" command is received.

Constant Summary

Constants included from Log::MessageLog

Log::MessageLog::MESSAGE_QUEUE

Instance Attribute Summary

Attributes inherited from BasicAgent

#chain_threads

Instance Method Summary collapse

Methods inherited from TupleSpaceClient

#bye, #call_transition_method, #hello, #transit_to_init, #transit_to_terminate

Methods included from Log::MessageLog

#debug_message, #debug_message_begin, #debug_message_end, debug_mode, debug_mode=, debug_mode?, message, quiet_mode, quiet_mode=, quiet_mode?, #show, #user_message, #user_message_begin, #user_message_end

Methods included from TupleSpaceClientOperation

#base_location, #bye, #finalize, #hello, #notify_exception, #read, #take

Methods included from TupleSpace::TupleSpaceInterface

#process_log, #processing_error, #set_tuple_space, tuple_space_operation, #tuple_space_server, #with_process_log

Methods inherited from BasicAgent

agent_type, inherited, set_agent_type, #start, #start!, #states, #terminate, #terminated?, #transit, #wait_until, #wait_until_after, #wait_until_before, #wait_until_terminated

Methods included from StateTransitionSingletonMethod

#chain, #define_exception_handler, #define_transition, #exception_handler, #start, #transition_chain

Constructor Details

#initialize(tuple_space, &b) ⇒ JobTerminator

Returns a new instance of JobTerminator.



8
9
10
11
# File 'lib/pione/agent/job-terminator.rb', line 8

def initialize(tuple_space, &b)
  super(tuple_space)
  @action = b
end

Instance Method Details

#transit_to_fire(status) ⇒ Object



37
38
39
40
# File 'lib/pione/agent/job-terminator.rb', line 37

def transit_to_fire(status)
  Log::Debug.system("job terminator fires the action %s." % @action)
  @action.call(status)
end

#transit_to_waitObject

transition methods



28
29
30
31
32
33
34
35
# File 'lib/pione/agent/job-terminator.rb', line 28

def transit_to_wait
  tuple = read(TupleSpace::CommandTuple.new(name: "terminate"))
  status = System::Status.success
  unless tuple.args.empty?
    status = tuple.args.first
  end
  return status
end