Examples of MulticastDetector


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

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

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

         if (services.getNetworkRegistry() == null)
         {
            NetworkRegistry registry = NetworkRegistry.getInstance();
View Full Code Here

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

      org.apache.log4j.BasicConfigurator.configure();
      org.apache.log4j.Category.getRoot().setLevel(Level.DEBUG);
      org.apache.log4j.Category.getInstance("org.jboss.remoting").setLevel(XLevel.TRACE);
      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();
     
      try
      {
         NetworkRegistry reg1 = setupServers(detector1, connector1);
         // need to register with the mbean server for notifications
         List mbeanServers = (List) AccessController.doPrivileged( new PrivilegedAction()
         {
            public Object run()
            {
               return 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;
         System.out.println("registry 1: " + reg1Count);
         System.out.println("registry 2: " + reg2Count);
        
         if(reg1Count >= 1 && reg2Count >= 1)
         {
            System.out.println("PASSED - both registries have found detectors.");
         }
         else
         {
            System.out.println("FAILED - registries not populated with remote detectors.");
         }

         // Actual junit test
         assertTrue(reg1Count >= 1 && reg2Count >= 1);
        
         // Verify the Connectors created by this test have been detected.
         checkForConnector(reg1);
         checkForConnector(reg2);

         // now check to make sure got the subsystem as expected
         assertTrue(subSystems.contains("MOCK"));
      }
      finally
      {
         // stop the 2nd detector, so see if 1st one detects it is missing
         if (connector1 != null)
         {
            connector1.stop();
            connector1.destroy();
            connector1 = null;
         }
         if (connector2 != null)
         {
            connector2.stop();
            connector2.destroy();
            connector2 = null;
         }
         if (detector1 != null) detector1.stop();
         if (detector2 != null) detector2.stop();
      }
      //connector2.stop();
      //connector2.destroy();
   }
View Full Code Here

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

      super.tearDown();
   }

   public void testStopWithoutStart() throws Exception
   {
      MulticastDetector detector = new MulticastDetector();
      server.registerMBean(detector, objectName);
// don't call detector.start();
      Thread.sleep(1000);

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

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

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

      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

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

      //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

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

   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

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

   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

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

         Detector detector = null;
         ObjectName objName = null;

         if(type.equals(TYPE_MULTICAST))
         {
            MulticastDetector mdet = new MulticastDetector();
            mdet.setPort(port);
            detector = mdet;
            objName = new ObjectName("remoting:type=Detector,transport=multicast");
         }
         else if(type.equals(TYPE_JNDI))
         {
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. 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.