ObjectName obj = new ObjectName("jboss.remoting:type=Connector,transport=" + locator1.getProtocol());
registerMBean(server1, connector1, obj);
//connector1.create();
connector1.start();
MulticastDetector detector1 = new MulticastDetector();
registerMBean(server1, detector1, new ObjectName("remoting:type=MulticastDetector"));
// set config info for detector and start it.
detector1.start();
log.info("First set started.");
Thread.sleep(3000);
log.info("Starting second set.");
MBeanServer server2 = null;
try
{
server2 = (MBeanServer) AccessController.doPrivileged( new PrivilegedExceptionAction()
{
public Object run() throws Exception
{
return MBeanServerFactory.createMBeanServer();
}
});
}
catch (PrivilegedActionException e)
{
throw (Exception) e.getCause();
}
registerMBean(server2, networkRegistry, new ObjectName("remoting:type=NetworkRegistry"));
addNotificationListener(server2, new ObjectName("remoting:type=NetworkRegistry"), this);
port = TestUtil.getRandomPort();
locator2 = new InvokerLocator("socket://" + bindAddr + ":" + port);
log.info("InvokerLocator2: " + locator2);
Connector connector2 = new Connector(locator2);
ObjectName obj2 = new ObjectName("jboss.remoting:type=Connector,transport=" + locator2.getProtocol());
registerMBean(server2, connector2, obj2);
//connector2.create();
connector2.start();
MulticastDetector detector2 = new MulticastDetector();
registerMBean(server2, detector2, new ObjectName("remoting:type=MultiplexDetector"));
// set config info for detector and start it.
detector2.start();
log.info("Second set started.");
Thread.sleep(5000);
// should have detected both new locators
assertEquals(2, numOfAdded);
log.info("Stopping first set.");
connector1.stop();
connector1.destroy();
detector1.stop();
log.info("First set stopped.");
//DEBUG
// Thread.sleep(6000000);
Thread.sleep(15000);
// should have detected first set stopped
// thus leaving only one valid locator
assertEquals(1, numOfUpdated);
log.info("Stopping second set.");
connector2.stop();
connector2.destroy();
detector2.stop();
log.info("Stopped second set.");
Thread.sleep(15000);
// number of update locators should remain 1