org.jboss.ha.singleton
Class HASingletonSupport

java.lang.Object
  extended by org.jboss.mx.util.JBossNotificationBroadcasterSupport
      extended by org.jboss.system.ServiceMBeanSupport
          extended by org.jboss.ha.jmx.AbstractHAServiceMBeanSupport<org.jboss.ha.framework.interfaces.HASingleton<Notification>>
              extended by org.jboss.ha.singleton.HASingletonSupport
All Implemented Interfaces:
EventListener, MBeanRegistration, NotificationBroadcaster, NotificationEmitter, org.jboss.ha.framework.interfaces.HAService<Notification>, org.jboss.ha.framework.interfaces.HAServiceKeyProvider, org.jboss.ha.framework.interfaces.HASingleton<Notification>, org.jboss.ha.framework.interfaces.HASingletonLifecycle, org.jboss.ha.framework.interfaces.HASingletonMBean, org.jboss.ha.framework.server.EventFacility<Notification>, org.jboss.ha.framework.server.EventFactory<Notification>, org.jboss.ha.framework.server.HAServiceRpcHandler<Notification>, org.jboss.ha.framework.server.HASingletonRpcHandler<Notification>, HAServiceMBean, org.jboss.kernel.spi.dependency.KernelControllerContextAware, Service, ServiceMBean
Direct Known Subclasses:
HASingletonController

public class HASingletonSupport
extends AbstractHAServiceMBeanSupport<org.jboss.ha.framework.interfaces.HASingleton<Notification>>
implements org.jboss.ha.framework.interfaces.HASingleton<Notification>, org.jboss.ha.framework.server.HASingletonRpcHandler<Notification>

Base class for HA-Singleton legacy mbean services.

Version:
$Revision: 87733 $
Author:
Ivelin Ivanov, Scott Stark, Dimitris Andreadis, Galder Zamarreno, Paul Ferraro

Field Summary
 
Fields inherited from class org.jboss.system.ServiceMBeanSupport
log, server, SERVICE_CONTROLLER_SIG, serviceName
 
Fields inherited from interface org.jboss.ha.framework.interfaces.HASingleton
HASINGLETON_STARTED_NOTIFICATION, HASINGLETON_STARTING_NOTIFICATION, HASINGLETON_STOPPED_NOTIFICATION, HASINGLETON_STOPPING_NOTIFICATION
 
Fields inherited from interface org.jboss.system.ServiceMBean
CREATE_EVENT, CREATED, DESTROY_EVENT, DESTROYED, FAILED, REGISTERED, START_EVENT, STARTED, STARTING, states, STOP_EVENT, STOPPED, STOPPING, UNREGISTERED
 
Constructor Summary
HASingletonSupport()
           
 
Method Summary
protected  org.jboss.ha.framework.interfaces.HASingleton<Notification> createHAService()
          Defines the object used to delegate service methods.
 org.jboss.ha.framework.interfaces.HASingletonElectionPolicy getElectionPolicy()
           
 boolean getRestartOnMerge()
           
 boolean isMasterNode()
           
 void setElectionPolicy(org.jboss.ha.framework.interfaces.HASingletonElectionPolicy electionPolicy)
           
 void setRestartOnMerge(boolean restartOnMerge)
           
 void startSingleton()
          Extending classes should override this method and implement the custom singleton logic.
 void stopOldMaster()
           
 void stopSingleton()
          Extending classes should override this method and implement the custom singleton logic.
 
Methods inherited from class org.jboss.ha.jmx.AbstractHAServiceMBeanSupport
callAsyncMethodOnPartition, callMethodOnPartition, createEvent, createService, destroyService, getDistributedState, getHAPartition, getHAService, getHAServiceKey, getPartitionName, getSendLocalLifecycleNotifications, getSendRemoteLifecycleNotifications, getServiceHAName, handleEvent, isRegisterThreadContextClassLoader, notifyListeners, sendNotification, sendNotificationRemote, sendNotificationToLocalListeners, setClusterPartition, setDistributedState, setHAPartition, setRegisterThreadContextClassLoader, setSendLocalLifecycleNotifications, setSendRemoteLifecycleNotifications, setServiceHAName, setupPartition, startService, stopService
 
Methods inherited from class org.jboss.system.ServiceMBeanSupport
create, destroy, getDeploymentInfo, getLog, getName, getNextNotificationSequenceNumber, getObjectName, getServer, getServiceName, getState, getStateString, jbossInternalCreate, jbossInternalDescription, jbossInternalDestroy, jbossInternalLifecycle, jbossInternalStart, jbossInternalStop, pojoChange, pojoCreate, pojoDestroy, pojoStart, pojoStop, postDeregister, postRegister, preDeregister, preRegister, setKernelControllerContext, start, stop, unsetKernelControllerContext
 
Methods inherited from class org.jboss.mx.util.JBossNotificationBroadcasterSupport
addNotificationListener, getNotificationInfo, handleNotification, nextNotificationSequenceNumber, 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.framework.interfaces.HAService
create, destroy, getServiceHAName, isRegisterThreadContextClassLoader, setHAPartition, setRegisterThreadContextClassLoader, setServiceHAName, start, stop
 
Methods inherited from interface org.jboss.ha.framework.interfaces.HAServiceKeyProvider
getHAPartition, getHAServiceKey
 
Methods inherited from interface org.jboss.ha.framework.interfaces.EventListener
handleEvent
 
Methods inherited from interface org.jboss.system.ServiceMBean
getName, getState, getStateString, jbossInternalLifecycle
 
Methods inherited from interface org.jboss.system.Service
create, destroy, start, stop
 
Methods inherited from interface javax.management.NotificationBroadcaster
addNotificationListener, getNotificationInfo, removeNotificationListener
 

Constructor Detail

HASingletonSupport

public HASingletonSupport()
Method Detail

isMasterNode

public boolean isMasterNode()
Specified by:
isMasterNode in interface org.jboss.ha.framework.interfaces.HASingletonMBean
See Also:
HASingletonMBean.isMasterNode()

setElectionPolicy

public void setElectionPolicy(org.jboss.ha.framework.interfaces.HASingletonElectionPolicy electionPolicy)
Specified by:
setElectionPolicy in interface org.jboss.ha.framework.interfaces.HASingleton<Notification>
See Also:
HASingleton.setElectionPolicy(org.jboss.ha.framework.interfaces.HASingletonElectionPolicy)

getElectionPolicy

public org.jboss.ha.framework.interfaces.HASingletonElectionPolicy getElectionPolicy()
Specified by:
getElectionPolicy in interface org.jboss.ha.framework.interfaces.HASingleton<Notification>
See Also:
HASingleton.getElectionPolicy()

getRestartOnMerge

public boolean getRestartOnMerge()
Specified by:
getRestartOnMerge in interface org.jboss.ha.framework.interfaces.HASingleton<Notification>
See Also:
HASingleton.getRestartOnMerge()

setRestartOnMerge

public void setRestartOnMerge(boolean restartOnMerge)
Specified by:
setRestartOnMerge in interface org.jboss.ha.framework.interfaces.HASingleton<Notification>
See Also:
HASingleton.setRestartOnMerge(boolean)

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 org.jboss.ha.framework.interfaces.HASingletonLifecycle
See Also:
HASingletonLifecycle

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 org.jboss.ha.framework.interfaces.HASingletonLifecycle
See Also:
HASingletonLifecycle

createHAService

protected org.jboss.ha.framework.interfaces.HASingleton<Notification> createHAService()
Description copied from class: AbstractHAServiceMBeanSupport
Defines the object used to delegate service methods.

Specified by:
createHAService in class AbstractHAServiceMBeanSupport<org.jboss.ha.framework.interfaces.HASingleton<Notification>>
Returns:
an HAService delegate
See Also:
AbstractHAServiceMBeanSupport.createHAService()

stopOldMaster

public void stopOldMaster()
                   throws Exception
Specified by:
stopOldMaster in interface org.jboss.ha.framework.server.HASingletonRpcHandler<Notification>
Throws:
Exception
See Also:
HASingletonRpcHandler.stopOldMaster()


Copyright © 2009 JBoss, a division of Red Hat, Inc.. All Rights Reserved.