Methods Summary |
---|
public void | _receiveRemoteNotification(javax.management.Notification notification)Invoked by remote broadcasters.
Delegates to the super class
super.sendNotification(notification);
|
protected void | callAsyncMethodOnPartition(java.lang.String methodName, java.lang.Object[] args, java.lang.Class[] types)
HAPartition partition = getPartition();
if (partition != null)
{
getPartition().callAsynchMethodOnCluster(
getServiceHAName(),
methodName,
args, types,
true);
}
|
public void | callMethodOnPartition(java.lang.String methodName, java.lang.Object[] args)
getPartition().callMethodOnCluster(
getServiceHAName(),
methodName,
args,
true);
|
public void | callMethodOnPartition(java.lang.String methodName, java.lang.Object[] args, java.lang.Class[] types)
getPartition().callMethodOnCluster(
getServiceHAName(),
methodName,
args, types,
true);
|
protected org.jboss.ha.framework.interfaces.HAPartition | findHAPartitionWithName(java.lang.String name)
log.debug("findHAPartitionWithName, name="+name);
HAPartition result = null;
QueryExp classEQ = Query.eq(Query.classattr(),
Query.value(ClusterPartition.class.getName()));
QueryExp matchPartitionName = Query.match(Query.attr("PartitionName"),
Query.value(name));
QueryExp exp = Query.and(classEQ, matchPartitionName);
Set mbeans = this.getServer().queryMBeans(null, exp);
if (mbeans != null && mbeans.size() > 0)
{
ObjectInstance inst = (ObjectInstance) (mbeans.iterator().next());
ClusterPartitionMBean cp =
(ClusterPartitionMBean) MBeanProxyExt.create(
ClusterPartitionMBean.class,
inst.getObjectName(),
this.getServer());
result = cp.getHAPartition();
}
if( result == null )
{
String msg = "Failed to find HAPartition with PartitionName="+name;
throw new InstanceNotFoundException(msg);
}
return result;
|
public org.jboss.ha.framework.server.ClusterPartitionMBean | getClusterPartition()
return clusterPartition;
|
public java.io.Serializable | getDistributedState(java.lang.String key)Convenience method for sharing state across a cluster partition.
Delegates to the DistributedStateService
DistributedState ds = getPartition().getDistributedStateService();
return ds.get(getServiceHAName(), key);
|
public org.jboss.ha.framework.interfaces.HAPartition | getPartition()
return partition_;
|
public java.lang.String | getPartitionName()
return partitionName;
|
public boolean | getSendLocalLifecycleNotifications()Gets whether JMX Notifications should be sent to local (same JVM) listeners
if the notification is for an attribute change to attribute "State".
Default is true .
return sendLocalLifecycleNotifications;
|
public boolean | getSendRemoteLifecycleNotifications()Gets whether JMX Notifications should be sent to remote listeners
if the notification is for an attribute change to attribute "State".
Default is true .
See http://jira.jboss.com/jira/browse/JBAS-3194 for an example of a
use case where this property should be set to false.
return sendRemoteLifecycleNotifications;
|
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.
return getServiceName().getCanonicalName();
|
protected boolean | isDRMMasterReplica()
DistributedReplicantManager drm =
getPartition().getDistributedReplicantManager();
return drm.isMasterReplica(getServiceHAName());
|
private boolean | isStateChangeNotification(javax.management.Notification notification)
boolean stateChange = false;
if (notification instanceof AttributeChangeNotification)
{
stateChange = "State".equals(((AttributeChangeNotification) notification).getAttributeName());
}
return stateChange;
|
public void | partitionTopologyChanged(java.util.List newReplicants, int newReplicantsViewId)
boolean debug = log.isDebugEnabled();
if (debug)
{
log.debug("partitionTopologyChanged(). cluster view id: " + newReplicantsViewId);
}
|
protected void | registerDRMListener()
DistributedReplicantManager drm =
this.partition_.getDistributedReplicantManager();
// register to listen to topology changes, which might cause the election of a new master
drmListener = new DistributedReplicantManager.ReplicantListener()
{
Object mutex = new Object();
public void replicantsChanged(
String key,
List newReplicants,
int newReplicantsViewId)
{
if (key.equals(getServiceHAName()))
{
// This synchronized block was added when the internal behavior of
// DistributedReplicantManagerImpl was changed so that concurrent
// replicantsChanged notifications are possible. Synchronization
// ensures that this change won't break non-thread-safe
// subclasses of HAServiceMBeanSupport.
synchronized(mutex)
{
// change in the topology callback
HAServiceMBeanSupport.this.partitionTopologyChanged(newReplicants, newReplicantsViewId);
}
}
}
};
drm.registerListener(getServiceHAName(), drmListener);
// this ensures that the DRM knows that this node has the MBean deployed
drm.add(getServiceHAName(), REPLICANT_TOKEN);
|
protected void | registerRPCHandler()
partition_.registerRPCHandler(getServiceHAName(), this);
|
public void | sendNotification(javax.management.Notification notification)Broadcast the notification to the remote listener nodes (if any) and then
invoke super.sendNotification() to notify local listeners.
boolean stateChange = isStateChangeNotification(notification);
if (!stateChange || sendRemoteLifecycleNotifications)
{
try
{
// Overriding the source MBean with its ObjectName
// to ensure that it can be safely transferred over the wire
notification.setSource(this.getServiceName());
sendNotificationRemote(notification);
}
catch (Throwable th)
{
boolean debug = log.isDebugEnabled();
if (debug)
log.debug("sendNotificationRemote( " + notification + " ) failed ", th);
// even if broadcast failed, local notification should still be sent
}
}
if (!stateChange || sendLocalLifecycleNotifications)
{
sendNotificationToLocalListeners(notification);
}
|
protected void | sendNotificationRemote(javax.management.Notification notification)Broadcast a notifcation remotely to the partition participants
callAsyncMethodOnPartition("_receiveRemoteNotification",
new Object[]{notification}, new Class[]{Notification.class});
|
protected void | sendNotificationToLocalListeners(javax.management.Notification notification)
super.sendNotification(notification);
|
public void | setClusterPartition(org.jboss.ha.framework.server.ClusterPartitionMBean clusterPartition)
if ((getState() != STARTED) && (getState() != STARTING))
{
this.clusterPartition = clusterPartition;
}
|
public void | setDistributedState(java.lang.String key, java.io.Serializable value)Convenience method for sharing state across a cluster partition.
Delegates to the DistributedStateService
DistributedState ds = getPartition().getDistributedStateService();
ds.set(getServiceHAName(), key, value);
|
public void | setPartitionName(java.lang.String newPartitionName)
if ((getState() != STARTED) && (getState() != STARTING))
{
partitionName = newPartitionName;
}
|
public void | setSendLocalLifecycleNotifications(boolean sendLocalLifecycleNotifications)Sets whether JMX Notifications should be sent to local (same JVM) listeners
if the notification is for an attribute change to attribute "State".
Default is true .
this.sendLocalLifecycleNotifications = sendLocalLifecycleNotifications;
|
public void | setSendRemoteLifecycleNotifications(boolean sendRemoteLifecycleNotifications)Sets whether JMX Notifications should be sent to remote listeners
if the notification is for an attribute change to attribute "State".
Default is true .
See http://jira.jboss.com/jira/browse/JBAS-3194 for an example of a
use case where this property should be set to false.
this.sendRemoteLifecycleNotifications = sendRemoteLifecycleNotifications;
|
protected void | setupPartition()
// get handle to the cluster partition
if (clusterPartition == null)
{
String pName = getPartitionName();
partition_ = findHAPartitionWithName(pName);
}
else
{
partition_ = clusterPartition.getHAPartition();
partitionName = partition_.getPartitionName();
}
|
protected void | startService()
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.
boolean debug = log.isDebugEnabled();
if (debug)
log.debug("start HAServiceMBeanSupport");
setupPartition();
registerRPCHandler();
registerDRMListener();
|
protected void | stopService()
Attention: Always call this method when you overwrite it in a subclass
boolean debug = log.isDebugEnabled();
if (debug)
log.debug("stop HAServiceMBeanSupport");
unregisterDRMListener();
unregisterRPCHandler();
|
protected void | unregisterDRMListener()
DistributedReplicantManager drm =
this.partition_.getDistributedReplicantManager();
// remove replicant node
drm.remove(getServiceHAName());
// unregister
drm.unregisterListener(getServiceHAName(), drmListener);
|
protected void | unregisterRPCHandler()
partition_.unregisterRPCHandler(getServiceHAName(), this);
|