public class OperationHandler
extends java.lang.Object
Modifier and Type | Class and Description |
---|---|
class |
OperationHandler.Controller |
class |
OperationHandler.ControllerSession |
Modifier and Type | Field and Description |
---|---|
protected java.util.UUID |
agentUUID
UUID of the agent using this OperationHandler
|
protected java.util.Map<java.lang.String,OperationHandler.ControllerSession> |
controllerSessions
Active sessions toward different nodes
|
protected java.util.List<TucsonOpCompletionEvent> |
events
TuCSoN requests completion events (node replies events)
|
protected java.util.List<java.lang.Long> |
operationExpired
Expired TuCSoN operations
|
protected java.util.Map<java.lang.Long,TucsonOperation> |
operations
Requested TuCSoN operations
|
protected ACCDescription |
profile
Current ACC session description
|
Constructor and Description |
---|
OperationHandler(java.util.UUID uuid) |
Modifier and Type | Method and Description |
---|---|
void |
addOperation(java.lang.Long id,
TucsonOperation op) |
void |
addOperationExpired(long id)
Method to track expired operations, that is operations whose completion
has not been received before specified timeout expiration
|
ITucsonOperation |
doBlockingOperation(TucsonAgentId aid,
int type,
java.lang.Object tid,
Tuple t,
java.lang.Long ms)
Private method that takes in charge execution of all the Synchronous
primitives listed above.
|
ITucsonOperation |
doNonBlockingOperation(TucsonAgentId aid,
int type,
java.lang.Object tid,
Tuple t,
TucsonOperationCompletionListener l)
Private method that takes in charge execution of all the Asynchronous
primitives listed above.
|
protected ITucsonOperation |
doOperation(TucsonAgentId aid,
TucsonTupleCentreId tcid,
int type,
Tuple t,
TucsonOperationCompletionListener l)
This method is the real responsible of TuCSoN operations execution.
|
java.util.Map<java.lang.String,OperationHandler.ControllerSession> |
getControllerSessions() |
protected AbstractTucsonProtocol |
getSession(TucsonTupleCentreId tid,
TucsonAgentId aid)
This method is responsible to setup, store and retrieve connections
toward all the tuplecentres ever contacted by the TuCSoN Agent behind
this proxy.
|
protected void |
postEvent(TucsonOpCompletionEvent ev)
Method to add a TuCSoN Operation Completion Event
event to the
internal queue of pending completion event to process |
protected java.util.UUID agentUUID
protected java.util.Map<java.lang.String,OperationHandler.ControllerSession> controllerSessions
protected java.util.List<TucsonOpCompletionEvent> events
protected java.util.List<java.lang.Long> operationExpired
protected java.util.Map<java.lang.Long,TucsonOperation> operations
protected ACCDescription profile
public OperationHandler(java.util.UUID uuid)
uuid
- the Java UUID of the agent this handler serves.public void addOperation(java.lang.Long id, TucsonOperation op)
id
- the Long identifier of the pending operation just requestedop
- the TuCSoN operation waiting to be servedpublic void addOperationExpired(long id)
id
- Unique Identifier of the expired operationpublic ITucsonOperation doBlockingOperation(TucsonAgentId aid, int type, java.lang.Object tid, Tuple t, java.lang.Long ms) throws TucsonOperationNotPossibleException, UnreachableNodeException, OperationTimeOutException
doOperation doOp
(notice that in
truth there is no real execution at this point: we are just packing
primitives invocation into TuCSoN messages, then send them to the Node
side)
The difference w.r.t. the previous method
nonBlocking
is that here we explicitly wait for completion a time
specified in the timeout input parameter.aid
- the agent identifiertype
- TuCSoN operation type (internal integer code)tid
- Target TuCSoN tuplecentre id
tid
t
- The Logic Tuple involved in the requested operationms
- Maximum waiting time tolerated by the callee TuCSoN AgentTucsonOperationNotPossibleException
- if the operation requested cannot be performedUnreachableNodeException
- if the target tuple centre cannot be reached over the networkOperationTimeOutException
- if the timeout associated to the operation requested expires
prior to operation completionTucsonTupleCentreId
public ITucsonOperation doNonBlockingOperation(TucsonAgentId aid, int type, java.lang.Object tid, Tuple t, TucsonOperationCompletionListener l) throws TucsonOperationNotPossibleException, UnreachableNodeException
doOperation doOp
(notice that in
truth there is no real execution at this point: we are just packing
primitives invocation into TuCSoN messages, then send them to the Node
side)aid
- the agent identifiertype
- TuCSoN operation type (internal integer code)tid
- Target TuCSoN tuplecentre id
tid
t
- The Logic Tuple involved in the requested operationl
- The listener who should be notified upon operation completionTucsonOperationNotPossibleException
- if the operation requested cannot be performedUnreachableNodeException
- if the target tuple centre cannot be reached over the networkTucsonTupleCentreId
,
TucsonOperationCompletionListener
,
ITucsonOperation
public java.util.Map<java.lang.String,OperationHandler.ControllerSession> getControllerSessions()
protected ITucsonOperation doOperation(TucsonAgentId aid, TucsonTupleCentreId tcid, int type, Tuple t, TucsonOperationCompletionListener l) throws UnreachableNodeException
getSession
.
Then, a Tucson Operation op
storing any useful information about the TuCSoN primitive invocation is
created and packed into a Tucson Message Request
TucsonMsgRequest
to be possibly sent over
the wire toward the target tuplecentre.
Notice that a listener is needed, who is the proxy itself, wichever was
the requested operation (inp, in, etc.) and despite its (a-)synchronous
behavior. This is because of the distributed very nature of TuCSoN: we
couldn't expect to block on a socket waiting for a reply. Instead,
requested operations should be dispatched toward the TuCSoN Node Service,
which in turn will take them in charge and notify the requestor upon
completion.aid
- the agent identifiertcid
- Target TuCSoN tuplecentre id
tid
type
- TuCSoN operation type (internal integer code)t
- The Logic Tuple involved in the requested operationl
- The listener who should be notified upon operation completionUnreachableNodeException
- if the target tuple centre cannot be reached over the networkTucsonTupleCentreId
,
TucsonOperationCompletionListener
,
ITucsonOperation
,
TucsonOperation
protected AbstractTucsonProtocol getSession(TucsonTupleCentreId tid, TucsonAgentId aid) throws UnreachableNodeException
nodeProxy
tid
- Target TuCSoN tuplecentre id
tid
aid
- the agent identifierUnreachableNodeException
- if the target tuple centre cannot be reached over the networkTucsonProtocol
,
ACCProxyNodeSide
protected void postEvent(TucsonOpCompletionEvent ev)
event
to the
internal queue of pending completion event to processev
- Completion Event to be added to pending queueTucsonOpCompletionEvent