org.jboss.ha.jmx
Class HAServiceMBeanSupport

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

public class HAServiceMBeanSupport
extends ServiceMBeanSupport (src)
implements HAServiceMBean (src)

Management Bean for an HA-Service. Provides a convenient common base for cluster symmetric MBeans. This class is also a user transparent extension of the standard NotificationBroadcasterSupport to a clustered environment. Listeners register with their local broadcaster. Invoking sendNotification() on any broadcaster, will notify all listeners in the same cluster partition. TODO: The performance can be further optimized by avoiding broadcast messages when remote listener nodes are not interested (e.g. have no local subscribers) or by iterating locally over filters or remote listeners.


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
HAServiceMBeanSupport()
           
 
Method Summary
 void _receiveRemoteNotification(Notification (src)  notification)
          Invoked by remote broadcasters.
protected  void callAsyncMethodOnPartition(java.lang.String methodName, java.lang.Object[] args, java.lang.Class[] types)
           
 void callMethodOnPartition(java.lang.String methodName, java.lang.Object[] args)
          Convenience method for broadcasting a call to all members of a partition.
 void callMethodOnPartition(java.lang.String methodName, java.lang.Object[] args, java.lang.Class[] types)
           
protected  HAPartition (src) findHAPartitionWithName(java.lang.String name)
           
 java.io.Serializable getDistributedState(java.lang.String key)
          Convenience method for sharing state across a cluster partition.
 HAPartition (src) getPartition()
           
 java.lang.String getPartitionName()
          Name of the underlying partition that determine the cluster to use.
 java.lang.String getServiceHAName()
          Override this method only if you need to provide a custom partition wide unique service name.
protected  boolean isDRMMasterReplica()
           
 void partitionTopologyChanged(java.util.List newReplicants, int newReplicantsViewId)
           
protected  void registerDRMListener()
           
protected  void registerRPCHandler()
           
 void sendNotification(Notification (src)  notification)
          Broadcast the notification to the remote listener nodes (if any) and then invoke super.sendNotification() to notify local listeners.
protected  void sendNotificationRemote(Notification (src)  notification)
          Broadcast a notifcation remotely to the partition participants
protected  void sendNotificationToLocalListeners(Notification (src)  notification)
           
 void setDistributedState(java.lang.String key, java.io.Serializable value)
          Convenience method for sharing state across a cluster partition.
 void setPartitionName(java.lang.String newPartitionName)
          Set the name of the underlying partition that determine the cluster to use.
protected  void setupPartition()
           
protected  void startService()
           Implementors of this method should not code the singleton logic here.
protected  void stopService()
           Attention: Always call this method when you overwrite it in a subclass
protected  void unregisterDRMListener()
           
protected  void 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.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

HAServiceMBeanSupport

public HAServiceMBeanSupport()
Method Detail

getPartitionName

public java.lang.String getPartitionName()
Description copied from interface: HAServiceMBean (src)
Name of the underlying partition that determine the cluster to use.

Specified by:
getPartitionName in interface HAServiceMBean (src)

setPartitionName

public void setPartitionName(java.lang.String newPartitionName)
Description copied from interface: HAServiceMBean (src)
Set the name of the underlying partition that determine the cluster to use. Can be set only when the MBean is not in a STARTED or STARTING state.

Specified by:
setPartitionName in interface HAServiceMBean (src)

setDistributedState

public void setDistributedState(java.lang.String key,
                                java.io.Serializable value)
                         throws java.lang.Exception
Convenience method for sharing state across a cluster partition. Delegates to the DistributedStateService

Specified by:
setDistributedState in interface HAServiceMBean (src)
Parameters:
key - key for the distributed object
value - the distributed object
Throws:
java.lang.Exception

getDistributedState

public java.io.Serializable getDistributedState(java.lang.String key)
Convenience method for sharing state across a cluster partition. Delegates to the DistributedStateService

Specified by:
getDistributedState in interface HAServiceMBean (src)
Parameters:
key - key for the distributed object
Returns:
Serializable the distributed object

startService

protected void startService()
                     throws java.lang.Exception

Implementors of this method should not code the singleton logic here. The MBean lifecycle create/start/stop are separate from the singleton logic. Singleton logic should originate in becomeMaster().

Attention: Always call this method when you overwrite it in a subclass because it elects the master singleton node.

Overrides:
startService in class ServiceMBeanSupport (src)
Throws:
java.lang.Exception

stopService

protected void stopService()
                    throws java.lang.Exception

Attention: Always call this method when you overwrite it in a subclass

Overrides:
stopService in class ServiceMBeanSupport (src)
Throws:
java.lang.Exception

setupPartition

protected void setupPartition()
                       throws java.lang.Exception
Throws:
java.lang.Exception

registerRPCHandler

protected void registerRPCHandler()

unregisterRPCHandler

protected void unregisterRPCHandler()

registerDRMListener

protected void registerDRMListener()
                            throws java.lang.Exception
Throws:
java.lang.Exception

unregisterDRMListener

protected void unregisterDRMListener()
                              throws java.lang.Exception
Throws:
java.lang.Exception

partitionTopologyChanged

public void partitionTopologyChanged(java.util.List newReplicants,
                                     int newReplicantsViewId)

isDRMMasterReplica

protected boolean isDRMMasterReplica()

getPartition

public HAPartition (src)  getPartition()

callMethodOnPartition

public void callMethodOnPartition(java.lang.String methodName,
                                  java.lang.Object[] args)
                           throws java.lang.Exception
Deprecated. Use callMethodOnPartition(String, Object[], Class[]) instead

Description copied from interface: HAServiceMBean (src)
Convenience method for broadcasting a call to all members of a partition.

Specified by:
callMethodOnPartition in interface HAServiceMBean (src)
Parameters:
methodName -
args -
Throws:
java.lang.Exception

callMethodOnPartition

public void callMethodOnPartition(java.lang.String methodName,
                                  java.lang.Object[] args,
                                  java.lang.Class[] types)
                           throws java.lang.Exception
Throws:
java.lang.Exception

sendNotification

public void sendNotification(Notification (src)  notification)
Broadcast the notification to the remote listener nodes (if any) and then invoke super.sendNotification() to notify local listeners.

Specified by:
sendNotification in interface HAServiceMBean (src)
Overrides:
sendNotification in class JBossNotificationBroadcasterSupport (src)
Parameters:
notification - sent out to local listeners and other nodes. It should be serializable. It is recommended that the source of the notification is an ObjectName of an MBean that is is available on all nodes where the broadcaster MBean is registered.
See Also:
NotificationBroadcasterSupport.sendNotification(Notification)

sendNotificationToLocalListeners

protected void sendNotificationToLocalListeners(Notification (src)  notification)

callAsyncMethodOnPartition

protected void callAsyncMethodOnPartition(java.lang.String methodName,
                                          java.lang.Object[] args,
                                          java.lang.Class[] types)
                                   throws java.lang.Exception
Throws:
java.lang.Exception

sendNotificationRemote

protected void sendNotificationRemote(Notification (src)  notification)
                               throws java.lang.Exception
Broadcast a notifcation remotely to the partition participants

Parameters:
notification -
Throws:
java.lang.Exception

_receiveRemoteNotification

public void _receiveRemoteNotification(Notification (src)  notification)
Invoked by remote broadcasters. Delegates to the super class


getServiceHAName

public java.lang.String getServiceHAName()
Override this method only if you need to provide a custom partition wide unique service name. The default implementation will usually work, provided that the getServiceName() method returns a unique canonical MBean name.

Returns:
partition wide unique service name

findHAPartitionWithName

protected HAPartition (src)  findHAPartitionWithName(java.lang.String name)
                                       throws java.lang.Exception
Throws:
java.lang.Exception