Class GroupCommunicationProviderImpl
- java.lang.Object
-
- com.sun.enterprise.ee.cms.impl.base.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
-
-
Constructor Summary
Constructors Constructor Description GroupCommunicationProviderImpl(java.lang.String groupName)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description voidannounceClusterShutdown(com.sun.enterprise.ee.cms.spi.GMSMessage gmsMessage)voidannounceGroupStartup(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.voidannounceWatchdogObservedFailure(java.lang.String serverToken)implements Callable.voidassumeGroupLeadership()voidclusterViewEvent(ClusterViewEvent clusterViewEvent, ClusterView clusterView)Called when a cluster view event occurs.java.lang.StringgetGroupLeader()java.lang.ObjectgetLocalAddress()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 groupcom.sun.enterprise.ee.cms.spi.MemberStatesgetMemberState(java.lang.String memberIdentityToken)com.sun.enterprise.ee.cms.spi.MemberStatesgetMemberState(java.lang.String member, long threshold, long timeout)voidhandleClusterMessage(SystemAdvertisement adv, java.lang.Object message)Called when a message is received from another member.voidinitializeGroupCommunicationProvider(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.booleanisDiscoveryInProgress()booleanisGroupLeader()voidjoin()Joins the group using semantics specified by the underlying GCP systemvoidleave(boolean isClusterShutdown)Leaves the group as a result of a planned administrative action to shutdown.protected voidmonitorDoSend(com.sun.enterprise.ee.cms.spi.GMSMessage msg, long sendDuration, boolean sendSucceeded, java.lang.Exception e)voidreportJoinedAndReadyState()booleansendMessage(PeerID id, java.io.Serializable msg)voidsendMessage(java.io.Serializable message)voidsendMessage(java.lang.String targetMemberIdentityToken, java.io.Serializable message, boolean synchronous)Sends a message using the underlying group communication providers'(GCP's) APIs.voidsetGroupStoppingState()
-
-
-
Method Detail
-
clusterViewEvent
public void clusterViewEvent(ClusterViewEvent clusterViewEvent, ClusterView clusterView)
Description copied from interface:ClusterViewEventListenerCalled when a cluster view event occurs.- Specified by:
clusterViewEventin interfaceClusterViewEventListener- Parameters:
clusterViewEvent- The event that occurred.clusterView- the current membership snapshot after the event.
-
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.GMSExceptionInitializes 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:
initializeGroupCommunicationProviderin interfacecom.sun.enterprise.ee.cms.spi.GroupCommunicationProvider- Parameters:
memberName- member namegroupName- group nameidentityMap- valid configuration propertiesconfigProperties- 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:
joinin interfacecom.sun.enterprise.ee.cms.spi.GroupCommunicationProvider
-
announceClusterShutdown
public void announceClusterShutdown(com.sun.enterprise.ee.cms.spi.GMSMessage gmsMessage)
- Specified by:
announceClusterShutdownin interfacecom.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:
announceGroupStartupin interfacecom.sun.enterprise.ee.cms.spi.GroupCommunicationProvider- Parameters:
groupName- name of groupstartupState- INITATED, COMPLETED_SUCCESS or COMPLETED_FAILEDmemberTokens- 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:
leavein interfacecom.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.MemberNotInViewExceptionSends a message using the underlying group communication providers'(GCP's) APIs. Requires the users' message to be wrapped into a GMSMessage object.- Specified by:
sendMessagein interfacecom.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 expectioncom.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:
sendMessagein interfacecom.sun.enterprise.ee.cms.spi.GroupCommunicationProvider- Throws:
com.sun.enterprise.ee.cms.core.GMSExceptioncom.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:
getMembersin interfacecom.sun.enterprise.ee.cms.spi.GroupCommunicationProvider- Returns:
- list of current live members
-
isGroupLeader
public boolean isGroupLeader()
- Specified by:
isGroupLeaderin interfacecom.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:
getMemberStatein interfacecom.sun.enterprise.ee.cms.spi.GroupCommunicationProvider
-
getMemberState
public com.sun.enterprise.ee.cms.spi.MemberStates getMemberState(java.lang.String memberIdentityToken)
- Specified by:
getMemberStatein interfacecom.sun.enterprise.ee.cms.spi.GroupCommunicationProvider
-
getGroupLeader
public java.lang.String getGroupLeader()
- Specified by:
getGroupLeaderin interfacecom.sun.enterprise.ee.cms.spi.GroupCommunicationProvider
-
handleClusterMessage
public void handleClusterMessage(SystemAdvertisement adv, java.lang.Object message)
Description copied from interface:ClusterMessageListenerCalled when a message is received from another member.- Specified by:
handleClusterMessagein interfaceClusterMessageListener- Parameters:
adv- source system advertisementmessage- the message
-
assumeGroupLeadership
public void assumeGroupLeadership()
- Specified by:
assumeGroupLeadershipin interfacecom.sun.enterprise.ee.cms.spi.GroupCommunicationProvider
-
setGroupStoppingState
public void setGroupStoppingState()
- Specified by:
setGroupStoppingStatein interfacecom.sun.enterprise.ee.cms.spi.GroupCommunicationProvider
-
reportJoinedAndReadyState
public void reportJoinedAndReadyState()
- Specified by:
reportJoinedAndReadyStatein interfacecom.sun.enterprise.ee.cms.spi.GroupCommunicationProvider
-
announceWatchdogObservedFailure
public void announceWatchdogObservedFailure(java.lang.String serverToken) throws com.sun.enterprise.ee.cms.core.GMSExceptionimplements Callable. Used for handing off the job of calling sendMessage() method to a ThreadPool. REVISIT- Specified by:
announceWatchdogObservedFailurein interfacecom.sun.enterprise.ee.cms.spi.GroupCommunicationProvider- Throws:
com.sun.enterprise.ee.cms.core.GMSException
-
isDiscoveryInProgress
public boolean isDiscoveryInProgress()
- Specified by:
isDiscoveryInProgressin interfacecom.sun.enterprise.ee.cms.spi.GroupCommunicationProvider
-
-