Interface AgentReplicationHelper

    • Nested Class Summary

      Nested Classes 
      Modifier and Type Interface Description
      static interface  AgentReplicationHelper.Listener
      The 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 int COLD_REPLICATION
      The constant indicating that replicas of a virtual agent are treated as cold resources.
      static int HOT_REPLICATION
      The constant indicating that replicas of a virtual agent are treated as hot resources.
      static String SERVICE_NAME
      The name of the AgentReplicationService that must be specified in the getHelper() method of the Agent class to retrieve the AgentReplicationHelper.
      static String VIRTUAL_RECEIVER
      ACL Message user defined parameter key specifying the local name of the virtual agent the message was sent to.
    • 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 agent
        where - 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
      • invokeReplicatedMethod

        void invokeReplicatedMethod​(String methodName,
                                    Object[] arguments)
        Invoke a method on all other replicas. This method should not be invoked directly. AgentReplicationHanlde.replicate() should be used instead.