com.sun.enterprise.ee.cms.impl.base
Class GroupCommunicationProviderImpl

java.lang.Object
  extended by com.sun.enterprise.ee.cms.impl.base.GroupCommunicationProviderImpl
All Implemented Interfaces:
GroupCommunicationProvider, ClusterMessageListener, ClusterViewEventListener, EventListener

public class GroupCommunicationProviderImpl
extends Object
implements GroupCommunicationProvider, ClusterViewEventListener, ClusterMessageListener

Implements the GroupCommunicationProvider interface to plug in JxtaClusterManagement layer as a Group Communication Provider for GMS.

Version:
$Revision: 1628 $
Author:
Shreedhar Ganapathy Date: Jun 26, 2006

Constructor Summary
GroupCommunicationProviderImpl(String groupName)
           
 
Method Summary
 void announceClusterShutdown(GMSMessage gmsMessage)
           
 void announceGroupStartup(String groupName, GMSConstants.groupStartupState startupState, List<String> memberTokens)
          Demarcate the INITIATION and COMPLETION of group startup.
 void announceWatchdogObservedFailure(String serverToken)
          implements Callable.
 void assumeGroupLeadership()
           
 void clusterViewEvent(ClusterViewEvent clusterViewEvent, ClusterView clusterView)
          Called when a cluster view event occurs.
 String getGroupLeader()
           
 Object getLocalAddress()
          Returns the address representing the peer identified by this process.
 List<String> getMembers()
          returns a list of members that are currently alive in the group
 MemberStates getMemberState(String memberIdentityToken)
           
 MemberStates getMemberState(String member, long threshold, long timeout)
           
 void handleClusterMessage(SystemAdvertisement adv, Object message)
          Called when a message is received from another member.
 void initializeGroupCommunicationProvider(String memberName, String groupName, Map<String,String> identityMap, 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(GMSMessage msg, long sendDuration, boolean sendSucceeded, Exception e)
           
 void reportJoinedAndReadyState()
           
 boolean sendMessage(PeerID id, Serializable msg)
           
 void sendMessage(Serializable message)
           
 void sendMessage(String targetMemberIdentityToken, 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(String groupName)
Method Detail

clusterViewEvent

public void clusterViewEvent(ClusterViewEvent clusterViewEvent,
                             ClusterView clusterView)
Description copied from interface: ClusterViewEventListener
Called when a cluster view event occurs.

Specified by:
clusterViewEvent in interface ClusterViewEventListener
Parameters:
clusterViewEvent - The event that occurred.
clusterView - the current membership snapshot after the event.

initializeGroupCommunicationProvider

public void initializeGroupCommunicationProvider(String memberName,
                                                 String groupName,
                                                 Map<String,String> identityMap,
                                                 Map configProperties)
                                          throws 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 GroupCommunicationProvider
Parameters:
memberName - member name
groupName - group name
identityMap - valid configuration properties
configProperties - configuration properties
Throws:
GMSException

join

public void join()
Joins the group using semantics specified by the underlying GCP system

Specified by:
join in interface GroupCommunicationProvider

announceClusterShutdown

public void announceClusterShutdown(GMSMessage gmsMessage)
Specified by:
announceClusterShutdown in interface GroupCommunicationProvider

announceGroupStartup

public void announceGroupStartup(String groupName,
                                 GMSConstants.groupStartupState startupState,
                                 List<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 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 GroupCommunicationProvider

sendMessage

public boolean sendMessage(PeerID id,
                           Serializable msg)

sendMessage

public void sendMessage(String targetMemberIdentityToken,
                        Serializable message,
                        boolean synchronous)
                 throws GMSException,
                        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 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:
GMSException
MemberNotInViewException

monitorDoSend

protected void monitorDoSend(GMSMessage msg,
                             long sendDuration,
                             boolean sendSucceeded,
                             Exception e)

sendMessage

public void sendMessage(Serializable message)
                 throws GMSException,
                        MemberNotInViewException
Specified by:
sendMessage in interface GroupCommunicationProvider
Throws:
GMSException
MemberNotInViewException

getLocalAddress

public 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 List<String> getMembers()
returns a list of members that are currently alive in the group

Specified by:
getMembers in interface GroupCommunicationProvider
Returns:
list of current live members

isGroupLeader

public boolean isGroupLeader()
Specified by:
isGroupLeader in interface GroupCommunicationProvider

getMemberState

public MemberStates getMemberState(String member,
                                   long threshold,
                                   long timeout)
Specified by:
getMemberState in interface GroupCommunicationProvider

getMemberState

public MemberStates getMemberState(String memberIdentityToken)
Specified by:
getMemberState in interface GroupCommunicationProvider

getGroupLeader

public String getGroupLeader()
Specified by:
getGroupLeader in interface GroupCommunicationProvider

handleClusterMessage

public void handleClusterMessage(SystemAdvertisement adv,
                                 Object message)
Description copied from interface: ClusterMessageListener
Called when a message is received from another member.

Specified by:
handleClusterMessage in interface ClusterMessageListener
Parameters:
adv - source system advertisement
message - the message

assumeGroupLeadership

public void assumeGroupLeadership()
Specified by:
assumeGroupLeadership in interface GroupCommunicationProvider

setGroupStoppingState

public void setGroupStoppingState()
Specified by:
setGroupStoppingState in interface GroupCommunicationProvider

reportJoinedAndReadyState

public void reportJoinedAndReadyState()
Specified by:
reportJoinedAndReadyState in interface GroupCommunicationProvider

announceWatchdogObservedFailure

public void announceWatchdogObservedFailure(String serverToken)
                                     throws GMSException
implements Callable. Used for handing off the job of calling sendMessage() method to a ThreadPool. REVISIT private class CallableMessageSend implements Callable { private PeerID member; private Serializable msg; private CallableMessageSend(final PeerID member) { this.member = member; } public void setMessage(Serializable msg) { this.msg = null; this.msg = msg; } public Object call() throws Exception { boolean sent = clusterManager.send(member, msg); if (!sent) { if (logger.isLoggable(Level.FINE)) { logger.fine("CallableMessageSend failed to send msg " + msg + " to member " + member); } } return null; } }

Specified by:
announceWatchdogObservedFailure in interface GroupCommunicationProvider
Throws:
GMSException

isDiscoveryInProgress

public boolean isDiscoveryInProgress()
Specified by:
isDiscoveryInProgress in interface GroupCommunicationProvider


Copyright © 2012. All Rights Reserved.