Package org.jboss.remoting.network

Examples of org.jboss.remoting.network.NetworkRegistry


         MBeanServer server = MBeanServerFactory.createMBeanServer();

         System.out.println("my identity is: " + Identity.get(server));


         NetworkRegistry registry = NetworkRegistry.getInstance();
         server.registerMBean(registry, new ObjectName("remoting:type=NetworkRegistry"));

         //int port = PortUtil.findFreePort();

         Connector connector = new Connector();
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();
            services.assignNetworkRegistry(registry, null, true);
         }
      }

      return;
View Full Code Here

    */
   private boolean findAlternativeTarget()
   {
      boolean failover = false;
      ArrayList availableList = new ArrayList();
      NetworkRegistry registry = InternalTransporterServices.getInstance().getNetworkRegistry();
      if (registry != null)
      {
         NetworkInstance[] instances = registry.getServers();
         if (instances != null)
         {
            for (int x = 0; x < instances.length; x++)
            {
               NetworkInstance netInstance = instances[x];
View Full Code Here

         System.setProperty("jboss.identity", String.valueOf(System.currentTimeMillis()));

         MBeanServer server = MBeanServerFactory.createMBeanServer();

         NetworkRegistry registry = NetworkRegistry.getInstance();
         server.registerMBean(registry, new ObjectName("remoting:type=NetworkRegistry"));

         InvokerLocator locator = new InvokerLocator("socket://localhost");
         //ClassLoader clsLoader = Thread.currentThread().getContextClassLoader();
         //SocketServerInvoker invokerSvr = new SocketServerInvoker(clsLoader, locator);
         //ObjectName objName = new ObjectName("jboss.remoting:type=SocketServerInvoker");
         //server.registerMBean(invokerSvr, objName);
         //invokerSvr.start();

         Connector connector = new Connector();
         connector.setInvokerLocator(locator.getLocatorURI());
         ObjectName obj = new ObjectName("jboss.remoting:type=Connector,transport=" + locator.getProtocol());
         server.registerMBean(connector, obj);
         //connector.create();
         connector.start();

         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))
         {
            JNDIDetector jdet = new JNDIDetector();
            jdet.setPort(port);
            jdet.setHost(host);
            jdet.setContextFactory(contextFactory);
            jdet.setURLPackage(urlPackage);
            detector = jdet;
            objName = new ObjectName("remoting:type=Detector,transport=jndi");
         }

         server.registerMBean(detector, objName);
         detector.start();
         System.err.println("Starting Detector");

         while(true)
         {
            Thread.currentThread().sleep(3000);
            NetworkInstance[] instances = registry.getServers();
            for(int x = 0; x < instances.length; x++)
            {
               log.debug(instances[x]);
            }
         }
View Full Code Here

     * @throws Exception if failed to create or register all the services successfully
     */
    private void setupDetector() throws Exception {
        // the network registry listens for other servers coming online and going offline
        // we will also register this service container as a listener to the registry so it can be told about servers coming and going
        m_registry = new NetworkRegistry();

        // under very rare conditions (specifically, the hostname on the box is not resolvable via DNS), the remoting
        // identity generation will fail.  If it fails, we will generate our own jboss.identity here
        try {
            Identity.get(m_mbs);
View Full Code Here

            MBeanServer server = MBeanServerFactory.createMBeanServer();

            System.out.println("my identity is: "+Identity.get(server));


            NetworkRegistry registry = NetworkRegistry.getInstance();
            server.registerMBean(registry, new ObjectName("remoting:type=NetworkRegistry"));

            int port = PortUtil.findFreePort("localhost");

            Connector connector = new Connector();
View Full Code Here

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

      // the registry will house all remoting servers discovered
      NetworkRegistry registry = NetworkRegistry.getInstance();
      server.registerMBean(registry, new ObjectName("remoting:type=NetworkRegistry"));
      println("NetworkRegistry has been created");

      // register class as listener, so know when new server found
      registry.addNotificationListener(this, null, null);
      println("NetworkRegistry has added the client as a listener");

      // multicast detector will detect new network registries that come online
      MulticastDetector detector = new MulticastDetector();
      server.registerMBean(detector, new ObjectName("remoting:type=MulticastDetector"));
View Full Code Here

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

      // the registry will house all remoting servers discovered
      NetworkRegistry registry = NetworkRegistry.getInstance();
      server.registerMBean(registry, new ObjectName("remoting:type=NetworkRegistry"));
      log.info("NetworkRegistry has been created");

      // register class as listener, so know when new server found
      registry.addNotificationListener(this, null, null);
      log.info("NetworkRegistry has added the client as a listener");

      String detectorHost = InetAddress.getLocalHost().getHostName();
     
      // jndi detector will detect new network registries that come online
View Full Code Here

//      org.apache.log4j.Category.getInstance("org.jgroups").setLevel(Level.FATAL);


      MBeanServer server1 = MBeanServerFactory.createMBeanServer();

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

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

      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)
View Full Code Here

TOP

Related Classes of org.jboss.remoting.network.NetworkRegistry

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.