public class TwoPhInitiator extends FSMBehaviour
Modifier and Type | Field and Description |
---|---|
static java.lang.String |
PH0_STATE |
static java.lang.String |
PH1_STATE |
static java.lang.String |
PH2_STATE |
currentName, lastStates
Constructor and Description |
---|
TwoPhInitiator(Agent a,
ACLMessage cfp)
Constructs a
TwoPhInitiator behaviour. |
TwoPhInitiator(Agent a,
ACLMessage cfp,
DataStore ds)
Constructs a
TwoPhInitiator behaviour. |
Modifier and Type | Method and Description |
---|---|
java.lang.String |
getCurrentPhase() |
Behaviour |
getPhase(java.lang.String name) |
protected void |
handleAllPh0Responses(java.util.Vector responses,
java.util.Vector proposes,
java.util.Vector pendings,
java.util.Vector nextPhMsgs)
This method is called when all the responses of phase 0 have been collected or when
the timeout is expired.
|
protected void |
handleAllPh1Responses(java.util.Vector responses,
java.util.Vector confirms,
java.util.Vector disconfirms,
java.util.Vector informs,
java.util.Vector pendings,
java.util.Vector nextPhMsgs)
This method is called in phase 1 when all the responses have been collected or when
the timeout is expired.
|
protected void |
handleAllPh2Responses(java.util.Vector responses)
This method is called in phase 2 when all the responses have been collected.
|
protected void |
handleConfirm(ACLMessage confirm)
This method is called every time a
confirm message is received,
which is not out-of-sequence according to the protocol rules. |
protected void |
handleDisconfirm(ACLMessage disconfirm)
This method is called every time a
disconfirm message is received,
which is not out-of-sequence according to the protocol rules. |
protected void |
handleFailure(ACLMessage failure)
This method is called every time a
failure message is received,
which is not out-of-sequence according to the protocol rules. |
protected void |
handleNotUnderstood(ACLMessage notUnderstood) |
protected void |
handleOldResponse(ACLMessage old)
This method is called every time a
failure , a disconfirm
or an inform message is received in phase 2, which is not out-of-sequence
according to the protocol rules. |
protected void |
handleOutOfSequence(ACLMessage msg)
This method is called every time a message is received in phase n (use
getCurrentPhase method to know the phase), which is
out-of-sequence according to the protocol rules. |
protected void |
handlePh1Inform(ACLMessage inform)
This method is called every time an
inform message in phase 1
is received, which is not out-of-sequence according to the protocol rules. |
protected void |
handlePh2Inform(ACLMessage inform)
This method is called every time an
inform message in phase 2
is received, which is not out-of-sequence according to the protocol rules. |
protected void |
handlePropose(ACLMessage propose)
This method is called every time a
propose message is received,
which is not out-of-sequence according to the protocol rules. |
protected java.util.Vector |
prepareCfps(ACLMessage cfp)
This method must return the vector of ACLMessage objects to be sent.
|
checkTermination, deregisterDefaultTransition, deregisterState, deregisterTransition, forceTransitionTo, getChildren, getCurrent, getLastExitValue, getName, getPrevious, getState, handleInconsistentFSM, handleStateEntered, hasDefaultTransition, onEnd, registerDefaultTransition, registerDefaultTransition, registerFirstState, registerLastState, registerState, registerTransition, registerTransition, reset, resetStates, scheduleFirst, scheduleNext, stringifyTransitionTable
action, done, resetChildren, setAgent
block, block, getAgent, getBehaviourName, getDataStore, getParent, isRunnable, onStart, restart, root, setBehaviourName, setDataStore
public static final java.lang.String PH0_STATE
public static final java.lang.String PH1_STATE
public static final java.lang.String PH2_STATE
public TwoPhInitiator(Agent a, ACLMessage cfp)
TwoPhInitiator
behaviour.a
- The agent performing the protocol.cfp
- The message that must be used to initiate the protocol.
Notice that the default implementation of the prepareCfps
method
returns an array composed of that message only.public TwoPhInitiator(Agent a, ACLMessage cfp, DataStore ds)
TwoPhInitiator
behaviour.a
- The agent performing the protocol.cfp
- The message that must be used to initiate the protocol.
Notice that the default implementation of the prepareCfps
method
returns an array composed of that message only.ds
- DataStore
that will be used by this TwoPhInitiator
.protected java.util.Vector prepareCfps(ACLMessage cfp)
cfp
- the ACLMessage object passed in the constructorreply-with
and conversation-id
are ignored and regenerated automatically by this
class. Instead user can specify reply-by
slot representing phase0
timeout.protected void handlePropose(ACLMessage propose)
propose
message is received,
which is not out-of-sequence according to the protocol rules. This default
implementation does nothing; programmers might wish to override the method
in case they need to react to this event.propose
- the received propose messageprotected void handleFailure(ACLMessage failure)
failure
message is received,
which is not out-of-sequence according to the protocol rules. This default
implementation does nothing; programmers might wish to override the method
in case they need to react to this event.failure
- the received propose messageprotected void handleAllPh0Responses(java.util.Vector responses, java.util.Vector proposes, java.util.Vector pendings, java.util.Vector nextPhMsgs)
reply-By
of all the CFP messages sent.By response message we
intend here all the propose, failure, not-understood
received messages, which
are not out-of-sequence according to the protocol rules.
This default implementation does nothing; programmers might
wish to override this method to modify the Vector of initiation messages
(nextPhMsgs
) for next phase. More in details this Vector
already includes messages with the performative set according to the
default protocol rules i.e. QUERY_IF (if all responders replied with
PROPOSE) or REJECT_PROPOSAL (if at least one responder failed or didn't reply).
In particular, by setting the reply-by
slot, users can
specify a timeout for next phase.responses
- The Vector of all messages received as response in phase 0proposes
- The Vector of PROPOSE messages received as response in phase 0pendings
- The Vector of CFP messages for which a response has not
been received yet.nextPhMsgs
- The Vector of initiation messages for next phase already
filled with QUERY_IF
messages (if all responders replied with
PROPOSE
) or REJECT_PROPOSAL
(if at least one
responder failed or didn't reply).protected void handleConfirm(ACLMessage confirm)
confirm
message is received,
which is not out-of-sequence according to the protocol rules. This default
implementation does nothing; programmers might wish to override the method
in case they need to react to this event.confirm
- the received propose messageprotected void handleDisconfirm(ACLMessage disconfirm)
disconfirm
message is received,
which is not out-of-sequence according to the protocol rules. This default
implementation does nothing; programmers might wish to override the method
in case they need to react to this event.disconfirm
- the received propose messageprotected void handlePh1Inform(ACLMessage inform)
inform
message in phase 1
is received, which is not out-of-sequence according to the protocol rules.
This default implementation does nothing; programmers might wish to override
the method in case they need to react to this event.inform
- the received propose messageprotected void handleAllPh1Responses(java.util.Vector responses, java.util.Vector confirms, java.util.Vector disconfirms, java.util.Vector informs, java.util.Vector pendings, java.util.Vector nextPhMsgs)
reply-By
of all the sent messages. By response message we
intend here all the disconfirm, confirm, inform
received messages,
which are not out-of-sequence according to the protocol rules. This default
implementation does nothing; programmers might wish to override the method
in case they need to react to this event by analysing all the messages in
just one call.responses
- The Vector of all messages received as response in phase 1confirms
- all confirms receiveddisconfirms
- all disconfirms receivedpendings
- all queryIfs still pendingnextPhMsgs
- prepared responses for next phase: accept-proposal
or reject-proposal
protected void handlePh2Inform(ACLMessage inform)
inform
message in phase 2
is received, which is not out-of-sequence according to the protocol rules.
This default implementation does nothing; programmers might wish to override
the method in case they need to react to this event.inform
- the received propose messageprotected void handleOldResponse(ACLMessage old)
failure
, a disconfirm
or an inform
message is received in phase 2, which is not out-of-sequence
according to the protocol rules. This default implementation does nothing;
programmers might wish to override the method in case they need to react
to this event.old
- the received propose messageprotected void handleAllPh2Responses(java.util.Vector responses)
inform
(phase 2),
failure
(phase 0), disconfirm
(phase 1) and
inform
(phase 1) received messages, which are not out-of-sequence
according to the protocol rules. This default implementation does nothing;
programmers might wish to override the method in case they need to react to
this event by analysing all the messages in just one call.responses
- all responses received in phase 2protected void handleOutOfSequence(ACLMessage msg)
getCurrentPhase
method to know the phase), which is
out-of-sequence according to the protocol rules. This default implementation
does nothing; programmers might wish to override the method in case they need
to react to this event.msg
- the received messageprotected void handleNotUnderstood(ACLMessage notUnderstood)
public java.lang.String getCurrentPhase()
public Behaviour getPhase(java.lang.String name)