Package com.sun.enterprise.mgmt
Class ClusterManager
- java.lang.Object
-
- com.sun.enterprise.mgmt.ClusterManager
-
- All Implemented Interfaces:
MessageListener,java.util.EventListener
public class ClusterManager extends java.lang.Object implements MessageListener
The ClusterManager is the entry point for using the cluster management module which provides group communications and membership semantics on top of JXTA, Grizzly and others.
-
-
Constructor Summary
Constructors Constructor Description ClusterManager(java.lang.String groupName, java.lang.String instanceName, java.util.Map<java.lang.String,java.lang.String> identityMap, java.util.Map props, java.util.List<ClusterViewEventListener> viewListeners, java.util.List<ClusterMessageListener> messageListeners)The ClusterManager is created using the instanceName, and a Properties object that contains a set of parameters that the employing application would like to set for its purposes, namely, configuration parameters such as failure detection timeout, retries, address and port on which to communicate with the group, group and instance IDs,etc.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description voidaddClusteMessageListener(ClusterMessageListener listener)ClusterViewManagergetClusterViewManager()Returns the ClusterViewManager object.java.lang.StringgetGroupName()HealthMonitorgetHealthMonitor()Returns the HealthMonitor instance.PeerIDgetID(java.lang.String name)Returns name encoded IDjava.lang.StringgetInstanceName()Gets the instance namecom.sun.enterprise.mgmt.MasterNodegetMasterNode()Returns the MasterNode instanceNetworkManagergetNetworkManager()NetworkManagergetNetworkManager(java.lang.String transport)Returns the NetworkManager instancejava.lang.StringgetNodeState(PeerID peerID, long threshold, long timeout)PeerIDgetPeerID()SystemAdvertisementgetSystemAdvertisement()Gets the systemAdvertisement attribute of the JXTAPlatform objectSystemAdvertisementgetSystemAdvertisementForMember(PeerID id)intgetType()Returns the message type whichMessageis supporting i.g.voidgroupStartup(com.sun.enterprise.ee.cms.core.GMSConstants.groupStartupState startupState, java.util.List<java.lang.String> memberTokens)booleanisDiscoveryInProgress()booleanisGroupStartup()booleanisMaster()booleanisWatchdog()voidnotifyNewMaster()voidreceiveMessageEvent(MessageEvent event)Processing aMessageEventvoidremoveClusterViewEventListener(ClusterMessageListener listener)voidreportJoinedAndReadyState()booleansend(PeerID peerid, java.io.Serializable msg)booleansend(PeerID peerid, java.io.Serializable msg, boolean validatePeeridInView)Send a message to a specific node or the group.voidsetClusterStopping()voidstart()Starts the ClusterManager and all it's servicesvoidstop(boolean isClusterShutdown)Stops the ClusterManager and all it's servicesvoidtakeOverMasterRole()voidwaitFor(long msec)
-
-
-
Constructor Detail
-
ClusterManager
public ClusterManager(java.lang.String groupName, java.lang.String instanceName, java.util.Map<java.lang.String,java.lang.String> identityMap, java.util.Map props, java.util.List<ClusterViewEventListener> viewListeners, java.util.List<ClusterMessageListener> messageListeners) throws com.sun.enterprise.ee.cms.core.GMSExceptionThe ClusterManager is created using the instanceName, and a Properties object that contains a set of parameters that the employing application would like to set for its purposes, namely, configuration parameters such as failure detection timeout, retries, address and port on which to communicate with the group, group and instance IDs,etc. The set of allowed constants to be used as keys in the Properties object are specified in JxtaConfigConstants enum.- Parameters:
groupName- Name of Group to which this process/peer seeks membershipinstanceName- A token identifying this instance/processidentityMap- Additional identity tokens can be specified through this Map object. These become a part of the SystemAdvertisement allowing the peer/system to be identified by the application layer based on their own notion of identityprops- a Properties object containing parameters that are allowed to be specified by employing application //TODO: specify that INFRA IDs and address/port are composite keys in essence but addresses/ports could be shared across ids with a performance penalty. //TODO: provide an API to send messages, synchronously or asynchronouslyviewListeners- listeners interested in group view change eventsmessageListeners- listeners interested in receiving messages.- Throws:
com.sun.enterprise.ee.cms.core.GMSException- Generic exception for handling errors
-
-
Method Detail
-
isWatchdog
public boolean isWatchdog()
-
addClusteMessageListener
public void addClusteMessageListener(ClusterMessageListener listener)
-
removeClusterViewEventListener
public void removeClusterViewEventListener(ClusterMessageListener listener)
-
stop
public void stop(boolean isClusterShutdown)
Stops the ClusterManager and all it's services- Parameters:
isClusterShutdown- true if this peer is shutting down as part of cluster wide shutdown
-
start
public void start()
Starts the ClusterManager and all it's services
-
getNetworkManager
public NetworkManager getNetworkManager(java.lang.String transport)
Returns the NetworkManager instance- Parameters:
transport- The type of transport- Returns:
- The networkManager value
-
getNetworkManager
public NetworkManager getNetworkManager()
-
getMasterNode
public com.sun.enterprise.mgmt.MasterNode getMasterNode()
Returns the MasterNode instance- Returns:
- The masterNode value
-
getHealthMonitor
public HealthMonitor getHealthMonitor()
Returns the HealthMonitor instance.- Returns:
- The healthMonitor value
-
getClusterViewManager
public ClusterViewManager getClusterViewManager()
Returns the ClusterViewManager object. All modules use this common object which represents a synchronized view of a set of AppServers- Returns:
- The clusterViewManager object
-
getPeerID
public PeerID getPeerID()
-
getInstanceName
public java.lang.String getInstanceName()
Gets the instance name- Returns:
- The instance name
-
isMaster
public boolean isMaster()
-
send
public boolean send(PeerID peerid, java.io.Serializable msg, boolean validatePeeridInView) throws java.io.IOException, com.sun.enterprise.ee.cms.core.MemberNotInViewException
Send a message to a specific node or the group. In the case where the id is null the message is sent to the entire group- Parameters:
peerid- the node IDmsg- the message to sendvalidatePeeridInView- the flag to validate the peer id- Returns:
- boolean
trueif the message has been sent otherwisefalse.false. is commonly returned for non-error related congestion, meaning that you should be able to send the message after waiting some amount of time. - Throws:
java.io.IOException- if an io error occurscom.sun.enterprise.ee.cms.core.MemberNotInViewException- if the peer id is not in view
-
send
public boolean send(PeerID peerid, java.io.Serializable msg) throws java.io.IOException, com.sun.enterprise.ee.cms.core.MemberNotInViewException
- Throws:
java.io.IOExceptioncom.sun.enterprise.ee.cms.core.MemberNotInViewException
-
receiveMessageEvent
public void receiveMessageEvent(MessageEvent event) throws MessageIOException
Processing aMessageEvent- Specified by:
receiveMessageEventin interfaceMessageListener- Parameters:
event- a received message event- Throws:
MessageIOException- if I/O error occurs
-
getType
public int getType()
Description copied from interface:MessageListenerReturns the message type whichMessageis supporting i.g.Message.TYPE_CLUSTER_MANAGER_MESSAGEorMessage.TYPE_HEALTH_MONITOR_MESSAGE's integer value or etc...- Specified by:
getTypein interfaceMessageListener- Returns:
- the message type about which this listener is concerned
-
getSystemAdvertisementForMember
public SystemAdvertisement getSystemAdvertisementForMember(PeerID id)
-
getSystemAdvertisement
public SystemAdvertisement getSystemAdvertisement()
Gets the systemAdvertisement attribute of the JXTAPlatform object- Returns:
- The systemAdvertisement value
-
getNodeState
public java.lang.String getNodeState(PeerID peerID, long threshold, long timeout)
-
getID
public PeerID getID(java.lang.String name)
Returns name encoded ID- Parameters:
name- to name to encode- Returns:
- name encoded ID
-
takeOverMasterRole
public void takeOverMasterRole()
-
setClusterStopping
public void setClusterStopping()
-
waitFor
public void waitFor(long msec)
-
notifyNewMaster
public void notifyNewMaster()
-
reportJoinedAndReadyState
public void reportJoinedAndReadyState()
-
groupStartup
public void groupStartup(com.sun.enterprise.ee.cms.core.GMSConstants.groupStartupState startupState, java.util.List<java.lang.String> memberTokens)
-
isGroupStartup
public boolean isGroupStartup()
-
getGroupName
public java.lang.String getGroupName()
-
isDiscoveryInProgress
public boolean isDiscoveryInProgress()
-
-