Package org.jboss.remoting.detection.multicast

Examples of org.jboss.remoting.detection.multicast.MulticastDetector


      detector.stop();
   }

   public void testCallingStopTwice() throws Exception
   {
      MulticastDetector detector = new MulticastDetector();
      server.registerMBean(detector, objectName);
      detector.start();
      Thread.sleep(1000);

      server.unregisterMBean(objectName);
      detector.stop();
      detector.stop();
   }
View Full Code Here


      server1.registerMBean(networkRegistry, new ObjectName("remoting:type=NetworkRegistry"));

      server1.addNotificationListener(new ObjectName("remoting:type=NetworkRegistry"),
                                      this, null, null);

      MulticastDetector detector1 = new MulticastDetector();

      int port = TestUtil.getRandomPort();
      InvokerLocator locator1 = new InvokerLocator("socket://localhost:" + port);
      Connector connector1 = new Connector(locator1);
      ObjectName obj = new ObjectName("jboss.remoting:type=Connector,transport=" + locator1.getProtocol());
      server1.registerMBean(connector1, obj);
      //connector1.create();
      connector1.start();

      server1.registerMBean(detector1, new ObjectName("remoting:type=MultiplexDetector"));
      // set config info for detector and start it.
      detector1.start();

      System.out.println("First set started.");

      Thread.sleep(3000);

      System.out.println("Starting second set.");

      MBeanServer server2 = MBeanServerFactory.createMBeanServer();
      server2.registerMBean(networkRegistry, new ObjectName("remoting:type=NetworkRegistry"));
      server2.addNotificationListener(new ObjectName("remoting:type=NetworkRegistry"),
                                      this, null, null);

      MulticastDetector detector2 = new MulticastDetector();

      port = TestUtil.getRandomPort();
      InvokerLocator locator2 = new InvokerLocator("socket://localhost:" + port);
      Connector connector2 = new Connector(locator2);
      ObjectName obj2 = new ObjectName("jboss.remoting:type=Connector,transport=" + locator2.getProtocol());
      server2.registerMBean(connector2, obj2);
      //connector2.create();
      connector2.start();

      server2.registerMBean(detector2, new ObjectName("remoting:type=MultiplexDetector"));
      // set config info for detector and start it.
      detector2.start();

      System.out.println("Second set started.");

      Thread.sleep(5000);

      // should have detected both new locators
      assertEquals(2, numOfAdded);

      System.out.println("Stopping first set.");
      connector1.stop();
      connector1.destroy();
      detector1.stop();
      System.out.println("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);

      System.out.println("Stopping second set.");
      connector2.stop();
      connector2.destroy();
      detector2.stop();
      System.out.println("Stopped second set.");

      Thread.sleep(15000);

      // number of update locators should remain 1
View Full Code Here

      super(name);
   }

   public void testNotifications() throws Exception
   {
      MulticastDetector detector1 = new MulticastDetector();
      MulticastDetector detector2 = new MulticastDetector();

      Connector connector1 = new Connector();
      Connector connector2 = new Connector();

      NetworkRegistry reg1 = setupServers(detector1, connector1);
      TestNotificationListener notif1 = new TestNotificationListener();
      reg1.addNotificationListener(notif1, null, null);

      NetworkRegistry reg2 = setupServers(detector2, connector2);
      TestNotificationListener notif2 = new TestNotificationListener();
      reg2.addNotificationListener(notif2, null, null);

      // Need to allow heartbeat so have detection
      Thread.currentThread().sleep(5000);

      //Should now have an entry for both of the registries
      int reg1Count = reg1.getServers().length;
      int reg2Count = reg2.getServers().length;

      // Actual junit test
      assertTrue(reg1Count == 1 && reg2Count == 1);

      if(reg1Count == 1 && reg2Count == 1)
      {
         System.out.println("PASSED - both registries have found the detectors.");
      }
      else
      {
         System.out.println("FAILED - registries not populated with remote detectors.");
      }

      assertTrue(((String)notif1.notifLog.get(0)).startsWith("ADDED"));
      assertTrue(((String)notif1.notifLog.get(1)).startsWith("ADDED"));
      System.out.println("Notifications from Registry #1--->" + notif1.notifLog);
      assertTrue(((String)notif2.notifLog.get(0)).startsWith("ADDED"));
      assertTrue(((String)notif2.notifLog.get(1)).startsWith("ADDED"));
      System.out.println("Notifications from Registry #2--->" + notif2.notifLog);

      // stop the 2nd detector, so see if 1st one detects it is missing
      connector1.stop();
      connector1.destroy();
      connector1 = null;
      connector2.stop();
      connector2.destroy();
      connector2 = null;
      detector1.stop();

      // sleep for a few seconds so the 1st detector can discover 2nd one down
      Thread.sleep(60000);

      // 1st one should be empty
      reg1Count = reg2.getServers().length;

      // Actual junit test
      assertTrue(reg1Count == 0);

      if(reg1Count == 0)
      {
         System.out.println("PASSED - 2nd detector stopped and no longer in registry.");
      }
      else
      {
         System.out.println("FAILED - 2nd detector stopped but still in registry.");
      }

      assertTrue(((String)notif2.notifLog.get(0)).startsWith("ADDED"));
      assertTrue(((String)notif2.notifLog.get(1)).startsWith("ADDED"));
      assertTrue(((String)notif2.notifLog.get(2)).startsWith("REMOVED"));
      assertTrue(((String)notif2.notifLog.get(3)).startsWith("REMOVED"));
      System.out.println("Notifications from Registry #2-->" + notif2.notifLog);

      // cleanup
      detector2.stop();
      //connector2.stop();
      //connector2.destroy();
   }
View Full Code Here

      //connector2.destroy();
   }

   public void testDetectors() throws Exception
   {
      MulticastDetector detector1 = new MulticastDetector();
      MulticastDetector detector2 = new MulticastDetector();

      Connector connector1 = new Connector();
      Connector connector2 = new Connector();

      NetworkRegistry reg1 = setupServers(detector1, connector1);
      NetworkRegistry reg2 = setupServers(detector2, connector2);

      // Need to allow heartbeat so have detection
      Thread.currentThread().sleep(2000);

      //Should now have an entry for both of the registries
      int reg1Count = reg1.getServers().length;
      int reg2Count = reg2.getServers().length;

      // Actual junit test
      assertTrue(reg1Count == 1 && reg2Count == 1);

      if(reg1Count == 1 && reg2Count == 1)
      {
         System.out.println("PASSED - both registries have found the detectors.");
      }
      else
      {
         System.out.println("FAILED - registries not populated with remote detectors.");
      }

      // stop the 2nd detector, so see if 1st one detects it is missing
      connector1.stop();
      connector1.destroy();
      connector1 = null;
      connector2.stop();
      connector2.destroy();
      connector2 = null;
      detector1.stop();

      // sleep for a few seconds so the 1st detector can discover 2nd one down
      Thread.currentThread().sleep(60000);

      // 1st one should be empty
      reg1Count = reg2.getServers().length;

      // Actual junit test
      assertTrue(reg1Count == 0);

      if(reg1Count == 0)
      {
         System.out.println("PASSED - 2nd detector stopped and no longer in registry.");
      }
      else
      {
         System.out.println("FAILED - 2nd detector stopped but still in registry.");
      }

      // cleanup
      detector2.stop();
      //connector2.stop();
      //connector2.destroy();
   }
View Full Code Here

   private Connector connector;
   private NetworkRegistry registry;

   public void setUp() throws Exception
   {
      detector = new MulticastDetector();

      System.setProperty("jboss.identity", String.valueOf(System.currentTimeMillis()));
      System.out.println("jboss.identity = " + System.getProperty("jboss.identity"));

      MBeanServer server = MBeanServerFactory.createMBeanServer();
View Full Code Here

   private NetworkRegistry registry;
   private Map config = new HashMap();

   public void setUp() throws Exception
   {
      detector = new MulticastDetector();

      System.setProperty("jboss.identity", String.valueOf(System.currentTimeMillis()));
      System.out.println("jboss.identity = " + System.getProperty("jboss.identity"));

      MBeanServer server = MBeanServerFactory.createMBeanServer();
View Full Code Here

   private MulticastDetector detector;
   private NetworkRegistry registry;

   public void setUp() throws Exception
   {
      detector = new MulticastDetector();

      System.setProperty("jboss.identity", String.valueOf(System.currentTimeMillis()));
      System.out.println("jboss.identity = " + System.getProperty("jboss.identity"));

      MBeanServer server = MBeanServerFactory.createMBeanServer();
View Full Code Here

      org.apache.log4j.BasicConfigurator.configure();
      org.apache.log4j.Category.getRoot().setLevel(Level.DEBUG);
      org.apache.log4j.Category.getInstance("org.jboss.remoting").setLevel(Level.DEBUG);
      org.apache.log4j.Category.getInstance("org.jgroups").setLevel(Level.FATAL);

      MulticastDetector detector1 = new MulticastDetector();
      MulticastDetector detector2 = new MulticastDetector();

      Connector connector1 = new Connector();
      Connector connector2 = new Connector();

      NetworkRegistry reg1 = setupServers(detector1, connector1);
      // need to register with the mbean server for notifications
      List mbeanServers = MBeanServerFactory.findMBeanServer(null);
      MBeanServer mbeanSvr = (MBeanServer) mbeanServers.get(0);
      mbeanSvr.addNotificationListener(new ObjectName("remoting:type=NetworkRegistry"),
                                       this, null, null);

      NetworkRegistry reg2 = setupServers(detector2, connector2);

      // Need to allow heartbeat so have detection
      Thread.currentThread().sleep(2000);

      //Should now have an entry for both of the registries
      int reg1Count = reg1.getServers().length;
      int reg2Count = reg2.getServers().length;

      // Actual junit test
      assertTrue(reg1Count == 1 && reg2Count == 1);

      if(reg1Count == 1 && reg2Count == 1)
      {
         System.out.println("PASSED - both registries have found the detectors.");
      }
      else
      {
         System.out.println("FAILED - registries not populated with remote detectors.");
      }

      // now check to make sure got the subsystem as expected
      assertEquals("MOCK", subSystem);

      // stop the 2nd detector, so see if 1st one detects it is missing
      connector1.stop();
      connector1.destroy();
      connector1 = null;
      connector2.stop();
      connector2.destroy();
      connector2 = null;
      detector1.stop();
      detector2.stop();
      //connector2.stop();
      //connector2.destroy();
   }
View Full Code Here

   private Client remotingClient = null;

   public void setUp() throws Exception
   {
      detector = new MulticastDetector();

      System.setProperty("jboss.identity", String.valueOf(System.currentTimeMillis()));
      System.out.println("jboss.identity = " + System.getProperty("jboss.identity"));

      MBeanServer server = MBeanServerFactory.createMBeanServer();
View Full Code Here

      {
         // we need an MBeanServer to store our network registry and multicast detector services
         MBeanServer server = createMBeanServer();

         // multicast detector will detect new network registries that come online
         MulticastDetector detector = new MulticastDetector();
         services.setup(server, detector, null, null, null, true, false);
         detector.start();
      }
      else if (services.getDetector() == null)
      {
         // the internal services singleton is already setup, make sure it has a detector because we need it
         MulticastDetector detector = new MulticastDetector();
         services.assignDetector(detector, null, true);
         detector.start();
      }

      return;
   }
View Full Code Here

TOP

Related Classes of org.jboss.remoting.detection.multicast.MulticastDetector

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.