tested against activecluster-1.1-SNAPSHOT, activemq-4.0-SNAPSHOT and Sun
JDK 1.4.2_08 and 1.5.0 - two node cluster, both on same machine.
start your first node (red)
[jules@zeuglodon core]$ ./cluster.sh activecluster red
2005/10/29 00:04:18:317 BST [INFO] ACCluster - starting...
2005/10/29 00:04:18:321 BST [INFO] ACCluster - ...started
start your second node (green)
[jules@zeuglodon core]$ ./cluster.sh activecluster green
2005/10/29 00:04:31:874 BST [INFO] ACCluster - starting...
2005/10/29 00:04:31:885 BST [INFO] ACCluster - ...started
2005/10/29 00:04:33:323 BST [INFO] ACCluster - onNodeAdd: red
red says:
2005/10/29 00:04:33:536 BST [INFO] ACCluster - onNodeAdd: green
2005/10/29 00:04:33:537 BST [INFO] ACCluster - onCoordinatorChanged: green
ctl-c green, after a few seconds red says:
2005/10/29 00:04:46:624 BST [INFO] ACCluster - onNodeFailed: green
2005/10/29 00:04:46:626 BST [INFO] ACCluster - onCoordinatorChanged: red
all fine so far - now restart green:
[jules@zeuglodon core]$ ./cluster.sh activecluster green
2005/10/29 00:04:51:962 BST [INFO] ACCluster - starting...
2005/10/29 00:04:51:967 BST [INFO] ACCluster - ...started
red says......nothing.
if you then start a third node (blue):
[jules@zeuglodon core]$ ./cluster.sh activecluster blue
2005/10/29 00:08:47:990 BST [INFO] ACCluster - starting...
2005/10/29 00:08:47:994 BST [INFO] ACCluster - ...started
2005/10/29 00:08:50:198 BST [INFO] ACCluster - onNodeAdd: green
it sees green, but not red and green says:
2005/10/29 00:08:49:661 BST [INFO] ACCluster - onNodeAdd: blue
2005/10/29 00:08:49:662 BST [INFO] ACCluster - onCoordinatorChanged: blue
so green sees blue too.
but red says.....nothing.
Using tcp:// and a broker, red will happily see blue and green after
they are restarted.
This has been the case with activecluster/activemq for a long time, but
I was hoping that it would be fixed by improvements to peer:// in
activemq-4.0 - but :-(
Jules
--
"Open Source is a self-assembling organism. You dangle a piece of
string into a super-saturated solution and a whole operating-system
crystallises out around it."
/**********************************
* Jules Gosnell
* Partner
* Core Developers Network (Europe)
*
* www.coredevelopers.net
*
* Open Source Training & Support.
**********************************/
package org.codehaus.wadi.sandbox.partition.impl;
import java.util.HashMap;
import java.util.Map;
import javax.jms.JMSException;
import org.activecluster.ClusterEvent;
import org.activecluster.ClusterFactory;
import org.activecluster.ClusterListener;
import org.activecluster.impl.DefaultClusterFactory;
import org.activemq.ActiveMQConnectionFactory;
import org.activemq.store.vm.VMPersistenceAdapterFactory;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.codehaus.wadi.dindex.impl.SeniorityElectionStrategy;
import org.codehaus.wadi.impl.CustomClusterFactory;
import org.codehaus.wadi.sandbox.partition.Cluster;
public class ACCluster {
protected final Log _log = LogFactory.getLog(getClass());
//protected final String _clusterUri="tcp://smilodon:61616";
protected final String _clusterUri="peer://org.codehaus.wadi";
protected final String _clusterName="ORG.CODEHAUS.WADI.TEST";
protected final ActiveMQConnectionFactory _connectionFactory=new ActiveMQConnectionFactory(_clusterUri);
protected final ClusterFactory _clusterFactory=new DefaultClusterFactory(_connectionFactory);
protected final org.activecluster.Cluster _cluster;
protected final long _timeout=30*1000L;
public ACCluster(String nodeName) throws Exception {
System.setProperty("activemq.persistenceAdapterFactory", VMPersistenceAdapterFactory.class.getName());
_cluster=_clusterFactory.createCluster(_clusterName);
Map state=new HashMap();
state.put("nodeName", nodeName);
_cluster.getLocalNode().setState(state);
_cluster.addClusterListener(new ClusterListener() {
public void onNodeAdd(ClusterEvent arg0) {
_log.info("onNodeAdd: "+arg0.getNode().getState().get("nodeName"));
}
public void onNodeUpdate(ClusterEvent arg0) {
_log.info("onNodeUpdate: "+arg0.getNode().getState().get("nodeName"));
}
public void onNodeRemoved(ClusterEvent arg0) {
_log.info("onNodeRemoved: "+arg0.getNode().getState().get("nodeName"));
}
public void onNodeFailed(ClusterEvent arg0) {
_log.info("onNodeFailed: "+arg0.getNode().getState().get("nodeName"));
}
public void onCoordinatorChanged(ClusterEvent arg0) {
_log.info("onCoordinatorChanged: "+arg0.getNode().getState().get("nodeName"));
}
});
}
public void start() throws JMSException {
_log.info("starting...");
_cluster.start();
_log.info("...started");
}
public void stop() {
}
public static void main(String[] args) throws Exception {
ACCluster cluster=new ACCluster(args[0]);
cluster.start();
Thread.sleep(100*1000);
cluster.stop();
}
}