Module: Pione::Agent::TupleSpaceClientOperation

Included in:
TupleSpaceClient
Defined in:
lib/pione/agent/tuple-space-client.rb

Instance Method Summary collapse

Instance Method Details

#base_locationObject



32
33
34
# File 'lib/pione/agent/tuple-space-client.rb', line 32

def base_location
  read(TupleSpace::BaseLocationTuple.any).location
end

#byeObject

Send a bye message to the tuple space server.



18
19
20
21
22
# File 'lib/pione/agent/tuple-space-client.rb', line 18

def bye
  Util.ignore_exception do
    take!(TupleSpace::AgentTuple.new(agent_type: agent_type, uuid: uuid))
  end
end

#finalizeObject

Sends a bye message to the tuple space servers and terminate myself.



5
6
7
8
9
10
# File 'lib/pione/agent/tuple-space-client.rb', line 5

def finalize
  unless current_state == :terminated
    bye
    terminate
  end
end

#helloObject

Send a hello message to the tuple space server.



13
14
15
# File 'lib/pione/agent/tuple-space-client.rb', line 13

def hello
  write(TupleSpace::AgentTuple.new(agent_type: agent_type, uuid: uuid))
end

#notify_exception(e) ⇒ Object

Notify the agent happened a exception.



25
26
27
28
29
30
# File 'lib/pione/agent/tuple-space-client.rb', line 25

def notify_exception(e)
  # ignore exception because the exception caused tuple server is down...
  Util.ignore_exception do
    write(TupleSpace::ExceptionTuple.new(uuid, agent_type, e))
  end
end

#read(*args) ⇒ Object

Protected read.



44
45
46
47
48
# File 'lib/pione/agent/tuple-space-client.rb', line 44

def read(*args)
  tuple = super(*args, &method(:set_current_tuple_entry))
  set_current_tuple_entry(nil)
  return tuple
end

#take(*args) ⇒ Object

Protected take.



37
38
39
40
41
# File 'lib/pione/agent/tuple-space-client.rb', line 37

def take(*args)
  tuple = super(*args, &method(:set_current_tuple_entry))
  set_current_tuple_entry(nil)
  return tuple
end