Package jade.core.replication
Interface AgentReplicationHelper
-
- All Superinterfaces:
ServiceHelper
public interface AgentReplicationHelper extends ServiceHelper
Helper class that allows agents to exploit the features of the AGentReplicationService- See Also:
Agent.getHelper(String)
-
-
Nested Class Summary
Nested Classes Modifier and Type Interface Description static interfaceAgentReplicationHelper.ListenerThe interface to be implemented by a replicated agent for the master replica to be notified about replica addition/removal and master replica changes.
-
Field Summary
Fields Modifier and Type Field Description static intCOLD_REPLICATIONThe constant indicating that replicas of a virtual agent are treated as cold resources.static intHOT_REPLICATIONThe constant indicating that replicas of a virtual agent are treated as hot resources.static StringSERVICE_NAMEThe name of the AgentReplicationService that must be specified in the getHelper() method of the Agent class to retrieve the AgentReplicationHelper.static StringVIRTUAL_RECEIVERACL Message user defined parameter key specifying the local name of the virtual agent the message was sent to.
-
Method Summary
All Methods Instance Methods Abstract Methods Modifier and Type Method Description voidcreateReplica(String replicaName, Location where)Create a new replica of a previously defined virtual agent.AIDgetMasterAid()Returns the AID of the master replica agentMap<AID,Location>getReplicas()Returns a Map mapping all replicas to their LocationAIDgetVirtualAid()Returns the AID of the virtual agent previously defined by means of the makeVirtual() method or null if no virtual agent has been defined.voidinvokeReplicatedMethod(String methodName, Object[] arguments)Invoke a method on all other replicas.booleanisMaster()Returns true if this agent is the master replica.AIDmakeVirtual(String virtualName, int replicationMode)Define a virtual agent and sets the agent that invokes this method as its master replica.-
Methods inherited from interface jade.core.ServiceHelper
init
-
-
-
-
Field Detail
-
SERVICE_NAME
static final String SERVICE_NAME
The name of the AgentReplicationService that must be specified in the getHelper() method of the Agent class to retrieve the AgentReplicationHelper.- See Also:
- Constant Field Values
-
HOT_REPLICATION
static final int HOT_REPLICATION
The constant indicating that replicas of a virtual agent are treated as hot resources. That is messages directed to the virtual agent are delivered indifferently to one of the available replica- See Also:
- Constant Field Values
-
COLD_REPLICATION
static final int COLD_REPLICATION
The constant indicating that replicas of a virtual agent are treated as cold resources. That is messages directed to the virtual agent are always delivered to the master replica. Other replica(s) are only there for backup purposes- See Also:
- Constant Field Values
-
VIRTUAL_RECEIVER
static final String VIRTUAL_RECEIVER
ACL Message user defined parameter key specifying the local name of the virtual agent the message was sent to. This is automatically set by the AgentReplicationService when resolving a virtual agent receiver to one of its implementation replicas- See Also:
- Constant Field Values
-
-
Method Detail
-
makeVirtual
AID makeVirtual(String virtualName, int replicationMode) throws ServiceException
Define a virtual agent and sets the agent that invokes this method as its master replica.- Parameters:
virtualName- The name of the virtual agent.replicationMode- Indicates whether replicas of the defined virtual agent must be treated as hot or cold resources.- Returns:
- The AID of the newly defined virtual agent
- Throws:
ServiceException- If an error occurs
-
createReplica
void createReplica(String replicaName, Location where) throws ServiceException
Create a new replica of a previously defined virtual agent. Note that the actual replica creation process occurs asynchronously. The master replica invoking this method is notified about successful or unsuccessful replica creation by means of the replicaAdded() and replicaCreationFailed() methods of the Listener interface.- Parameters:
replicaName- The name of the new replica agentwhere- The location where the new replica agent must be cloned- Throws:
ServiceException- If the agent invoking this method did not define a virtual agent yet, it is not the master replica or an error occurs.
-
getVirtualAid
AID getVirtualAid()
Returns the AID of the virtual agent previously defined by means of the makeVirtual() method or null if no virtual agent has been defined.- Returns:
- The AID of the virtual agent previously defined by means of the makeVirtual() method or null if no virtual agent has been defined.
-
getMasterAid
AID getMasterAid()
Returns the AID of the master replica agent- Returns:
- The AID of the master replica agent
-
isMaster
boolean isMaster()
Returns true if this agent is the master replica. false Otherwise- Returns:
- true if this agent is the master replica. false Otherwise
-
getReplicas
Map<AID,Location> getReplicas()
Returns a Map mapping all replicas to their Location- Returns:
- a Map mapping all replicas to their Location
-
-