Class: Pione::Agent::TupleSpaceClient

Inherits:
BasicAgent
  • Object
show all
Includes:
TupleSpaceClientOperation, Log::MessageLog, TupleSpace::TupleSpaceInterface
Defined in:
lib/pione/agent/tuple-space-client.rb

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 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, #finalize, #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) ⇒ TupleSpaceClient

Initialize agent's state.



75
76
77
78
# File 'lib/pione/agent/tuple-space-client.rb', line 75

def initialize(tuple_space)
  super()
  set_tuple_space(tuple_space)
end

Instance Method Details

#byeObject

Redefine bye method with logging.



108
109
110
111
112
113
114
115
# File 'lib/pione/agent/tuple-space-client.rb', line 108

def bye
  record = Log::AgentConnectionProcessRecord.new.tap do |record|
    record.agent_type = agent_type
    record.agent_uuid = uuid
    record.message = "bye"
  end
  with_process_log(record) {super}
end

#call_transition_method(*args) ⇒ Object

Override call transition method with logging.



118
119
120
121
122
123
124
125
126
127
128
129
# File 'lib/pione/agent/tuple-space-client.rb', line 118

def call_transition_method(*args)
  unless [:logger, :job_terminator, :messenger].include?(agent_type)
    record = Log::AgentActivityProcessRecord.new.tap do |rec|
      rec.agent_type = agent_type
      rec.agent_uuid = uuid
      rec.state = args.first
    end
    with_process_log(record) {super}
  else
    super
  end
end

#helloObject

Redefine hello method with logging.



98
99
100
101
102
103
104
105
# File 'lib/pione/agent/tuple-space-client.rb', line 98

def hello
  record = Log::AgentConnectionProcessRecord.new.tap do |record|
    record.agent_type = agent_type
    record.agent_uuid = uuid
    record.message = "hello"
  end
  with_process_log(record) {super}
end

#transit_to_initObject

transitions



84
85
86
# File 'lib/pione/agent/tuple-space-client.rb', line 84

def transit_to_init
  hello
end

#transit_to_terminateObject



88
89
90
91
# File 'lib/pione/agent/tuple-space-client.rb', line 88

def transit_to_terminate
  Util.ignore_exception { bye }
  cancel_current_tuple_entry
end