[jboss-cvs] JBossAS SVN: r61872 - in branches/Branch_4_0/cluster/src: main/org/jboss/ha/framework/interfaces and 2 other directories.
jboss-cvs-commits at lists.jboss.org
jboss-cvs-commits at lists.jboss.org
Thu Mar 29 21:41:04 EDT 2007
Author: bstansberry at jboss.com
Date: 2007-03-29 21:41:04 -0400 (Thu, 29 Mar 2007)
New Revision: 61872
Added:
branches/Branch_4_0/cluster/src/main/org/jboss/ha/framework/interfaces/ClusterMergeStatus.java
branches/Branch_4_0/cluster/src/main/org/jboss/ha/singleton/RestartOnMergeHASingletonController.java
Modified:
branches/Branch_4_0/cluster/src/etc/deploy-hasingleton-service.xml
branches/Branch_4_0/cluster/src/main/org/jboss/ha/framework/server/DistributedReplicantManagerImpl.java
branches/Branch_4_0/cluster/src/main/org/jboss/ha/singleton/HASingletonController.java
branches/Branch_4_0/cluster/src/main/org/jboss/ha/singleton/HASingletonSupport.java
Log:
[JBAS-4262] Port JBAS-4229 fix to Branch_4_0
Modified: branches/Branch_4_0/cluster/src/etc/deploy-hasingleton-service.xml
===================================================================
--- branches/Branch_4_0/cluster/src/etc/deploy-hasingleton-service.xml 2007-03-30 00:13:05 UTC (rev 61871)
+++ branches/Branch_4_0/cluster/src/etc/deploy-hasingleton-service.xml 2007-03-30 01:41:04 UTC (rev 61872)
@@ -17,6 +17,7 @@
|
-->
<mbean code="org.jboss.ha.singleton.HASingletonController"
+ interface="org.jboss.ha.singleton.RestartOnMergeSingletonController"
name="jboss.ha:service=HASingletonDeployer">
<!-- We now inject the partition into the HAJNDI service instead
of requiring that the partition name be passed -->
@@ -27,6 +28,22 @@
<attribute name="TargetStartMethodArgument">${jboss.server.home.url}/deploy-hasingleton</attribute>
<attribute name="TargetStopMethod">undeploy</attribute>
<attribute name="TargetStopMethodArgument">${jboss.server.home.url}/deploy-hasingleton</attribute>
+
+ <!-- Whether the singleton should be restarted (i.e. invoke the TargetStopMethod and then the
+ TargetStartMethod) if a cluster merge occurs while this node is the singleton master.
+ A cluster merge means there may have been more than one singleton masters during the period
+ when communication between some or all of the nodes in the cluster was disrupted; hence the
+ surviving master may not be aware of state changes made by another master. Restarting the
+ singleton gives it a signal that it should refresh its internal state from any external
+ store.
+
+ By default this is set to 'false' in 4.0.5.SP1, as setting it to 'true' is an
+ overly large behavior change for an SP release.
+
+ However, we recommend setting it to true, as HA-JMS should re-establish state from its
+ persistent store if a cluster merge occurs. See http://jira.jboss.com/jira/browse/JBAS-4229.
+ -->
+ <attribute name="RestartOnMerge">false</attribute>
</mbean>
<!--
Copied: branches/Branch_4_0/cluster/src/main/org/jboss/ha/framework/interfaces/ClusterMergeStatus.java (from rev 61868, branches/Branch_4_2/cluster/src/main/org/jboss/ha/framework/interfaces/ClusterMergeStatus.java)
===================================================================
--- branches/Branch_4_0/cluster/src/main/org/jboss/ha/framework/interfaces/ClusterMergeStatus.java (rev 0)
+++ branches/Branch_4_0/cluster/src/main/org/jboss/ha/framework/interfaces/ClusterMergeStatus.java 2007-03-30 01:41:04 UTC (rev 61872)
@@ -0,0 +1,53 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2006, Red Hat Middleware LLC, and individual contributors
+ * as indicated by the @author tags. See the copyright.txt file in the
+ * distribution for a full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+
+package org.jboss.ha.framework.interfaces;
+
+/**
+ * ThreadLocal-based context information about whether the
+ * current thread is executing a cluster merge.
+ * <p/>
+ * This is really a temporary 4.x workaround for JBAS-4229. In
+ * AS 5 this will likely be replaced by adding a boolean parameter
+ * to DistributedReplicantManager.ReplicantListener.replicantsChanged().
+ *
+ * @author Brian Stansberry
+ */
+public class ClusterMergeStatus
+{
+ private static final ThreadLocal status = new ThreadLocal();
+
+ public static void startMergeProcess()
+ {
+ status.set(Boolean.TRUE);
+ }
+
+ public static void endMergeProcess()
+ {
+ status.set(null);
+ }
+
+ public static boolean isMergeInProcess()
+ {
+ return status.get() != null;
+ }
+}
Modified: branches/Branch_4_0/cluster/src/main/org/jboss/ha/framework/server/DistributedReplicantManagerImpl.java
===================================================================
--- branches/Branch_4_0/cluster/src/main/org/jboss/ha/framework/server/DistributedReplicantManagerImpl.java 2007-03-30 00:13:05 UTC (rev 61871)
+++ branches/Branch_4_0/cluster/src/main/org/jboss/ha/framework/server/DistributedReplicantManagerImpl.java 2007-03-30 01:41:04 UTC (rev 61872)
@@ -41,6 +41,7 @@
import org.jboss.logging.Logger;
+import org.jboss.ha.framework.interfaces.ClusterMergeStatus;
import org.jboss.ha.framework.interfaces.ClusterNode;
import org.jboss.ha.framework.interfaces.DistributedReplicantManager;
import org.jboss.ha.framework.interfaces.HAPartition;
@@ -891,8 +892,11 @@
protected void mergeMembers()
{
+ boolean isAlreadyMerging = ClusterMergeStatus.isMergeInProcess();
try
{
+ ClusterMergeStatus.startMergeProcess();
+
log.debug("Start merging members in DRM service...");
java.util.HashSet notifies = new java.util.HashSet ();
ArrayList rsp = partition.callMethodOnCluster(SERVICE_NAME,
@@ -966,6 +970,11 @@
{
log.error("merge failed", ex);
}
+ finally
+ {
+ if (!isAlreadyMerging)
+ ClusterMergeStatus.endMergeProcess();
+ }
}
/**
Modified: branches/Branch_4_0/cluster/src/main/org/jboss/ha/singleton/HASingletonController.java
===================================================================
--- branches/Branch_4_0/cluster/src/main/org/jboss/ha/singleton/HASingletonController.java 2007-03-30 00:13:05 UTC (rev 61871)
+++ branches/Branch_4_0/cluster/src/main/org/jboss/ha/singleton/HASingletonController.java 2007-03-30 01:41:04 UTC (rev 61872)
@@ -48,7 +48,7 @@
* @version $Revision$
*/
public class HASingletonController extends HASingletonSupport
- implements HASingletonControllerMBean
+ implements RestartOnMergeHASingletonController
{
// Private Data --------------------------------------------------
Modified: branches/Branch_4_0/cluster/src/main/org/jboss/ha/singleton/HASingletonSupport.java
===================================================================
--- branches/Branch_4_0/cluster/src/main/org/jboss/ha/singleton/HASingletonSupport.java 2007-03-30 00:13:05 UTC (rev 61871)
+++ branches/Branch_4_0/cluster/src/main/org/jboss/ha/singleton/HASingletonSupport.java 2007-03-30 01:41:04 UTC (rev 61872)
@@ -25,6 +25,7 @@
import javax.management.Notification;
+import org.jboss.ha.framework.interfaces.ClusterMergeStatus;
import org.jboss.ha.jmx.HAServiceMBeanSupport;
/**
@@ -41,6 +42,7 @@
// Private Data --------------------------------------------------
private boolean isMasterNode = false;
+ private boolean restartOnMerge = false;
// Constructors --------------------------------------------------
@@ -64,6 +66,38 @@
return isMasterNode;
}
+ /**
+ * Gets whether this singleton will stop and restart itself if it is the
+ * master and a cluster merge occurs.
+ * <p/>
+ * A restart allows the service to reset any state that may
+ * have gotten out-of-sync with the rest of the cluster while
+ * the just-merged split was in effect.
+ *
+ * @return <code>true</code> if a restart will occur, <code>false</code>
+ * otherwise
+ */
+ public boolean getRestartOnMerge()
+ {
+ return restartOnMerge;
+ }
+
+ /**
+ * Sets whether this singleton will stop and restart itself if it is the
+ * master and a cluster merge occurs?
+ * <p/>
+ * A restart allows the service to reset any state that may
+ * have gotten out-of-sync with the rest of the cluster while
+ * the just-merged split was in effect.
+ *
+ * @param restartOnMerge <code>true</code> if a restart should occur,
+ * <code>false</code> otherwise
+ */
+ public void setRestartOnMerge(boolean restartOnMerge)
+ {
+ this.restartOnMerge = restartOnMerge;
+ }
+
// Public --------------------------------------------------------
/**
@@ -125,7 +159,11 @@
// if this node is already the master, don't bother electing it again
if (isElectedNewMaster && isMasterNode)
{
- return;
+ // JBAS-4229
+ if (restartOnMerge && ClusterMergeStatus.isMergeInProcess())
+ {
+ restartMaster();
+ }
}
// just becoming master
else if (isElectedNewMaster && !isMasterNode)
@@ -188,16 +226,7 @@
//callMethodOnPartition("_stopOldMaster", new Object[0], new Class[0]);
callAsyncMethodOnPartition("_stopOldMaster", new Object[0], new Class[0]);
- isMasterNode = true;
-
- // notify starting
- sendLocalNotification(HASINGLETON_STARTING_NOTIFICATION);
-
- // start new master
- startSingleton();
-
- // notify started
- sendLocalNotification(HASINGLETON_STARTED_NOTIFICATION);
+ startNewMaster();
}
catch (Exception ex)
{
@@ -205,6 +234,28 @@
}
}
+ protected void startNewMaster()
+ {
+ log.debug("startNewMaster, isMasterNode=" + isMasterNode);
+
+ isMasterNode = true;
+
+ // notify starting
+ sendLocalNotification(HASINGLETON_STARTING_NOTIFICATION);
+
+ // start new master
+ startSingleton();
+
+ // notify started
+ sendLocalNotification(HASINGLETON_STARTED_NOTIFICATION);
+ }
+
+ protected void restartMaster()
+ {
+ _stopOldMaster();
+ startNewMaster();
+ }
+
// Private -------------------------------------------------------
private void sendLocalNotification(String type)
Copied: branches/Branch_4_0/cluster/src/main/org/jboss/ha/singleton/RestartOnMergeHASingletonController.java (from rev 61869, branches/JBoss_4_0_3_SP1_CP/cluster/src/main/org/jboss/ha/singleton/RestartOnMergeHASingletonController.java)
===================================================================
--- branches/Branch_4_0/cluster/src/main/org/jboss/ha/singleton/RestartOnMergeHASingletonController.java (rev 0)
+++ branches/Branch_4_0/cluster/src/main/org/jboss/ha/singleton/RestartOnMergeHASingletonController.java 2007-03-30 01:41:04 UTC (rev 61872)
@@ -0,0 +1,42 @@
+/**
+ *
+ */
+package org.jboss.ha.singleton;
+
+/**
+ * Extends HASingletonControllerMBean to expose configuration of the
+ * <code>restartOnMerge</code> property.
+ *
+ * @author <a href="brian.stansberry at jboss.com">Brian Stansberry</a>
+ * @version $Revision: 1.1 $
+ */
+public interface RestartOnMergeHASingletonController extends HASingletonControllerMBean
+{
+
+ /**
+ * Gets whether this singleton will stop and restart itself if it is the
+ * master and a cluster merge occurs.
+ * <p/>
+ * A restart allows the service to reset any state that may
+ * have gotten out-of-sync with the rest of the cluster while
+ * the just-merged split was in effect.
+ *
+ * @return <code>true</code> if a restart will occur, <code>false</code>
+ * otherwise
+ */
+ boolean getRestartOnMerge();
+
+ /**
+ * Sets whether this singleton will stop and restart itself if it is the
+ * master and a cluster merge occurs?
+ * <p/>
+ * A restart allows the service to reset any state that may
+ * have gotten out-of-sync with the rest of the cluster while
+ * the just-merged split was in effect.
+ *
+ * @param restartOnMerge <code>true</code> if a restart should occur,
+ * <code>false</code> otherwise
+ */
+ void setRestartOnMerge(boolean restartOnMerge);
+
+}
More information about the jboss-cvs-commits
mailing list