org.jboss.ha.singleton
Class HASingletonSupport

java.lang.Object
  extended byorg.jboss.mx.util.JBossNotificationBroadcasterSupport (src) 
      extended byorg.jboss.system.ServiceMBeanSupport (src) 
          extended byorg.jboss.ha.jmx.HAServiceMBeanSupport (src) 
              extended byorg.jboss.ha.singleton.HASingletonSupport
All Implemented Interfaces:
HAServiceMBean (src) , HASingleton (src) , HASingletonMBean (src) , MBeanRegistration (src) , NotificationBroadcaster (src) , NotificationEmitter (src) , Service (src) , ServiceMBean (src)
Direct Known Subclasses:
AbstractScheduleProvider (src) , HASingletonController (src) , HASingletonSupportTester (src)

public class HASingletonSupport
extends HAServiceMBeanSupport (src)
implements HASingletonMBean (src) , HASingleton (src)

Management Bean for an HA-Singleton service.


Field Summary
 
Fields inherited from class org.jboss.system.ServiceMBeanSupport (src)
log, server, SERVICE_CONTROLLER_SIG, serviceName
 
Fields inherited from interface org.jboss.system.ServiceMBean (src)
CREATE_EVENT, CREATED, DESTROY_EVENT, DESTROYED, FAILED, REGISTERED, START_EVENT, STARTED, STARTING, states, STOP_EVENT, STOPPED, STOPPING, UNREGISTERED
 
Constructor Summary
HASingletonSupport()
           
 
Method Summary
 void _stopOldMaster()
          This method will be invoked twice by the local node when it stops as well as by the remote
 boolean isMasterNode()
           
protected  void makeThisNodeMaster()
           
 void partitionTopologyChanged(java.util.List newReplicants, int newViewID)
          When topology changes, a new master is elected based on the result of the isDRMMasterReplica() call.
 void startSingleton()
           Extending classes should override this method and implement the custom singleton logic.
 void stopSingleton()
          Extending classes should override this method and implement the custom singleton logic.
 
Methods inherited from class org.jboss.ha.jmx.HAServiceMBeanSupport (src)
_receiveRemoteNotification, callAsyncMethodOnPartition, callMethodOnPartition, callMethodOnPartition, findHAPartitionWithName, getDistributedState, getPartition, getPartitionName, getServiceHAName, isDRMMasterReplica, registerDRMListener, registerRPCHandler, sendNotification, sendNotificationRemote, sendNotificationToLocalListeners, setDistributedState, setPartitionName, setupPartition, startService, stopService, unregisterDRMListener, unregisterRPCHandler
 
Methods inherited from class org.jboss.system.ServiceMBeanSupport (src)
create, createService, destroy, destroyService, getLog, getName, getNextNotificationSequenceNumber, getObjectName, getServer, getServiceName, getState, getStateString, jbossInternalCreate, jbossInternalDescription, jbossInternalDestroy, jbossInternalLifecycle, jbossInternalStart, jbossInternalStop, postDeregister, postRegister, preDeregister, preRegister, start, stop
 
Methods inherited from class org.jboss.mx.util.JBossNotificationBroadcasterSupport (src)
addNotificationListener, getNotificationInfo, handleNotification, removeNotificationListener, removeNotificationListener
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 
Methods inherited from interface org.jboss.ha.jmx.HAServiceMBean (src)
callMethodOnPartition, getDistributedState, getPartitionName, sendNotification, setDistributedState, setPartitionName
 
Methods inherited from interface org.jboss.system.ServiceMBean (src)
getName, getState, getStateString, jbossInternalLifecycle
 
Methods inherited from interface org.jboss.system.Service (src)
create, destroy, start, stop
 
Methods inherited from interface javax.management.NotificationBroadcaster (src)
addNotificationListener, getNotificationInfo, removeNotificationListener
 

Constructor Detail

HASingletonSupport

public HASingletonSupport()
Method Detail

isMasterNode

public boolean isMasterNode()
Specified by:
isMasterNode in interface HASingletonMBean (src)
Returns:
true if this cluster node has the active mbean singleton. false otherwise

startSingleton

public void startSingleton()

Extending classes should override this method and implement the custom singleton logic. Only one node in the cluster is the active master. If the current node is elected for master, this method is invoked. When another node is elected for master for some reason, the stopSingleton() method is invokded.

When the extending class is a stateful singleton, it will usually use putDistributedState() and getDistributedState() to save in the cluster environment information that will be needed by the next node elected for master should the current master node fail.

Specified by:
startSingleton in interface HASingleton (src)
See Also:
HASingleton (src)

stopSingleton

public void stopSingleton()
Extending classes should override this method and implement the custom singleton logic. Only one node in the cluster is the active master. If the current node is master and another node is elected for master, this method is invoked.

Specified by:
stopSingleton in interface HASingleton (src)
See Also:
HASingleton (src)

partitionTopologyChanged

public void partitionTopologyChanged(java.util.List newReplicants,
                                     int newViewID)
When topology changes, a new master is elected based on the result of the isDRMMasterReplica() call.

Overrides:
partitionTopologyChanged in class HAServiceMBeanSupport (src)
See Also:
HAServiceMBeanSupport.partitionTopologyChanged(List, int), DistributedReplicantManager#isMasterReplica(String);

makeThisNodeMaster

protected void makeThisNodeMaster()

_stopOldMaster

public void _stopOldMaster()
This method will be invoked twice by the local node when it stops as well as by the remote