Package org.jboss.remoting.transport

Examples of org.jboss.remoting.transport.Connector


      serverLocator = new InvokerLocator(locatorURI);
      log.info("Starting remoting server with locator uri of: " + locatorURI);
      HashMap config = new HashMap();
      config.put(InvokerLocator.FORCE_REMOTE, "true");
      addExtraServerConfig(config);
      connector = new Connector(serverLocator, config);
      connector.create();
      invocationHandler = new TestInvocationHandler();
      connector.addInvocationHandler("test", invocationHandler);
      connector.setLeasePeriod(LEASE_PERIOD);
      serverConnectionListener = new TestConnectionListener("serverConnectionListener");
View Full Code Here


      serverLocator = new InvokerLocator(locatorURI);
      log.info("Starting remoting server with locator uri of: " + locatorURI);
      HashMap config = new HashMap();
      config.put(InvokerLocator.FORCE_REMOTE, "true");
      addExtraServerConfig(config);
      connector = new Connector(serverLocator, config);
      connector.create();
      invocationHandler = new TestInvocationHandler();
      connector.addInvocationHandler("test", invocationHandler);
      connector.start();
   }
View Full Code Here

      serverLocator = new InvokerLocator(locatorURI);
      log.info("Starting remoting server with locator uri of: " + locatorURI);
      HashMap config = new HashMap();
      config.put(InvokerLocator.FORCE_REMOTE, "true");
      addExtraServerConfig(config);
      connector = new Connector(serverLocator, config);
      connector.create();
      invocationHandler = new TestInvocationHandler();
      connector.addInvocationHandler("test", invocationHandler);
      connector.start();
   }
View Full Code Here

         String locatorURI = "socket://" + host + ":" + port;
         InvokerLocator locator = new InvokerLocator(locatorURI);
         HashMap serverConfig = new HashMap();
         serverConfig.put(ServerInvoker.MAX_NUM_ONEWAY_THREADS_KEY, "3");
         serverConfig.put(ServerInvoker.MAX_ONEWAY_THREAD_POOL_QUEUE_SIZE, "5");
         Connector connector = new Connector(locator, serverConfig);
         connector.create();
         TestHandler handler = new TestHandler();
         connector.addInvocationHandler("test", handler);
         connector.start();
        
         HashMap clientConfig = new HashMap();
         clientConfig.put(InvokerLocator.FORCE_REMOTE, "true");
         clientConfig.put(Client.MAX_NUM_ONEWAY_THREADS, "7");
         clientConfig.put(Client.MAX_ONEWAY_THREAD_POOL_QUEUE_SIZE, "9");
         Client client = new Client(locator, clientConfig);
         client.connect();
        
         client.invokeOneway(FAST, null, true);
         client.invokeOneway(FAST, null, false);
         poolCounter += 2;
         Thread.sleep(1000);
         assertEquals(2, handler.startedCount);
        
         Field field = ServerInvoker.class.getDeclaredField("onewayThreadPool");
         field.setAccessible(true);
         BasicThreadPool pool = (BasicThreadPool) field.get(connector.getServerInvoker());
         assertEquals(3, pool.getMaximumPoolSize());
         assertEquals(5, pool.getMaximumQueueSize());
        
         field = Client.class.getDeclaredField("onewayThreadPool");
         field.setAccessible(true);
         pool = (BasicThreadPool) field.get(client);
         assertEquals(7, pool.getMaximumPoolSize());
         assertEquals(9, pool.getMaximumQueueSize());
        
         client.disconnect();
         connector.stop();
         log.info(getName() + " PASSES");
   }
View Full Code Here

      log.info("entering " + getName());
      String host = InetAddress.getLocalHost().getHostAddress();
      int port = PortUtil.findFreePort(host);
      String locatorURI = "http://" + host + ":" + port;
      InvokerLocator locator = new InvokerLocator(locatorURI);
      Connector connector = new Connector(locator);
      connector.create();
      TestHandler handler = new TestHandler();
      connector.addInvocationHandler("test", handler);
      connector.start();
     
      HashMap config = new HashMap();
      config.put(InvokerLocator.FORCE_REMOTE, "true");
      config.put(Client.MAX_NUM_ONEWAY_THREADS, "2");
      config.put(Client.MAX_ONEWAY_THREAD_POOL_QUEUE_SIZE, "1");
      Client client = new Client(locator, config);
      client.connect();
     
      Object response = client.invoke(FAST);
      assertEquals(FAST, response);
     
      long start = System.currentTimeMillis();
     
      // This invocation should run in pooled thread 1.
      log.info("making 1st oneway invocation");
      client.invokeOneway(SLOW + "1", null, true);
      poolCounter++;
     
      // This invocation should run in pooled thread 2.
      log.info("making 2nd oneway invocation");
      client.invokeOneway(SLOW + "2", null, true);
     
      // This invocation should go into the queue.
      log.info("making 3rd oneway invocation");
      client.invokeOneway(SLOW + "3", null, true);
      assertTrue((System.currentTimeMillis() - start < 1000));
      Thread.sleep(2000);
      log.info("handler.count: " + handler.startedCount);
      assertEquals(3, handler.startedCount);
     
      // This invocation should run in the current thread, and will not return
      // until after a response is received.
      start = System.currentTimeMillis();
      log.info("making 4th oneway invocation");
      client.invokeOneway(SLOW + "4", null, true);
      log.info("made 4th oneway invocation");
      log.info("wait: " + (System.currentTimeMillis() - start));
      assertTrue((System.currentTimeMillis() - start >= 5000));
     
      Thread.sleep(12000);
      assertEquals(5, handler.startedCount);
     
      client.disconnect();
      connector.stop();
      log.info(getName() + " PASSES");
   }
View Full Code Here

      log.info("entering " + getName());
      String host = InetAddress.getLocalHost().getHostAddress();
      int port = PortUtil.findFreePort(host);
      String locatorURI = "socket://" + host + ":" + port;
      InvokerLocator locator = new InvokerLocator(locatorURI);
      Connector connector = new Connector(locator);
      connector.create();
      TestHandler handler = new TestHandler();
      connector.addInvocationHandler("test", handler);
      connector.start();
     
      HashMap config = new HashMap();
      config.put(InvokerLocator.FORCE_REMOTE, "true");
      config.put(Client.MAX_NUM_ONEWAY_THREADS, "2");
      config.put(Client.MAX_ONEWAY_THREAD_POOL_QUEUE_SIZE, "1");
      Client client = new Client(locator, config);
      client.connect();
     
      Object response = client.invoke(FAST);
      assertEquals(FAST, response);
     
      long start = System.currentTimeMillis();
     
      // The following four invocations are quite nondeterministic.  In the best
      // case, two will execute in the thread pool and two will execute simultaneously
      // in ServerThreads.  In the worst case, the last three invocations will
      // find a pooled connection and connect to a ServerThread busy with the
      // previous invocation.
     
      // Will execute in first thread pool thread.
      log.info("making 1st oneway invocation");
      client.invokeOneway(SLOW + "1", null, true);
      poolCounter++;
     
      // Will execute in first or second thread pool thread.
      log.info("making 2nd oneway invocation");
      client.invokeOneway(SLOW + "2", null, true);
     
      // Could execute in a thread pool thread or go on the queue.
      log.info("making 3rd oneway invocation");
      client.invokeOneway(SLOW + "3", null, true);
      assertTrue((System.currentTimeMillis() - start < 1000));
     
      // Could execute in a thread pool thread, go on the queue, or execute
      // in the main thread.
      log.info("making 4th oneway invocation");
      client.invokeOneway(SLOW + "4", null, true);
      log.info("made 4th oneway invocation");
      log.info("wait: " + (System.currentTimeMillis() - start));
      assertTrue((System.currentTimeMillis() - start < 1000));
     
      // In the worst case, the four invocations could take as much as 15 seconds
      // to all start.
      Thread.sleep(16000);
      assertEquals(5, handler.startedCount);
     
      client.disconnect();
      connector.stop();
      log.info(getName() + " PASSES");
   }
View Full Code Here

      log.info("entering " + getName());
      String host = InetAddress.getLocalHost().getHostAddress();
      int port = PortUtil.findFreePort(host);
      String locatorURI = "http://" + host + ":" + port;
      InvokerLocator locator = new InvokerLocator(locatorURI);
      Connector connector = new Connector(locator);
      connector.create();
      TestHandler handler = new TestHandler();
      connector.addInvocationHandler("test", handler);
      connector.start();
     
      HashMap config = new HashMap();
      config.put(InvokerLocator.FORCE_REMOTE, "true");
      config.put(Client.MAX_NUM_ONEWAY_THREADS, "100");
      config.put(Client.MAX_ONEWAY_THREAD_POOL_QUEUE_SIZE, "100");
      Client client = new Client(locator, config);
      client.connect();
     
      int INVOCATIONS = 400;
      OnewayThread[] threads = new OnewayThread[INVOCATIONS];
     
      for (int i = 0; i < INVOCATIONS; i++)
      {
         threads[i] = new OnewayThread(client, i, true);
         threads[i].start();
      }
     
      go = true;
      poolCounter++;
      Thread.sleep(5000);
     
      // Verify INVOCATIONS invocations were received.
      assertEquals(INVOCATIONS, handler.startedCount);
     
      // Verify only one thread pool was created.
      Field field = Client.class.getDeclaredField("onewayThreadPool");
      field.setAccessible(true);
      Object pool = field.get(client);
      assertTrue(pool instanceof BasicThreadPool);
      BasicThreadPool basicThreadPool = (BasicThreadPool) pool;
      assertEquals(poolCounter, basicThreadPool.getPoolNumber());
     
      for (int i = 0; i < INVOCATIONS; i++)
      {
         assertTrue("failure in thread: " + i, threads[i].ok);
      }
     
      client.disconnect();
      connector.stop();
      log.info(getName() + " PASSES");
   }
View Full Code Here

      log.info("entering " + getName());
      String host = InetAddress.getLocalHost().getHostAddress();
      int port = PortUtil.findFreePort(host);
      String locatorURI = "socket://" + host + ":" + port;
      InvokerLocator locator = new InvokerLocator(locatorURI);
      Connector connector = new Connector(locator);
      connector.create();
      TestHandler handler = new TestHandler();
      connector.addInvocationHandler("test", handler);
      connector.start();
     
      HashMap config = new HashMap();
      config.put(InvokerLocator.FORCE_REMOTE, "true");
      config.put(Client.MAX_NUM_ONEWAY_THREADS, "100");
      config.put(Client.MAX_ONEWAY_THREAD_POOL_QUEUE_SIZE, "100");
      Client client = new Client(locator, config);
      client.connect();
     
      int INVOCATIONS = 1000;
      OnewayThread[] threads = new OnewayThread[INVOCATIONS];
     
      for (int i = 0; i < INVOCATIONS; i++)
      {
         threads[i] = new OnewayThread(client, i, true);
         threads[i].start();
      }
     
      go = true;
      poolCounter++;
      Thread.sleep(5000);
     
      // Verify INVOCATIONS invocations were received.
      assertEquals(INVOCATIONS, handler.startedCount);
     
      // Verify only one thread pool was created.
      Field field = Client.class.getDeclaredField("onewayThreadPool");
      field.setAccessible(true);
      Object pool = field.get(client);
      assertTrue(pool instanceof BasicThreadPool);
      BasicThreadPool basicThreadPool = (BasicThreadPool) pool;
      assertEquals(poolCounter, basicThreadPool.getPoolNumber());
     
      for (int i = 0; i < INVOCATIONS; i++)
      {
         assertTrue("failure in thread: " + i, threads[i].ok);
      }
     
      client.disconnect();
      connector.stop();
      log.info(getName() + " PASSES");
   }
View Full Code Here

      String locatorURI = "http://" + host + ":" + port;
      InvokerLocator locator = new InvokerLocator(locatorURI);
      HashMap serverConfig = new HashMap();
      serverConfig.put(ServerInvoker.MAX_NUM_ONEWAY_THREADS_KEY, "2");
      serverConfig.put(ServerInvoker.MAX_ONEWAY_THREAD_POOL_QUEUE_SIZE, "1");
      Connector connector = new Connector(locator, serverConfig);
      connector.create();
      TestHandler handler = new TestHandler();
      connector.addInvocationHandler("test", handler);
      connector.start();
     
      HashMap clientConfig = new HashMap();
      clientConfig.put(InvokerLocator.FORCE_REMOTE, "true");
      Client client = new Client(locator, clientConfig);
      client.connect();
     
      Object response = client.invoke(FAST);
      assertEquals(FAST, response);
     
      long start = System.currentTimeMillis();
     
      // This invocation should run in pooled thread 1.
      log.info("making 1st oneway invocation");
      client.invokeOneway(SLOW + "1", null, false);
      poolCounter++;
     
      // Wait for connection to return to pool.
      Thread.sleep(500);
     
      // This invocation should run in pooled thread 2.
      log.info("making 2nd oneway invocation");
      client.invokeOneway(SLOW + "2", null, false);
     
      // Wait for connection to return to pool.
      Thread.sleep(500);
     
      // This invocation should use the pooled connection and go into the queue.
      log.info("making 3rd oneway invocation");
      client.invokeOneway(SLOW + "3", null, false);
      assertTrue((System.currentTimeMillis() - start < 2000));
      Thread.sleep(2000);
      log.info("handler.count: " + handler.startedCount);
      assertEquals(3, handler.startedCount);
     
      // This invocation should run in the ServerThread, and will not return
      // until after a response is received.
      log.info("making 4th oneway invocation");
      client.invokeOneway(SLOW + "4", null, false);
      log.info("made 4th oneway invocation");
      log.info("wait: " + (System.currentTimeMillis() - start));
      assertTrue((System.currentTimeMillis() - start >= 8000));
     
      // By the time the 4th oneway invocation returns, the 3rd oneway invocation
      // should have started.
      assertEquals(5, handler.startedCount);
      assertEquals(4, handler.finishedCount);
     
      Thread.sleep(3000);
      assertEquals(5, handler.finishedCount);
     
      client.disconnect();
      connector.stop();
      log.info(getName() + " PASSES");
   }
View Full Code Here

      serverLocator = new InvokerLocator(locatorURI);
      log.info("Starting remoting server with locator uri of: " + locatorURI);
      HashMap config = new HashMap();
      config.put(InvokerLocator.FORCE_REMOTE, "true");
      addExtraServerConfig(config);
      connector = new Connector(serverLocator, config);
      connector.create();
      invocationHandler = new TestInvocationHandler();
      connector.addInvocationHandler("test", invocationHandler);
      connector.start();
   }
View Full Code Here

TOP

Related Classes of org.jboss.remoting.transport.Connector

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.