[jboss-cvs] JBossAS SVN: r67643 - in branches/JBoss_4_0_0_CP/cluster/src/main/org/jboss/ha/framework: server and 1 other directory.
jboss-cvs-commits at lists.jboss.org
jboss-cvs-commits at lists.jboss.org
Fri Nov 30 01:57:09 EST 2007
Author: jiwils
Date: 2007-11-30 01:57:09 -0500 (Fri, 30 Nov 2007)
New Revision: 67643
Modified:
branches/JBoss_4_0_0_CP/cluster/src/main/org/jboss/ha/framework/interfaces/DistributedReplicantManager.java
branches/JBoss_4_0_0_CP/cluster/src/main/org/jboss/ha/framework/interfaces/HAPartition.java
branches/JBoss_4_0_0_CP/cluster/src/main/org/jboss/ha/framework/server/DistributedReplicantManagerImpl.java
Log:
Fix for [ASPATCH-322]; merge from https://svn.jboss.org/repos/jbossas/branches/JBoss_4_0_1_SP1_JBAS-2700/cluster/ in order to backport JBAS-2677.
Modified: branches/JBoss_4_0_0_CP/cluster/src/main/org/jboss/ha/framework/interfaces/DistributedReplicantManager.java
===================================================================
--- branches/JBoss_4_0_0_CP/cluster/src/main/org/jboss/ha/framework/interfaces/DistributedReplicantManager.java 2007-11-30 05:40:19 UTC (rev 67642)
+++ branches/JBoss_4_0_0_CP/cluster/src/main/org/jboss/ha/framework/interfaces/DistributedReplicantManager.java 2007-11-30 06:57:09 UTC (rev 67643)
@@ -39,7 +39,10 @@
/**
* Callback called when the content/list of replicant for a given replicant key has changed
* @param key The name of the key of the replicant that has changed
- * @param newReplicants The list of new replicants for the give replicant key
+ * @param newReplicants The list of new replicants for the give replicant key.
+ * This list will be in a consistent order on all
+ * cluster nodes on which the current viewId is
+ * in effect
* @param newReplicantsViewId The new replicant view id corresponding to this change
*/
public void replicantsChanged(String key, List newReplicants, int newReplicantsViewId);
@@ -86,14 +89,18 @@
/**
* Return a list of all replicants.
* @param key The replicant name
- * @return An array of serialized replicants available around the cluster for the given key
+ * @return An list of serialized replicants available around the cluster
+ * for the given key. This list will be in the same order in all
+ * nodes in the cluster.
*/
public List lookupReplicants(String key);
/**
* Return a list of all replicants node names.
* @param key The replicant name
- * @return An array of replicants node names available around the cluster for the given key
+ * @return A list the node names of cluster nodes that have made available
+ * a replicant for the given key. This list will be in the same
+ * order in all nodes in the cluster.
*/
public List lookupReplicantsNodeNames(String key);
Modified: branches/JBoss_4_0_0_CP/cluster/src/main/org/jboss/ha/framework/interfaces/HAPartition.java
===================================================================
--- branches/JBoss_4_0_0_CP/cluster/src/main/org/jboss/ha/framework/interfaces/HAPartition.java 2007-11-30 05:40:19 UTC (rev 67642)
+++ branches/JBoss_4_0_0_CP/cluster/src/main/org/jboss/ha/framework/interfaces/HAPartition.java 2007-11-30 06:57:09 UTC (rev 67643)
@@ -35,9 +35,14 @@
// *******************************
//
/**
- * Return the name of the current name in the current partition. The name is
- * dynamically determined by the partition.
- * @return The partition name
+ * Return the name of this node in the current partition. The name is
+ * dynamically determined by the partition. The name is derived by
+ * calling {@link ClusterNode#getName()} on the <code>ClusterNode</code>
+ * instance that represents this node.
+ *
+ * @return The node name
+ *
+ * @see #getClusterNodes()
*/
public String getNodeName();
/**
@@ -266,7 +271,9 @@
/**
* Return the member nodes that built the current view i.e. the current partition.
- * @return An array of ClusterNode containing the node names
+ * @return An array of ClusterNode listing the current members of the partitionn.
+ * This array will be in the same order in all nodes in the cluster that
+ * have received the current view.
*/
public ClusterNode[] getClusterNodes ();
}
\ No newline at end of file
Modified: branches/JBoss_4_0_0_CP/cluster/src/main/org/jboss/ha/framework/server/DistributedReplicantManagerImpl.java
===================================================================
--- branches/JBoss_4_0_0_CP/cluster/src/main/org/jboss/ha/framework/server/DistributedReplicantManagerImpl.java 2007-11-30 05:40:19 UTC (rev 67642)
+++ branches/JBoss_4_0_0_CP/cluster/src/main/org/jboss/ha/framework/server/DistributedReplicantManagerImpl.java 2007-11-30 06:57:09 UTC (rev 67643)
@@ -8,6 +8,7 @@
package org.jboss.ha.framework.server;
+import java.util.Set;
import java.util.Vector;
import java.util.ArrayList;
import java.util.HashMap;
@@ -26,6 +27,7 @@
import org.jboss.logging.Logger;
+import org.jboss.ha.framework.interfaces.ClusterNode;
import org.jboss.ha.framework.interfaces.DistributedReplicantManager;
import org.jboss.ha.framework.interfaces.HAPartition;
@@ -368,8 +370,33 @@
HashMap replicant = (HashMap)replicants.get(key);
if (replicant == null && local == null) return null;
ArrayList rtn = new ArrayList();
- if (local != null) rtn.add(local);
- if (replicant != null) rtn.addAll(replicant.values());
+
+ if (replicant == null)
+ {
+ if (local != null)
+ rtn.add(local);
+ }
+ else
+ {
+ // JBAS-2677. Put the replicants in view order.
+ ClusterNode[] nodes = partition.getClusterNodes();
+ String replNode;
+ Object replVal;
+ for (int i = 0; i < nodes.length; i++)
+ {
+ replNode = nodes[i].getName();
+ if (local != null && nodeName.equals(replNode))
+ {
+ rtn.add(local);
+ continue;
+ }
+
+ replVal = replicant.get(replNode);
+ if (replVal != null)
+ rtn.add(replVal);
+ }
+ }
+
return rtn;
}
}
@@ -382,8 +409,32 @@
HashMap replicant = (HashMap)replicants.get(key);
if (replicant == null && !locallyReplicated) return null;
ArrayList rtn = new ArrayList();
- if (locallyReplicated) rtn.add(this.nodeName);
- if (replicant != null) rtn.addAll(replicant.keySet ());
+
+ if (replicant == null)
+ {
+ if (locallyReplicated)
+ rtn.add(this.nodeName);
+ }
+ else
+ {
+ // JBAS-2677. Put the replicants in view order.
+ Set keys = replicant.keySet();
+ ClusterNode[] nodes = partition.getClusterNodes();
+ String keyOwner;
+ for (int i = 0; i < nodes.length; i++)
+ {
+ keyOwner = nodes[i].getName();
+ if (locallyReplicated && nodeName.equals(keyOwner))
+ {
+ rtn.add(this.nodeName);
+ continue;
+ }
+
+ if (keys.contains(keyOwner))
+ rtn.add(keyOwner);
+ }
+ }
+
return rtn;
}
}
More information about the jboss-cvs-commits
mailing list