Package org.jboss.remoting.detection.multicast

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


/* 123 */       Detector detector = null;
/* 124 */       ObjectName objName = null;
/*     */
/* 126 */       if (this.type.equals("multicast"))
/*     */       {
/* 128 */         MulticastDetector mdet = new MulticastDetector();
/* 129 */         mdet.setPort(this.port);
/* 130 */         detector = mdet;
/* 131 */         objName = new ObjectName("remoting:type=Detector,transport=multicast");
/*     */       }
/* 133 */       else if (this.type.equals("jndi"))
/*     */       {
View Full Code Here


/*     */
/* 216 */     if (!services.isSetup())
/*     */     {
/* 219 */       MBeanServer server = MBeanServerFactory.createMBeanServer();
/*     */
/* 222 */       MulticastDetector detector = new MulticastDetector();
/* 223 */       services.setup(server, detector, null, null, null, true, false);
/* 224 */       detector.start();
/*     */     }
/* 226 */     else if (services.getDetector() == null)
/*     */     {
/* 229 */       MulticastDetector detector = new MulticastDetector();
/* 230 */       services.assignDetector(detector, null, true);
/* 231 */       detector.start();
/*     */     }
/*     */   }
View Full Code Here

/*  64 */     println("NetworkRegistry has been created");
/*     */
/*  67 */     registry.addNotificationListener(this, null, null);
/*  68 */     println("NetworkRegistry has added the client as a listener");
/*     */
/*  71 */     MulticastDetector detector = new MulticastDetector();
/*  72 */     server.registerMBean(detector, new ObjectName("remoting:type=MulticastDetector"));
/*  73 */     detector.start();
/*  74 */     println("MulticastDetector has been created and is listening for new NetworkRegistries to come online");
/*     */   }
View Full Code Here

/*     */   public void setupDetector()
/*     */     throws Exception
/*     */   {
/*  60 */     MBeanServer server = MBeanServerFactory.createMBeanServer();
/*     */
/*  63 */     MulticastDetector detector = new MulticastDetector();
/*  64 */     server.registerMBean(detector, new ObjectName("remoting:type=MulticastDetector"));
/*  65 */     detector.start();
/*  66 */     println("MulticastDetector has been created and is listening for new NetworkRegistries to come online");
/*     */   }
View Full Code Here

      TestNetworkRegistry networkRegistry = new TestNetworkRegistry(locator);
      ObjectName name = new ObjectName("test:type=TestNetworkRegistry");
      server.registerMBean(networkRegistry, name);
     
      // Create detector and tell it to register local Connectors.
      MulticastDetector detector = new MulticastDetector();
      StringBuffer buf = new StringBuffer();
      buf.append("<?xml version=\"1.0\"?>\n");
      buf.append("<local/>");
      ByteArrayInputStream bais = new ByteArrayInputStream(buf.toString().getBytes());
      Document xml = DocumentBuilderFactory.newInstance().newDocumentBuilder().parse(bais);
      detector.setConfiguration(xml.getDocumentElement());
      server.registerMBean(detector, new ObjectName("test:type=MulticastDetector"));
      detector.start();

      // Verify that TestNetworkRegistry proxy gets used.
      detector.forceDetection();
      assertEquals(1, networkRegistry.counter);
      int counter = ((Integer) server.getAttribute(name, "Counter")).intValue();
      assertEquals(networkRegistry.counter, counter);
     
      detector.stop();
      server.unregisterMBean(name);
      shutdownServer();
      log.info(getName() + " PASSES");
   }
View Full Code Here

      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
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 = null;
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 = 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

      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

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.