Class GroupCommunicationProviderImpl

  • All Implemented Interfaces:
    com.sun.enterprise.ee.cms.spi.GroupCommunicationProvider, ClusterMessageListener, ClusterViewEventListener, java.util.EventListener

    public class GroupCommunicationProviderImpl
    extends java.lang.Object
    implements com.sun.enterprise.ee.cms.spi.GroupCommunicationProvider, ClusterViewEventListener, ClusterMessageListener
    Implements the GroupCommunicationProvider interface to plug in JxtaClusterManagement layer as a Group Communication Provider for GMS.
    Version:
    $Revision$
    Author:
    Shreedhar Ganapathy Date: Jun 26, 2006
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      void announceClusterShutdown​(com.sun.enterprise.ee.cms.spi.GMSMessage gmsMessage)  
      void announceGroupStartup​(java.lang.String groupName, com.sun.enterprise.ee.cms.core.GMSConstants.groupStartupState startupState, java.util.List<java.lang.String> memberTokens)
      Demarcate the INITIATION and COMPLETION of group startup.
      void announceWatchdogObservedFailure​(java.lang.String serverToken)
      implements Callable.
      void assumeGroupLeadership()  
      void clusterViewEvent​(ClusterViewEvent clusterViewEvent, ClusterView clusterView)
      Called when a cluster view event occurs.
      java.lang.String getGroupLeader()  
      java.lang.Object getLocalAddress()
      Returns the address representing the peer identified by this process.
      java.util.List<java.lang.String> getMembers()
      returns a list of members that are currently alive in the group
      com.sun.enterprise.ee.cms.spi.MemberStates getMemberState​(java.lang.String memberIdentityToken)  
      com.sun.enterprise.ee.cms.spi.MemberStates getMemberState​(java.lang.String member, long threshold, long timeout)  
      void handleClusterMessage​(SystemAdvertisement adv, java.lang.Object message)
      Called when a message is received from another member.
      void initializeGroupCommunicationProvider​(java.lang.String memberName, java.lang.String groupName, java.util.Map<java.lang.String,​java.lang.String> identityMap, java.util.Map configProperties)
      Initializes the Group Communication Service Provider with the requisite values of group identity, member(self) identity, and a Map containing recognized and valid configuration properties that can be set/overriden by the employing application.
      boolean isDiscoveryInProgress()  
      boolean isGroupLeader()  
      void join()
      Joins the group using semantics specified by the underlying GCP system
      void leave​(boolean isClusterShutdown)
      Leaves the group as a result of a planned administrative action to shutdown.
      protected void monitorDoSend​(com.sun.enterprise.ee.cms.spi.GMSMessage msg, long sendDuration, boolean sendSucceeded, java.lang.Exception e)  
      void reportJoinedAndReadyState()  
      boolean sendMessage​(PeerID id, java.io.Serializable msg)  
      void sendMessage​(java.io.Serializable message)  
      void sendMessage​(java.lang.String targetMemberIdentityToken, java.io.Serializable message, boolean synchronous)
      Sends a message using the underlying group communication providers'(GCP's) APIs.
      void setGroupStoppingState()  
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Constructor Detail

      • GroupCommunicationProviderImpl

        public GroupCommunicationProviderImpl​(java.lang.String groupName)
    • Method Detail

      • initializeGroupCommunicationProvider

        public void initializeGroupCommunicationProvider​(java.lang.String memberName,
                                                         java.lang.String groupName,
                                                         java.util.Map<java.lang.String,​java.lang.String> identityMap,
                                                         java.util.Map configProperties)
                                                  throws com.sun.enterprise.ee.cms.core.GMSException
        Initializes the Group Communication Service Provider with the requisite values of group identity, member(self) identity, and a Map containing recognized and valid configuration properties that can be set/overriden by the employing application. The valid property keys must be specified in a datastructure that is available to the implementation and to GMS.
        Specified by:
        initializeGroupCommunicationProvider in interface com.sun.enterprise.ee.cms.spi.GroupCommunicationProvider
        Parameters:
        memberName - member name
        groupName - group name
        identityMap - valid configuration properties
        configProperties - configuration properties
        Throws:
        com.sun.enterprise.ee.cms.core.GMSException
      • join

        public void join()
        Joins the group using semantics specified by the underlying GCP system
        Specified by:
        join in interface com.sun.enterprise.ee.cms.spi.GroupCommunicationProvider
      • announceClusterShutdown

        public void announceClusterShutdown​(com.sun.enterprise.ee.cms.spi.GMSMessage gmsMessage)
        Specified by:
        announceClusterShutdown in interface com.sun.enterprise.ee.cms.spi.GroupCommunicationProvider
      • announceGroupStartup

        public void announceGroupStartup​(java.lang.String groupName,
                                         com.sun.enterprise.ee.cms.core.GMSConstants.groupStartupState startupState,
                                         java.util.List<java.lang.String> memberTokens)
        Demarcate the INITIATION and COMPLETION of group startup. Only useful for an administration utility that statically knows of all members in group and starts them at same time. This API allows for an optimization by GMS clients to know whether GMS Join and JoinedAndReady events are happening as part of group startup or individual instance startups.
        Specified by:
        announceGroupStartup in interface com.sun.enterprise.ee.cms.spi.GroupCommunicationProvider
        Parameters:
        groupName - name of group
        startupState - INITATED, COMPLETED_SUCCESS or COMPLETED_FAILED
        memberTokens - static list of members associated with startupState. Failed members if state is COMPLETED_FAILED
      • leave

        public void leave​(boolean isClusterShutdown)
        Leaves the group as a result of a planned administrative action to shutdown.
        Specified by:
        leave in interface com.sun.enterprise.ee.cms.spi.GroupCommunicationProvider
      • sendMessage

        public boolean sendMessage​(PeerID id,
                                   java.io.Serializable msg)
      • sendMessage

        public void sendMessage​(java.lang.String targetMemberIdentityToken,
                                java.io.Serializable message,
                                boolean synchronous)
                         throws com.sun.enterprise.ee.cms.core.GMSException,
                                com.sun.enterprise.ee.cms.core.MemberNotInViewException
        Sends a message using the underlying group communication providers'(GCP's) APIs. Requires the users' message to be wrapped into a GMSMessage object.
        Specified by:
        sendMessage in interface com.sun.enterprise.ee.cms.spi.GroupCommunicationProvider
        Parameters:
        targetMemberIdentityToken - The member token string that identifies the target member to which this message is addressed. The implementation is expected to provide a mapping the member token to the GCP's addressing semantics. If null, the entire group would receive this message.
        message - a Serializable object that wraps the user specified message in order to allow remote GMS instances to unpack this message appropriately.
        synchronous - setting true here will call the underlying GCP's api that corresponds to a synchronous message, if available.
        Throws:
        com.sun.enterprise.ee.cms.core.GMSException - the GMS generic expection
        com.sun.enterprise.ee.cms.core.MemberNotInViewException
      • monitorDoSend

        protected void monitorDoSend​(com.sun.enterprise.ee.cms.spi.GMSMessage msg,
                                     long sendDuration,
                                     boolean sendSucceeded,
                                     java.lang.Exception e)
      • sendMessage

        public void sendMessage​(java.io.Serializable message)
                         throws com.sun.enterprise.ee.cms.core.GMSException,
                                com.sun.enterprise.ee.cms.core.MemberNotInViewException
        Specified by:
        sendMessage in interface com.sun.enterprise.ee.cms.spi.GroupCommunicationProvider
        Throws:
        com.sun.enterprise.ee.cms.core.GMSException
        com.sun.enterprise.ee.cms.core.MemberNotInViewException
      • getLocalAddress

        public java.lang.Object getLocalAddress()
        Returns the address representing the peer identified by this process. The address object is of the type corresponding to the underlying GCP. In this case, the jxta ID of this peer is returned.
        Returns:
        Object - representing this peer's address.
      • getMembers

        public java.util.List<java.lang.String> getMembers()
        returns a list of members that are currently alive in the group
        Specified by:
        getMembers in interface com.sun.enterprise.ee.cms.spi.GroupCommunicationProvider
        Returns:
        list of current live members
      • isGroupLeader

        public boolean isGroupLeader()
        Specified by:
        isGroupLeader in interface com.sun.enterprise.ee.cms.spi.GroupCommunicationProvider
      • getMemberState

        public com.sun.enterprise.ee.cms.spi.MemberStates getMemberState​(java.lang.String member,
                                                                         long threshold,
                                                                         long timeout)
        Specified by:
        getMemberState in interface com.sun.enterprise.ee.cms.spi.GroupCommunicationProvider
      • getMemberState

        public com.sun.enterprise.ee.cms.spi.MemberStates getMemberState​(java.lang.String memberIdentityToken)
        Specified by:
        getMemberState in interface com.sun.enterprise.ee.cms.spi.GroupCommunicationProvider
      • getGroupLeader

        public java.lang.String getGroupLeader()
        Specified by:
        getGroupLeader in interface com.sun.enterprise.ee.cms.spi.GroupCommunicationProvider
      • assumeGroupLeadership

        public void assumeGroupLeadership()
        Specified by:
        assumeGroupLeadership in interface com.sun.enterprise.ee.cms.spi.GroupCommunicationProvider
      • setGroupStoppingState

        public void setGroupStoppingState()
        Specified by:
        setGroupStoppingState in interface com.sun.enterprise.ee.cms.spi.GroupCommunicationProvider
      • reportJoinedAndReadyState

        public void reportJoinedAndReadyState()
        Specified by:
        reportJoinedAndReadyState in interface com.sun.enterprise.ee.cms.spi.GroupCommunicationProvider
      • announceWatchdogObservedFailure

        public void announceWatchdogObservedFailure​(java.lang.String serverToken)
                                             throws com.sun.enterprise.ee.cms.core.GMSException
        implements Callable. Used for handing off the job of calling sendMessage() method to a ThreadPool. REVISIT
        Specified by:
        announceWatchdogObservedFailure in interface com.sun.enterprise.ee.cms.spi.GroupCommunicationProvider
        Throws:
        com.sun.enterprise.ee.cms.core.GMSException
      • isDiscoveryInProgress

        public boolean isDiscoveryInProgress()
        Specified by:
        isDiscoveryInProgress in interface com.sun.enterprise.ee.cms.spi.GroupCommunicationProvider