[jboss-cvs] JBoss Messaging SVN: r5476 - in trunk: src/main/org/jboss/messaging/core/server/cluster and 2 other directories.
jboss-cvs-commits at lists.jboss.org
jboss-cvs-commits at lists.jboss.org
Mon Dec 8 09:22:21 EST 2008
Author: timfox
Date: 2008-12-08 09:22:21 -0500 (Mon, 08 Dec 2008)
New Revision: 5476
Modified:
trunk/src/main/org/jboss/messaging/core/cluster/impl/DiscoveryGroupImpl.java
trunk/src/main/org/jboss/messaging/core/server/cluster/BroadcastGroup.java
trunk/src/main/org/jboss/messaging/core/server/cluster/impl/BroadcastGroupImpl.java
trunk/tests/src/org/jboss/messaging/tests/integration/cluster/distribution/DiscoveryTest.java
Log:
More tests.....
Modified: trunk/src/main/org/jboss/messaging/core/cluster/impl/DiscoveryGroupImpl.java
===================================================================
--- trunk/src/main/org/jboss/messaging/core/cluster/impl/DiscoveryGroupImpl.java 2008-12-08 13:39:33 UTC (rev 5475)
+++ trunk/src/main/org/jboss/messaging/core/cluster/impl/DiscoveryGroupImpl.java 2008-12-08 14:22:21 UTC (rev 5476)
@@ -194,7 +194,7 @@
continue;
}
}
-
+
ByteArrayInputStream bis = new ByteArrayInputStream(data);
ObjectInputStream ois = new ObjectInputStream(bis);
@@ -250,17 +250,18 @@
packet.setLength(data.length);
+ if (changed)
+ {
+ callListeners();
+ }
+
synchronized (waitLock)
{
received = true;
waitLock.notify();
}
-
- if (changed)
- {
- callListeners();
- }
+
}
}
catch (Exception e)
Modified: trunk/src/main/org/jboss/messaging/core/server/cluster/BroadcastGroup.java
===================================================================
--- trunk/src/main/org/jboss/messaging/core/server/cluster/BroadcastGroup.java 2008-12-08 13:39:33 UTC (rev 5475)
+++ trunk/src/main/org/jboss/messaging/core/server/cluster/BroadcastGroup.java 2008-12-08 14:22:21 UTC (rev 5476)
@@ -38,7 +38,9 @@
*/
public interface BroadcastGroup extends MessagingComponent
{
- void addConnectorPair(final Pair<TransportConfiguration, TransportConfiguration> connectorPair);
+ void addConnectorPair(Pair<TransportConfiguration, TransportConfiguration> connectorPair);
+
+ void removeConnectorPair(Pair<TransportConfiguration, TransportConfiguration> connectorPair);
int size();
Modified: trunk/src/main/org/jboss/messaging/core/server/cluster/impl/BroadcastGroupImpl.java
===================================================================
--- trunk/src/main/org/jboss/messaging/core/server/cluster/impl/BroadcastGroupImpl.java 2008-12-08 13:39:33 UTC (rev 5475)
+++ trunk/src/main/org/jboss/messaging/core/server/cluster/impl/BroadcastGroupImpl.java 2008-12-08 14:22:21 UTC (rev 5476)
@@ -60,9 +60,9 @@
private final List<Pair<TransportConfiguration, TransportConfiguration>> connectorPairs = new ArrayList<Pair<TransportConfiguration, TransportConfiguration>>();
- private volatile boolean started;
+ private boolean started;
- private volatile ScheduledFuture<?> future;
+ private ScheduledFuture<?> future;
public BroadcastGroupImpl(final InetAddress localBindAddress,
final int localPort,
@@ -111,22 +111,27 @@
started = false;
}
- public boolean isStarted()
+ public synchronized boolean isStarted()
{
return started;
}
- public void addConnectorPair(final Pair<TransportConfiguration, TransportConfiguration> connectorPair)
+ public synchronized void addConnectorPair(final Pair<TransportConfiguration, TransportConfiguration> connectorPair)
{
connectorPairs.add(connectorPair);
}
+
+ public synchronized void removeConnectorPair(final Pair<TransportConfiguration, TransportConfiguration> connectorPair)
+ {
+ connectorPairs.remove(connectorPair);
+ }
- public int size()
+ public synchronized int size()
{
return connectorPairs.size();
}
- public void broadcastConnectors() throws Exception
+ public synchronized void broadcastConnectors() throws Exception
{
// TODO - for now we just use plain serialization to serialize the transport configs
// we should use our own format for a tighter representation
@@ -178,7 +183,7 @@
}
}
- public void setScheduledFuture(final ScheduledFuture<?> future)
+ public synchronized void setScheduledFuture(final ScheduledFuture<?> future)
{
this.future = future;
}
Modified: trunk/tests/src/org/jboss/messaging/tests/integration/cluster/distribution/DiscoveryTest.java
===================================================================
--- trunk/tests/src/org/jboss/messaging/tests/integration/cluster/distribution/DiscoveryTest.java 2008-12-08 13:39:33 UTC (rev 5475)
+++ trunk/tests/src/org/jboss/messaging/tests/integration/cluster/distribution/DiscoveryTest.java 2008-12-08 14:22:21 UTC (rev 5476)
@@ -32,6 +32,7 @@
import org.jboss.messaging.core.cluster.DiscoveryListener;
import org.jboss.messaging.core.cluster.impl.DiscoveryGroupImpl;
import org.jboss.messaging.core.config.TransportConfiguration;
+import org.jboss.messaging.core.logging.Logger;
import org.jboss.messaging.core.server.cluster.BroadcastGroup;
import org.jboss.messaging.core.server.cluster.impl.BroadcastGroupImpl;
import org.jboss.messaging.tests.util.UnitTestCase;
@@ -51,6 +52,8 @@
*/
public class DiscoveryTest extends UnitTestCase
{
+ private static final Logger log = Logger.getLogger(DiscoveryTest.class);
+
public void testSimpleBroadcast() throws Exception
{
final InetAddress groupAddress = InetAddress.getByName("230.1.2.3");
@@ -205,6 +208,583 @@
dg.stop();
}
+ public void testMultipleGroups() throws Exception
+ {
+ final InetAddress groupAddress1 = InetAddress.getByName("230.1.2.3");
+ final int groupPort1 = 6745;
+
+ final InetAddress groupAddress2 = InetAddress.getByName("230.1.2.4");
+ final int groupPort2 = 6746;
+
+ final InetAddress groupAddress3 = InetAddress.getByName("230.1.2.5");
+ final int groupPort3 = 6747;
+
+ final int timeout = 500;
+
+ BroadcastGroup bg1 = new BroadcastGroupImpl(null, -1, groupAddress1, groupPort1);
+ bg1.start();
+
+ BroadcastGroup bg2 = new BroadcastGroupImpl(null, -1, groupAddress2, groupPort2);
+ bg2.start();
+
+ BroadcastGroup bg3 = new BroadcastGroupImpl(null, -1, groupAddress3, groupPort3);
+ bg3.start();
+
+ TransportConfiguration live1 = generateTC();
+ TransportConfiguration backup1 = generateTC();
+
+ TransportConfiguration live2 = generateTC();
+ TransportConfiguration backup2 = generateTC();
+
+ TransportConfiguration live3 = generateTC();
+ TransportConfiguration backup3 = generateTC();
+
+ Pair<TransportConfiguration, TransportConfiguration> connectorPair1 =
+ new Pair<TransportConfiguration, TransportConfiguration>(live1, backup1);
+
+ Pair<TransportConfiguration, TransportConfiguration> connectorPair2 =
+ new Pair<TransportConfiguration, TransportConfiguration>(live2, backup2);
+
+ Pair<TransportConfiguration, TransportConfiguration> connectorPair3 =
+ new Pair<TransportConfiguration, TransportConfiguration>(live3, backup3);
+
+ bg1.addConnectorPair(connectorPair1);
+ bg2.addConnectorPair(connectorPair2);
+ bg3.addConnectorPair(connectorPair3);
+
+ DiscoveryGroup dg1 = new DiscoveryGroupImpl(groupAddress1, groupPort1, timeout);
+ dg1.start();
+
+ DiscoveryGroup dg2 = new DiscoveryGroupImpl(groupAddress2, groupPort2, timeout);
+ dg2.start();
+
+ DiscoveryGroup dg3 = new DiscoveryGroupImpl(groupAddress3, groupPort3, timeout);
+ dg3.start();
+
+ bg1.broadcastConnectors();
+
+ bg2.broadcastConnectors();
+
+ bg3.broadcastConnectors();
+
+ boolean ok = dg1.waitForBroadcast(1000);
+ assertTrue(ok);
+ List<Pair<TransportConfiguration, TransportConfiguration>> connectors = dg1.getConnectors();
+ assertNotNull(connectors);
+ assertEquals(1, connectors.size());
+ Pair<TransportConfiguration, TransportConfiguration> receivedPair = connectors.get(0);
+ assertEquals(connectorPair1, receivedPair);
+
+ ok = dg2.waitForBroadcast(1000);
+ assertTrue(ok);
+ connectors = dg2.getConnectors();
+ assertNotNull(connectors);
+ assertEquals(1, connectors.size());
+ receivedPair = connectors.get(0);
+ assertEquals(connectorPair2, receivedPair);
+
+ ok = dg3.waitForBroadcast(1000);
+ assertTrue(ok);
+ connectors = dg3.getConnectors();
+ assertNotNull(connectors);
+ assertEquals(1, connectors.size());
+ receivedPair = connectors.get(0);
+ assertEquals(connectorPair3, receivedPair);
+
+ bg1.stop();
+ bg2.stop();
+ bg3.stop();
+
+ dg1.stop();
+ dg2.stop();
+ dg3.stop();
+
+ }
+
+ public void testBroadcastNullBackup() throws Exception
+ {
+ final InetAddress groupAddress = InetAddress.getByName("230.1.2.3");
+ final int groupPort = 6745;
+ final int timeout = 500;
+
+ BroadcastGroup bg = new BroadcastGroupImpl(null, -1, groupAddress, groupPort);
+
+ bg.start();
+
+ TransportConfiguration live1 = generateTC();
+
+ Pair<TransportConfiguration, TransportConfiguration> connectorPair =
+ new Pair<TransportConfiguration, TransportConfiguration>(live1, null);
+
+ bg.addConnectorPair(connectorPair);
+
+ DiscoveryGroup dg = new DiscoveryGroupImpl(groupAddress, groupPort, timeout);
+
+ dg.start();
+
+ bg.broadcastConnectors();
+
+ boolean ok = dg.waitForBroadcast(1000);
+
+ assertTrue(ok);
+
+ List<Pair<TransportConfiguration, TransportConfiguration>> connectors = dg.getConnectors();
+
+ assertNotNull(connectors);
+
+ assertEquals(1, connectors.size());
+
+ Pair<TransportConfiguration, TransportConfiguration> receivedPair = connectors.get(0);
+
+ assertEquals(connectorPair, receivedPair);
+
+ bg.stop();
+
+ dg.stop();
+
+ }
+
+ public void testDiscoveryListenersCalled() throws Exception
+ {
+ final InetAddress groupAddress = InetAddress.getByName("230.1.2.3");
+ final int groupPort = 6745;
+ final int timeout = 500;
+
+ BroadcastGroup bg = new BroadcastGroupImpl(null, -1, groupAddress, groupPort);
+
+ bg.start();
+
+ TransportConfiguration live1 = generateTC();
+
+ Pair<TransportConfiguration, TransportConfiguration> connectorPair =
+ new Pair<TransportConfiguration, TransportConfiguration>(live1, null);
+
+ bg.addConnectorPair(connectorPair);
+
+ DiscoveryGroup dg = new DiscoveryGroupImpl(groupAddress, groupPort, timeout);
+
+ MyListener listener1 = new MyListener();
+ MyListener listener2 = new MyListener();
+ MyListener listener3 = new MyListener();
+
+ dg.registerListener(listener1);
+ dg.registerListener(listener2);
+ dg.registerListener(listener3);
+
+ dg.start();
+
+ bg.broadcastConnectors();
+ boolean ok = dg.waitForBroadcast(1000);
+ assertTrue(ok);
+
+ assertTrue(listener1.called);
+ assertTrue(listener2.called);
+ assertTrue(listener3.called);
+
+ listener1.called = false;
+ listener2.called = false;
+ listener3.called = false;
+
+ bg.broadcastConnectors();
+ ok = dg.waitForBroadcast(1000);
+ assertTrue(ok);
+
+ //Won't be called since connectors haven't changed
+ assertFalse(listener1.called);
+ assertFalse(listener2.called);
+ assertFalse(listener3.called);
+
+ listener1.called = false;
+ listener2.called = false;
+ listener3.called = false;
+
+ TransportConfiguration live2 = generateTC();
+
+ Pair<TransportConfiguration, TransportConfiguration> connectorPair2 =
+ new Pair<TransportConfiguration, TransportConfiguration>(live2, null);
+
+ bg.addConnectorPair(connectorPair2);
+
+ dg.unregisterListener(listener1);
+
+ bg.broadcastConnectors();
+ ok = dg.waitForBroadcast(1000);
+ assertTrue(ok);
+
+ assertFalse(listener1.called);
+ assertTrue(listener2.called);
+ assertTrue(listener3.called);
+
+ listener1.called = false;
+ listener2.called = false;
+ listener3.called = false;
+
+ dg.unregisterListener(listener2);
+
+ bg.broadcastConnectors();
+ ok = dg.waitForBroadcast(1000);
+ assertTrue(ok);
+
+ assertFalse(listener1.called);
+ assertFalse(listener2.called);
+ assertFalse(listener3.called);
+
+ listener1.called = false;
+ listener2.called = false;
+ listener3.called = false;
+
+ TransportConfiguration live4 = generateTC();
+
+ Pair<TransportConfiguration, TransportConfiguration> connectorPair4 =
+ new Pair<TransportConfiguration, TransportConfiguration>(live4, null);
+
+ bg.addConnectorPair(connectorPair4);
+
+ dg.unregisterListener(listener3);
+
+ bg.broadcastConnectors();
+ ok = dg.waitForBroadcast(1000);
+ assertTrue(ok);
+
+ assertFalse(listener1.called);
+ assertFalse(listener2.called);
+ assertFalse(listener3.called);
+
+ bg.stop();
+
+ dg.stop();
+
+ }
+
+ public void testConnectorsUpdatedMultipleBroadcasters() throws Exception
+ {
+ final InetAddress groupAddress = InetAddress.getByName("230.1.2.3");
+ final int groupPort = 6745;
+ final int timeout = 500;
+
+ BroadcastGroup bg1 = new BroadcastGroupImpl(null, -1, groupAddress, groupPort);
+ bg1.start();
+
+ BroadcastGroup bg2 = new BroadcastGroupImpl(null, -1, groupAddress, groupPort);
+ bg2.start();
+
+ BroadcastGroup bg3 = new BroadcastGroupImpl(null, -1, groupAddress, groupPort);
+ bg3.start();
+
+ TransportConfiguration live1 = generateTC();
+ TransportConfiguration backup1 = generateTC();
+ Pair<TransportConfiguration, TransportConfiguration> connectorPair1 =
+ new Pair<TransportConfiguration, TransportConfiguration>(live1, backup1);
+ bg1.addConnectorPair(connectorPair1);
+
+ TransportConfiguration live2 = generateTC();
+ TransportConfiguration backup2 = generateTC();
+ Pair<TransportConfiguration, TransportConfiguration> connectorPair2 =
+ new Pair<TransportConfiguration, TransportConfiguration>(live2, backup2);
+ bg2.addConnectorPair(connectorPair2);
+
+ TransportConfiguration live3 = generateTC();
+ TransportConfiguration backup3 = generateTC();
+ Pair<TransportConfiguration, TransportConfiguration> connectorPair3 =
+ new Pair<TransportConfiguration, TransportConfiguration>(live3, backup3);
+ bg3.addConnectorPair(connectorPair3);
+
+ DiscoveryGroup dg = new DiscoveryGroupImpl(groupAddress, groupPort, timeout);
+
+ MyListener listener1 = new MyListener();
+ dg.registerListener(listener1);
+ MyListener listener2 = new MyListener();
+ dg.registerListener(listener2);
+
+ dg.start();
+
+ bg1.broadcastConnectors();
+ boolean ok = dg.waitForBroadcast(1000);
+ assertTrue(ok);
+ List<Pair<TransportConfiguration, TransportConfiguration>> connectors = dg.getConnectors();
+ assertNotNull(connectors);
+ assertEquals(1, connectors.size());
+ assertTrue(connectors.contains(connectorPair1));
+ assertTrue(listener1.called);
+ assertTrue(listener2.called);
+ listener1.called = false;
+ listener2.called = false;
+
+ bg2.broadcastConnectors();
+ ok = dg.waitForBroadcast(1000);
+ assertTrue(ok);
+ connectors = dg.getConnectors();
+ assertNotNull(connectors);
+ assertEquals(2, connectors.size());
+ assertTrue(connectors.contains(connectorPair1));
+ assertTrue(connectors.contains(connectorPair2));
+ assertTrue(listener1.called);
+ assertTrue(listener2.called);
+ listener1.called = false;
+ listener2.called = false;
+
+ bg3.broadcastConnectors();
+ ok = dg.waitForBroadcast(1000);
+ assertTrue(ok);
+ connectors = dg.getConnectors();
+ assertNotNull(connectors);
+ assertEquals(3, connectors.size());
+ assertTrue(connectors.contains(connectorPair1));
+ assertTrue(connectors.contains(connectorPair2));
+ assertTrue(connectors.contains(connectorPair3));
+ assertTrue(listener1.called);
+ assertTrue(listener2.called);
+ listener1.called = false;
+ listener2.called = false;
+
+ bg1.broadcastConnectors();
+ ok = dg.waitForBroadcast(1000);
+ assertTrue(ok);
+ connectors = dg.getConnectors();
+ assertNotNull(connectors);
+ assertEquals(3, connectors.size());
+ assertTrue(connectors.contains(connectorPair1));
+ assertTrue(connectors.contains(connectorPair2));
+ assertTrue(connectors.contains(connectorPair3));
+ assertFalse(listener1.called);
+ assertFalse(listener2.called);
+ listener1.called = false;
+ listener2.called = false;
+
+ bg2.broadcastConnectors();
+ ok = dg.waitForBroadcast(1000);
+ assertTrue(ok);
+ connectors = dg.getConnectors();
+ assertNotNull(connectors);
+ assertEquals(3, connectors.size());
+ assertTrue(connectors.contains(connectorPair1));
+ assertTrue(connectors.contains(connectorPair2));
+ assertTrue(connectors.contains(connectorPair3));
+ assertFalse(listener1.called);
+ assertFalse(listener2.called);
+ listener1.called = false;
+ listener2.called = false;
+
+ bg3.broadcastConnectors();
+ ok = dg.waitForBroadcast(1000);
+ assertTrue(ok);
+ connectors = dg.getConnectors();
+ assertNotNull(connectors);
+ assertEquals(3, connectors.size());
+ assertTrue(connectors.contains(connectorPair1));
+ assertTrue(connectors.contains(connectorPair2));
+ assertTrue(connectors.contains(connectorPair3));
+ assertFalse(listener1.called);
+ assertFalse(listener2.called);
+ listener1.called = false;
+ listener2.called = false;
+
+ TransportConfiguration live1_1 = generateTC();
+ TransportConfiguration backup1_1 = generateTC();
+ Pair<TransportConfiguration, TransportConfiguration> connectorPair1_1 =
+ new Pair<TransportConfiguration, TransportConfiguration>(live1_1, backup1_1);
+ bg1.addConnectorPair(connectorPair1_1);
+ bg1.broadcastConnectors();
+ ok = dg.waitForBroadcast(1000);
+ assertTrue(ok);
+ connectors = dg.getConnectors();
+ assertNotNull(connectors);
+ assertEquals(4, connectors.size());
+ assertTrue(connectors.contains(connectorPair1));
+ assertTrue(connectors.contains(connectorPair2));
+ assertTrue(connectors.contains(connectorPair3));
+ assertTrue(connectors.contains(connectorPair1_1));
+ assertTrue(listener1.called);
+ assertTrue(listener2.called);
+ listener1.called = false;
+ listener2.called = false;
+
+ bg2.removeConnectorPair(connectorPair2);
+ bg2.broadcastConnectors();
+ ok = dg.waitForBroadcast(1000);
+ assertTrue(ok);
+ connectors = dg.getConnectors();
+ assertNotNull(connectors);
+ assertEquals(4, connectors.size());
+ assertTrue(connectors.contains(connectorPair1));
+ //Connector2 should still be there since not timed out yet
+ assertTrue(connectors.contains(connectorPair2));
+ assertTrue(connectors.contains(connectorPair3));
+ assertTrue(connectors.contains(connectorPair1_1));
+ assertFalse(listener1.called);
+ assertFalse(listener2.called);
+ listener1.called = false;
+ listener2.called = false;
+
+ Thread.sleep(timeout);
+
+ bg1.broadcastConnectors();
+ ok = dg.waitForBroadcast(1000);
+ bg2.broadcastConnectors();
+ ok = dg.waitForBroadcast(1000);
+ bg3.broadcastConnectors();
+ ok = dg.waitForBroadcast(1000);
+
+ connectors = dg.getConnectors();
+ assertNotNull(connectors);
+ assertEquals(3, connectors.size());
+ assertTrue(connectors.contains(connectorPair1));
+ assertTrue(connectors.contains(connectorPair3));
+ assertTrue(connectors.contains(connectorPair1_1));
+ assertTrue(listener1.called);
+ assertTrue(listener2.called);
+ listener1.called = false;
+ listener2.called = false;
+
+ bg1.removeConnectorPair(connectorPair1);
+ bg3.removeConnectorPair(connectorPair3);
+
+ Thread.sleep(timeout);
+
+ bg1.broadcastConnectors();
+ ok = dg.waitForBroadcast(1000);
+ bg2.broadcastConnectors();
+ ok = dg.waitForBroadcast(1000);
+ bg3.broadcastConnectors();
+ ok = dg.waitForBroadcast(1000);
+
+ connectors = dg.getConnectors();
+ assertNotNull(connectors);
+ assertEquals(1, connectors.size());
+ assertTrue(connectors.contains(connectorPair1_1));
+ assertTrue(listener1.called);
+ assertTrue(listener2.called);
+ listener1.called = false;
+ listener2.called = false;
+
+ bg1.removeConnectorPair(connectorPair1_1);
+
+ Thread.sleep(timeout);
+
+ bg1.broadcastConnectors();
+ ok = dg.waitForBroadcast(1000);
+ bg2.broadcastConnectors();
+ ok = dg.waitForBroadcast(1000);
+ bg3.broadcastConnectors();
+ ok = dg.waitForBroadcast(1000);
+
+ connectors = dg.getConnectors();
+ assertNotNull(connectors);
+ assertEquals(0, connectors.size());
+ assertTrue(listener1.called);
+ assertTrue(listener2.called);
+ listener1.called = false;
+ listener2.called = false;
+
+ bg1.broadcastConnectors();
+ ok = dg.waitForBroadcast(1000);
+ bg2.broadcastConnectors();
+ ok = dg.waitForBroadcast(1000);
+ bg3.broadcastConnectors();
+ ok = dg.waitForBroadcast(1000);
+
+ connectors = dg.getConnectors();
+ assertNotNull(connectors);
+ assertEquals(0, connectors.size());
+ assertFalse(listener1.called);
+ assertFalse(listener2.called);
+
+ bg1.stop();
+ bg2.stop();
+ bg3.stop();
+
+ dg.stop();
+ }
+
+ public void testMultipleDiscoveryGroups() throws Exception
+ {
+ final InetAddress groupAddress = InetAddress.getByName("230.1.2.3");
+ final int groupPort = 6745;
+ final int timeout = 500;
+
+ BroadcastGroup bg = new BroadcastGroupImpl(null, -1, groupAddress, groupPort);
+
+ bg.start();
+
+ TransportConfiguration live1 = generateTC();
+ TransportConfiguration backup1 = generateTC();
+
+ Pair<TransportConfiguration, TransportConfiguration> connectorPair1=
+ new Pair<TransportConfiguration, TransportConfiguration>(live1, backup1);
+
+ bg.addConnectorPair(connectorPair1);
+
+ DiscoveryGroup dg1 = new DiscoveryGroupImpl(groupAddress, groupPort, timeout);
+
+ DiscoveryGroup dg2 = new DiscoveryGroupImpl(groupAddress, groupPort, timeout);
+
+ DiscoveryGroup dg3 = new DiscoveryGroupImpl(groupAddress, groupPort, timeout);
+
+ dg1.start();
+ dg2.start();
+ dg3.start();
+
+ bg.broadcastConnectors();
+
+ boolean ok = dg1.waitForBroadcast(1000);
+ assertTrue(ok);
+ List<Pair<TransportConfiguration, TransportConfiguration>> connectors = dg1.getConnectors();
+ assertNotNull(connectors);
+ assertEquals(1, connectors.size());
+ assertTrue(connectors.contains(connectorPair1));
+
+ ok = dg2.waitForBroadcast(1000);
+ assertTrue(ok);
+ connectors = dg2.getConnectors();
+ assertNotNull(connectors);
+ assertEquals(1, connectors.size());
+ assertTrue(connectors.contains(connectorPair1));
+ ok = dg3.waitForBroadcast(1000);
+ assertTrue(ok);
+ connectors = dg3.getConnectors();
+ assertNotNull(connectors);
+ assertEquals(1, connectors.size());
+ assertTrue(connectors.contains(connectorPair1));
+
+ TransportConfiguration live2 = generateTC();
+ TransportConfiguration backup2 = generateTC();
+ Pair<TransportConfiguration, TransportConfiguration> connectorPair2=
+ new Pair<TransportConfiguration, TransportConfiguration>(live2, backup2);
+
+ bg.addConnectorPair(connectorPair2);
+
+ bg.broadcastConnectors();
+ ok = dg1.waitForBroadcast(1000);
+ assertTrue(ok);
+ connectors = dg1.getConnectors();
+ assertNotNull(connectors);
+ assertEquals(2, connectors.size());
+ assertTrue(connectors.contains(connectorPair1));
+ assertTrue(connectors.contains(connectorPair2));
+
+ ok = dg2.waitForBroadcast(1000);
+ assertTrue(ok);
+ connectors = dg2.getConnectors();
+ assertNotNull(connectors);
+ assertEquals(2, connectors.size());
+ assertTrue(connectors.contains(connectorPair1));
+ assertTrue(connectors.contains(connectorPair2));
+
+ ok = dg3.waitForBroadcast(1000);
+ assertTrue(ok);
+ connectors = dg3.getConnectors();
+ assertNotNull(connectors);
+ assertEquals(2, connectors.size());
+ assertTrue(connectors.contains(connectorPair1));
+ assertTrue(connectors.contains(connectorPair2));
+
+ bg.stop();
+
+ dg1.stop();
+ dg2.stop();
+ dg3.stop();
+ }
+
private TransportConfiguration generateTC()
{
String className = "org.foo.bar." + UUIDGenerator.getInstance().generateStringUUID();
@@ -216,5 +796,15 @@
TransportConfiguration tc = new TransportConfiguration(className, params, name);
return tc;
}
+
+ private static class MyListener implements DiscoveryListener
+ {
+ volatile boolean called;
+ public void connectorsChanged()
+ {
+ called = true;
+ }
+ }
+
}
More information about the jboss-cvs-commits
mailing list