[jboss-cvs] JBossAS SVN: r64005 - in trunk: cluster/src/main/org/jboss/ha/jmx and 2 other directories.
jboss-cvs-commits at lists.jboss.org
jboss-cvs-commits at lists.jboss.org
Thu Jul 12 15:08:51 EDT 2007
Author: jerrygauth
Date: 2007-07-12 15:08:50 -0400 (Thu, 12 Jul 2007)
New Revision: 64005
Modified:
trunk/cluster/src/etc/deploy-hasingleton-beans.xml
trunk/cluster/src/etc/deploy-hasingleton-service.xml
trunk/cluster/src/main/org/jboss/ha/jmx/HAServiceMBean.java
trunk/cluster/src/main/org/jboss/ha/jmx/HAServiceMBeanSupport.java
trunk/cluster/src/main/org/jboss/ha/singleton/HASingletonSupport.java
trunk/testsuite/src/main/org/jboss/test/jmx/ha/HAService.java
Log:
JBAS-4276, partition injection changes for HAServiceMBeanSupport
Modified: trunk/cluster/src/etc/deploy-hasingleton-beans.xml
===================================================================
--- trunk/cluster/src/etc/deploy-hasingleton-beans.xml 2007-07-12 18:53:42 UTC (rev 64004)
+++ trunk/cluster/src/etc/deploy-hasingleton-beans.xml 2007-07-12 19:08:50 UTC (rev 64005)
@@ -34,7 +34,7 @@
<depends>HAPartition</depends>
- <property name="clusterPartition"><inject bean="HAPartition"/></property>
+ <property name="HAPartition"><inject bean="HAPartition"/></property>
<property name="target"><inject bean="HASingletonDeploymentScanner"/></property>
<property name="targetStartMethod">deploySingletons</property>
<property name="targetStartMethodArgument">${jboss.server.home.url}deploy-hasingleton</property>
Modified: trunk/cluster/src/etc/deploy-hasingleton-service.xml
===================================================================
--- trunk/cluster/src/etc/deploy-hasingleton-service.xml 2007-07-12 18:53:42 UTC (rev 64004)
+++ trunk/cluster/src/etc/deploy-hasingleton-service.xml 2007-07-12 19:08:50 UTC (rev 64005)
@@ -20,7 +20,7 @@
name="jboss.ha:service=HASingletonDeployer">
<!-- We now inject the partition into the HAJNDI service instead
of requiring that the partition name be passed -->
- <depends optional-attribute-name="ClusterPartition"
+ <depends optional-attribute-name="HAPartition"
proxy-type="attribute">jboss:service=${jboss.partition.name:DefaultPartition}</depends>
<depends optional-attribute-name="TargetName">jboss.system:service=MainDeployer</depends>
<attribute name="TargetStartMethod">deploy</attribute>
Modified: trunk/cluster/src/main/org/jboss/ha/jmx/HAServiceMBean.java
===================================================================
--- trunk/cluster/src/main/org/jboss/ha/jmx/HAServiceMBean.java 2007-07-12 18:53:42 UTC (rev 64004)
+++ trunk/cluster/src/main/org/jboss/ha/jmx/HAServiceMBean.java 2007-07-12 19:08:50 UTC (rev 64005)
@@ -26,6 +26,7 @@
import javax.management.Notification;
import javax.management.NotificationBroadcaster;
+import org.jboss.ha.framework.interfaces.HAPartition;
import org.jboss.ha.framework.server.ClusterPartitionMBean;
/**
@@ -43,33 +44,34 @@
extends org.jboss.system.ServiceMBean, NotificationBroadcaster
{
- /**
- * Name of the underlying partition that determine the cluster to use.
+ /**
+ * Gets the name of the partition used by this service. This is a
+ * convenience method as the partition name is an attribute of HAPartition.
*
- * @deprecated use {@link #getClusterPartition()}
+ * @return the name of the partition
*/
String getPartitionName();
-
+
/**
- * 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.
+ * Get the underlying partition used by this service.
*
- * @deprecated use {@link #setClusterPartition(ClusterPartitionMBean)}
+ * @return the partition
*/
- void setPartitionName(String partitionName);
-
+ HAPartition getHAPartition();
+
/**
- * Get the underlying partition used by this service.
+ * Sets the underlying partition used by this service.
*
- * @return the partition
+ * @param clusterPartition the partition
*/
- ClusterPartitionMBean getClusterPartition();
+ void setHAPartition(HAPartition clusterPartition);
/**
* Sets the underlying partition used by this service.
- * Can be set only when the MBean is not in a STARTED or STARTING state.
*
* @param clusterPartition the partition
+ *
+ * @deprecated use {@link #setHAPartition(HAPartition)}
*/
void setClusterPartition(ClusterPartitionMBean clusterPartition);
Modified: trunk/cluster/src/main/org/jboss/ha/jmx/HAServiceMBeanSupport.java
===================================================================
--- trunk/cluster/src/main/org/jboss/ha/jmx/HAServiceMBeanSupport.java 2007-07-12 18:53:42 UTC (rev 64004)
+++ trunk/cluster/src/main/org/jboss/ha/jmx/HAServiceMBeanSupport.java 2007-07-12 19:08:50 UTC (rev 64005)
@@ -22,25 +22,16 @@
package org.jboss.ha.jmx;
import java.io.Serializable;
-import java.util.Iterator;
import java.util.List;
-import java.util.Set;
import javax.management.AttributeChangeNotification;
-import javax.management.InstanceNotFoundException;
import javax.management.Notification;
-import javax.management.ObjectInstance;
-import javax.management.Query;
-import javax.management.QueryExp;
import org.jboss.ha.framework.interfaces.DistributedReplicantManager;
import org.jboss.ha.framework.interfaces.DistributedState;
import org.jboss.ha.framework.interfaces.HAPartition;
-import org.jboss.ha.framework.server.ClusterPartition;
import org.jboss.ha.framework.server.ClusterPartitionMBean;
-import org.jboss.mx.util.MBeanProxyExt;
import org.jboss.system.ServiceMBeanSupport;
-import org.jboss.system.server.ServerConfigUtil;
/**
*
@@ -68,9 +59,7 @@
// Constants -----------------------------------------------------
// Attributes ----------------------------------------------------
- private HAPartition partition_;
- private ClusterPartitionMBean clusterPartition;
- private String partitionName = ServerConfigUtil.getDefaultPartitionName();
+ private HAPartition clusterPartition;
private DistributedReplicantManager.ReplicantListener drmListener = null;
@@ -89,33 +78,29 @@
// for JMX
}
- public ClusterPartitionMBean getClusterPartition()
+ public HAPartition getHAPartition()
{
return clusterPartition;
}
+
+ public void setHAPartition(HAPartition clusterPartition)
+ {
+ this.clusterPartition = clusterPartition;
+ }
public void setClusterPartition(ClusterPartitionMBean clusterPartition)
{
if ((getState() != STARTED) && (getState() != STARTING))
{
- this.clusterPartition = clusterPartition;
+ this.clusterPartition = clusterPartition.getHAPartition();
}
}
public String getPartitionName()
{
- return partitionName;
+ return clusterPartition.getPartitionName();
}
- public void setPartitionName(String newPartitionName)
- {
- if ((getState() != STARTED) && (getState() != STARTING))
- {
- partitionName = newPartitionName;
- }
- }
-
-
// Protected ------------------------------
/**
@@ -131,7 +116,7 @@
public void setDistributedState(String key, Serializable value)
throws Exception
{
- DistributedState ds = getPartition().getDistributedStateService();
+ DistributedState ds = clusterPartition.getDistributedStateService();
ds.set(getServiceHAName(), key, value);
}
@@ -146,7 +131,7 @@
*/
public Serializable getDistributedState(String key)
{
- DistributedState ds = getPartition().getDistributedStateService();
+ DistributedState ds = clusterPartition.getDistributedStateService();
return ds.get(getServiceHAName(), key);
}
@@ -168,12 +153,18 @@
protected void startService() throws Exception
{
log.debug("start HAServiceMBeanSupport");
+
+ if (clusterPartition == null)
+ {
+ throw new IllegalStateException("HAPartition property must be set before starting HAServiceMBeanSupport");
+ }
setupPartition();
registerRPCHandler();
registerDRMListener();
+
}
/**
@@ -193,33 +184,22 @@
protected void setupPartition() throws Exception
{
- // get handle to the cluster partition
- if (clusterPartition == null)
- {
- String pName = getPartitionName();
- partition_ = findHAPartitionWithName(pName);
- }
- else
- {
- partition_ = clusterPartition.getHAPartition();
- partitionName = partition_.getPartitionName();
- }
+ // method no longer used by base implementation
}
protected void registerRPCHandler()
{
- partition_.registerRPCHandler(getServiceHAName(), this);
+ clusterPartition.registerRPCHandler(getServiceHAName(), this);
}
protected void unregisterRPCHandler()
{
- partition_.unregisterRPCHandler(getServiceHAName(), this);
+ clusterPartition.unregisterRPCHandler(getServiceHAName(), this);
}
protected void registerDRMListener() throws Exception
{
- DistributedReplicantManager drm =
- this.partition_.getDistributedReplicantManager();
+ DistributedReplicantManager drm = clusterPartition.getDistributedReplicantManager();
// register to listen to topology changes, which might cause the election of a new master
drmListener = new DistributedReplicantManager.ReplicantListener()
@@ -254,8 +234,7 @@
protected void unregisterDRMListener() throws Exception
{
- DistributedReplicantManager drm =
- this.partition_.getDistributedReplicantManager();
+ DistributedReplicantManager drm = clusterPartition.getDistributedReplicantManager();
// remove replicant node
drm.remove(getServiceHAName());
@@ -274,22 +253,15 @@
protected boolean isDRMMasterReplica()
{
- DistributedReplicantManager drm =
- getPartition().getDistributedReplicantManager();
+ DistributedReplicantManager drm = clusterPartition.getDistributedReplicantManager();
return drm.isMasterReplica(getServiceHAName());
}
-
- public HAPartition getPartition()
- {
- return partition_;
- }
-
public void callMethodOnPartition(String methodName, Object[] args, Class[] types)
throws Exception
{
- getPartition().callMethodOnCluster(
+ clusterPartition.callMethodOnCluster(
getServiceHAName(),
methodName,
args, types,
@@ -418,15 +390,11 @@
protected void callAsyncMethodOnPartition(String methodName, Object[] args, Class[] types)
throws Exception
{
- HAPartition partition = getPartition();
- if (partition != null)
- {
- partition.callAsynchMethodOnCluster(
+ clusterPartition.callAsynchMethodOnCluster(
getServiceHAName(),
methodName,
args, types,
true);
- }
}
@@ -468,47 +436,6 @@
return getServiceName().getCanonicalName();
}
-
- protected HAPartition findHAPartitionWithName(String name) throws Exception
- {
- log.debug("findHAPartitionWithName, name="+name);
- HAPartition result = null;
- // Class name match does not work with the AOP proxy :(
-// QueryExp classEQ = Query.eq(Query.classattr(),
-// Query.value(ClusterPartition.class.getName()));
- QueryExp matchName = Query.match(Query.attr("Name"),
- Query.value("ClusterPartition"));
- QueryExp matchPartitionName = Query.match(Query.attr("PartitionName"),
- Query.value(name));
- QueryExp exp = Query.and(matchName, matchPartitionName);
- Set mbeans = this.getServer().queryMBeans(null, exp);
- if (mbeans != null && mbeans.size() > 0)
- {
- for (Iterator iter = mbeans.iterator(); iter.hasNext();)
- {
- ObjectInstance inst = (ObjectInstance) iter.next();
- try
- {
- ClusterPartitionMBean cp =
- (ClusterPartitionMBean) MBeanProxyExt.create(
- ClusterPartitionMBean.class,
- inst.getObjectName(),
- this.getServer());
- result = cp.getHAPartition();
- break;
- }
- catch (Exception e) {}
- }
- }
-
- if( result == null )
- {
- String msg = "Failed to find HAPartition with PartitionName="+name;
- throw new InstanceNotFoundException(msg);
- }
- return result;
- }
-
// Private -------------------------------------------------------
// Inner classes -------------------------------------------------
Modified: trunk/cluster/src/main/org/jboss/ha/singleton/HASingletonSupport.java
===================================================================
--- trunk/cluster/src/main/org/jboss/ha/singleton/HASingletonSupport.java 2007-07-12 18:53:42 UTC (rev 64004)
+++ trunk/cluster/src/main/org/jboss/ha/singleton/HASingletonSupport.java 2007-07-12 19:08:50 UTC (rev 64005)
@@ -133,7 +133,7 @@
{
boolean isElectedNewMaster;
if (this.mElectionPolicyMB != null)
- isElectedNewMaster = this.mElectionPolicyMB.isElectedMaster(this.getPartition());
+ isElectedNewMaster = this.mElectionPolicyMB.isElectedMaster(this.getHAPartition());
else
isElectedNewMaster = isDRMMasterReplica();
Modified: trunk/testsuite/src/main/org/jboss/test/jmx/ha/HAService.java
===================================================================
--- trunk/testsuite/src/main/org/jboss/test/jmx/ha/HAService.java 2007-07-12 18:53:42 UTC (rev 64004)
+++ trunk/testsuite/src/main/org/jboss/test/jmx/ha/HAService.java 2007-07-12 19:08:50 UTC (rev 64005)
@@ -130,7 +130,7 @@
public String getClusterNode()
{
- return getPartition().getNodeName();
+ return getHAPartition().getNodeName();
}
}
More information about the jboss-cvs-commits
mailing list