Interface ClusteringAgent

  • All Superinterfaces:
    ParameterInclude
    All Known Implementing Classes:
    TribesClusteringAgent

    public interface ClusteringAgent
    extends ParameterInclude

    This is the main interface in the Axis2 clustering implementation. In order to plug-in a new clustering implementation, this interface has to be implemented.

    The initilization of a node in the cluster is handled here. It is also responsible for getting this node to join the cluster. This node should not process any Web services requests until it successfully joins the cluster. Generally, this node will also need to obtain the state information and/or configuration information from a neighboring node. This interface is also responsible for properly instantiating a StateManager & NodeManager. In the case of a static membership scheme, this members are read from the axis2.xml file and added to the ClusteringAgent.

    In the axis2.xml, the instance of this interface is specified using the "clustering" class attribute. e.g. <clustering class="org.apache.axis2.clustering.tribes.TribesClusterAgent"> specifies that the TribesClusterAgent class is the instance of this interface that needs to be used.

    There can also be several "parameter" elements, which are children of the "clustering" element in the axis2.xml file. Generally, these parameters will be specific to the ClusteringAgent implementation.

    • Method Detail

      • init

        void init()
           throws ClusteringFault
        Initialize this node, and join the cluster
        Throws:
        ClusteringFault - If an error occurs while initializing this node or joining the cluster
      • finalize

        void finalize()
        Do cleanup & leave the cluster
      • getStateManager

        StateManager getStateManager()
        Returns:
        The StateManager
      • getNodeManager

        NodeManager getNodeManager()
        Returns:
        The NodeManager
      • setStateManager

        void setStateManager​(StateManager stateManager)
        Set the StateManager corresponding to this ClusteringAgent. This is an optional attribute. We can have a cluster with no context replication, in which case the contextManager will be null. This value is set by the ClusterBuilder, by reading the "contextManager" element in the axis2.xml

        e.g.

        Parameters:
        stateManager - The StateManager instance
      • setNodeManager

        void setNodeManager​(NodeManager nodeManager)
        Set the NodeManager corresponding to this ClusteringAgent. This is an optional attribute. We can have a cluster with no configuration management, in which case the configurationManager will be null. This value is set by the ClusterBuilder, by reading the "configurationManager" element in the axis2.xml

        e.g.

        Parameters:
        nodeManager - The NodeManager instance
      • shutdown

        void shutdown()
               throws ClusteringFault
        Disconnect this node from the cluster. This node will no longer receive membership change notifications, state change messages or configuration change messages. The node will be " "standing alone" once it is shutdown. However, it has to continue to process Web service requests.
        Throws:
        ClusteringFault - If an error occurs while leaving the cluster
      • setConfigurationContext

        void setConfigurationContext​(ConfigurationContext configurationContext)
        Set the system's configuration context. This will be used by the clustering implementations to get information about the Axis2 environment and to correspond with the Axis2 environment
        Parameters:
        configurationContext - The configuration context
      • setMembers

        void setMembers​(List<Member> members)
        Set the static members of the cluster. This is used only with static group membership
        Parameters:
        members - Members to be added
      • getMembers

        List<Member> getMembers()
        Get the list of members in a static group
        Returns:
        The members if static group membership is used. If any other membership scheme is used, the values returned may not be valid
      • getAliveMemberCount

        int getAliveMemberCount()
        Get the number of members alive.
        Returns:
        the number of members alive.
      • addGroupManagementAgent

        void addGroupManagementAgent​(GroupManagementAgent agent,
                                     String applicationDomain)
        Set the load balance event handler which will be notified when load balance events occur. This will be valid only when this node is running in loadBalance mode
        Parameters:
        agent - The GroupManagementAgent to be added
        applicationDomain - The application domain which is handled by the GroupManagementAgent
      • addGroupManagementAgent

        void addGroupManagementAgent​(GroupManagementAgent agent,
                                     String applicationDomain,
                                     String applicationSubDomain)
        Add a GroupManagementAgent to an application domain + sub-domain
        Parameters:
        agent - The GroupManagementAgent to be added
        applicationDomain - The application domain which is handled by the GroupManagementAgent
        applicationSubDomain - The application sub-domain which is handled by the GroupManagementAgent
      • getGroupManagementAgent

        GroupManagementAgent getGroupManagementAgent​(String applicationDomain)
        Get the GroupManagementAgent which corresponds to the applicationDomain This will be valid only when this node is running in groupManagement
        Parameters:
        applicationDomain - The application domain to which the application nodes being load balanced belong to
        Returns:
        GroupManagementAgent which corresponds to the applicationDomain
      • getGroupManagementAgent

        GroupManagementAgent getGroupManagementAgent​(String applicationDomain,
                                                     String applicationSubDomain)
        Get the GroupManagementAgent which corresponds to the applicationDomain + sub-domain
        Parameters:
        applicationDomain - The application domain which is handled by the GroupManagementAgent
        applicationSubDomain - The application sub-domain which is handled by the GroupManagementAgent
        Returns:
        GroupManagementAgent which corresponds to the applicationDomain + sub-domain
      • getDomains

        Set<String> getDomains()
        Get all the domains that this ClusteringAgent belongs to
        Returns:
        the domains of this ClusteringAgent
      • isCoordinator

        boolean isCoordinator()
        Checks whether this member is the coordinator for the cluster
        Returns:
        true if this member is the coordinator, and false otherwise
      • sendMessage

        List<ClusteringCommand> sendMessage​(ClusteringMessage msg,
                                            boolean isRpcMessage)
                                     throws ClusteringFault
        Send a message to all members in this member's primary cluster
        Parameters:
        msg - The message to be sent
        isRpcMessage - Indicates whether the message has to be sent in RPC mode
        Returns:
        A list of responses if the message is sent in RPC mode
        Throws:
        ClusteringFault - If an error occurs while sending the message