Package org.jboss.remoting.transport

Examples of org.jboss.remoting.transport.Connector


      assertTrue(client.getInvoker() instanceof BisocketClientInvoker);
      log.info("client is connected");
     
      String callbackLocatorURI = getTransport() + "://" + host + ":1";
      config.put(Bisocket.IS_CALLBACK_SERVER, "true");
      Connector callbackConnector = new Connector(callbackLocatorURI, config);
      callbackConnector.start();
      DelayedCallbackHandler callbackHandler = new DelayedCallbackHandler();
      client.addListener(callbackHandler, new InvokerLocator(callbackLocatorURI));
      assertEquals(1, invocationHandler.callbackHandlers.size());
      log.info("client added callback handler");
     
      client.invokeOneway(CALLBACK_TEST);
      client.invokeOneway(CALLBACK_TEST);
      client.invokeOneway(CALLBACK_TEST);
      Thread.sleep(500);
      assertEquals(3, callbackHandler.callbackCounter);
     
      Iterator it = invocationHandler.callbackHandlers.iterator();
      ServerInvokerCallbackHandler serverInvokerCallbackHandler = (ServerInvokerCallbackHandler) it.next();
      Client callbackClient = serverInvokerCallbackHandler.getCallbackClient();
      assertTrue(callbackClient.getInvoker() instanceof BisocketClientInvoker);
      MicroSocketClientInvoker clientInvoker = (MicroSocketClientInvoker) callbackClient.getInvoker();
      Field field = MicroSocketClientInvoker.class.getDeclaredField("pool");
      field.setAccessible(true);
      List pool = (List) field.get(clientInvoker);
//      field = MicroSocketClientInvoker.class.getDeclaredField("usedPooled");
      field.setAccessible(true);
      assertEquals(0, pool.size());
//      Long usedPooled = (Long) field.get(clientInvoker);
//      assertEquals(3, usedPooled.intValue());
      assertEquals(3, clientInvoker.getNumberOfUsedConnections());
     
      Thread.sleep(3000);
      assertEquals(3, pool.size());
//      usedPooled = (Long) field.get(clientInvoker);
//      assertEquals(0, usedPooled.intValue());
      assertEquals(0, clientInvoker.getNumberOfUsedConnections());
     
      client.removeListener(callbackHandler);
      client.disconnect();
      callbackConnector.stop();
   }
View Full Code Here


      log.info("client is connected");
      assertTrue(client.getInvoker() instanceof BisocketClientInvoker);
     
      String callbackLocatorURI = getTransport() + "://" + host + ":1";
      config.put(Bisocket.IS_CALLBACK_SERVER, "true");
      Connector callbackConnector = new Connector(callbackLocatorURI, config);
      callbackConnector.start();
     
      DelayedCallbackHandler callbackHandler1 = new DelayedCallbackHandler();
      client.addListener(callbackHandler1, new InvokerLocator(callbackLocatorURI));
      DelayedCallbackHandler callbackHandler2 = new DelayedCallbackHandler();
      client.addListener(callbackHandler2, new InvokerLocator(callbackLocatorURI));
      assertEquals(2, invocationHandler.callbackHandlers.size());
      log.info("clients added callback handler");
     
      Iterator it = invocationHandler.callbackHandlers.iterator();
      ServerInvokerCallbackHandler serverInvokerCallbackHandler1 = (ServerInvokerCallbackHandler) it.next();
      ServerInvokerCallbackHandler serverInvokerCallbackHandler2 = (ServerInvokerCallbackHandler) it.next();
     
      Client callbackClient1 = serverInvokerCallbackHandler1.getCallbackClient();
      Client callbackClient2 = serverInvokerCallbackHandler2.getCallbackClient();
      assertNotSame(callbackClient1, callbackClient2);
 
      ClientInvoker clientInvoker1 = callbackClient1.getInvoker();
      assertTrue(clientInvoker1 instanceof BisocketClientInvoker);
      ClientInvoker clientInvoker2 = callbackClient2.getInvoker();
      assertTrue(clientInvoker2 instanceof BisocketClientInvoker);
      assertNotSame(clientInvoker1, clientInvoker2);
     
      Field field = MicroSocketClientInvoker.class.getDeclaredField("pool");
      field.setAccessible(true);
      List pool1 = (List) field.get(clientInvoker1);
      List pool2 = (List) field.get(clientInvoker2);
      assertNotSame(pool1, pool2);
     
//      field = MicroSocketClientInvoker.class.getDeclaredField("usedPooled");
//      field.setAccessible(true);
     
      assertEquals(0, callbackHandler1.callbackCounter);
      assertEquals(0, callbackHandler2.callbackCounter);
      assertEquals(0, pool1.size());
      assertEquals(0, pool2.size());
//      Long usedPooled1 = (Long) field.get(clientInvoker1);
//      Long usedPooled2 = (Long) field.get(clientInvoker2);
      assertEquals(0, ((MicroSocketClientInvoker) clientInvoker1).getNumberOfUsedConnections());
      assertEquals(0, ((MicroSocketClientInvoker) clientInvoker2).getNumberOfUsedConnections());
      client.invokeOneway(CALLBACK_TEST);
      client.invokeOneway(CALLBACK_TEST);
     
      Thread.sleep(500);
      int count1 = callbackHandler1.callbackCounter;
      int count2 = callbackHandler2.callbackCounter;
      assertTrue(count1 == 2 && count2 == 0 || count1 == 0 && count2 == 2);
      if (count1 == 0)
      {
         Object temp = callbackHandler1;
         callbackHandler1 = callbackHandler2;
         callbackHandler2 = (DelayedCallbackHandler) temp;;
      }
     
      assertEquals(2, callbackHandler1.callbackCounter);
      assertEquals(0, callbackHandler2.callbackCounter);
      assertEquals(0, pool1.size());
      assertEquals(0, pool2.size());
//      usedPooled1 = (Long) field.get(clientInvoker1);
//      usedPooled2 = (Long) field.get(clientInvoker2);
//      assertEquals(2, usedPooled1.longValue());
//      assertEquals(0, usedPooled2.longValue());
      assertEquals(2, ((MicroSocketClientInvoker) clientInvoker1).getNumberOfUsedConnections());
      assertEquals(0, ((MicroSocketClientInvoker) clientInvoker2).getNumberOfUsedConnections());
     
      Thread.sleep(2000);
      assertEquals(2, callbackHandler1.callbackCounter);
      assertEquals(2, callbackHandler2.callbackCounter);
      assertEquals(2, pool1.size());
      assertEquals(0, pool2.size());
//      usedPooled1 = (Long) field.get(clientInvoker1);
//      usedPooled2 = (Long) field.get(clientInvoker2);
//      assertEquals(0, usedPooled1.intValue());
//      assertEquals(2, usedPooled2.intValue());
      assertEquals(0, ((MicroSocketClientInvoker) clientInvoker1).getNumberOfUsedConnections());
      assertEquals(2, ((MicroSocketClientInvoker) clientInvoker2).getNumberOfUsedConnections());
     
      Thread.sleep(2000);
      assertEquals(2, callbackHandler1.callbackCounter);
      assertEquals(2, callbackHandler2.callbackCounter);
      assertEquals(2, pool1.size());
      assertEquals(2, pool2.size());
//      usedPooled1 = (Long) field.get(clientInvoker1);
//      usedPooled2 = (Long) field.get(clientInvoker2);
//      assertEquals(0, usedPooled1.intValue());
//      assertEquals(0, usedPooled2.intValue());
      assertEquals(0, ((MicroSocketClientInvoker) clientInvoker1).getNumberOfUsedConnections());
      assertEquals(0, ((MicroSocketClientInvoker) clientInvoker2).getNumberOfUsedConnections());
     
      client.removeListener(callbackHandler1);
      client.removeListener(callbackHandler2);
      client.disconnect();
      callbackConnector.stop();
   }
View Full Code Here

      assertTrue(client.getInvoker() instanceof BisocketClientInvoker);
      log.info("client is connected");
     
      String callbackLocatorURI1 = getTransport() + "://" + host + ":1";
      config.put(Bisocket.IS_CALLBACK_SERVER, "true");
      Connector callbackConnector1 = new Connector(callbackLocatorURI1, config);
      callbackConnector1.start();
      String callbackLocatorURI2 = getTransport() + "://" + host + ":2";
      Connector callbackConnector2 = new Connector(callbackLocatorURI2, config);
      callbackConnector2.start();
     
      DelayedCallbackHandler callbackHandler = new DelayedCallbackHandler();
      client.addListener(callbackHandler, new InvokerLocator(callbackLocatorURI1));
      client.addListener(callbackHandler, new InvokerLocator(callbackLocatorURI2));
      assertEquals(2, invocationHandler.callbackHandlers.size());
      log.info("client added callback handlers");
     
      client.invokeOneway(CALLBACK_TEST);
      client.invokeOneway(CALLBACK_TEST);
      Thread.sleep(500);
      assertEquals(2, callbackHandler.callbackCounter);
     
      Iterator it = invocationHandler.callbackHandlers.iterator();
      ServerInvokerCallbackHandler serverInvokerCallbackHandler1 = (ServerInvokerCallbackHandler) it.next();
      ServerInvokerCallbackHandler serverInvokerCallbackHandler2 = (ServerInvokerCallbackHandler) it.next();
      Client callbackClient1 = serverInvokerCallbackHandler1.getCallbackClient();
      Client callbackClient2 = serverInvokerCallbackHandler2.getCallbackClient();
      assertNotSame(callbackClient1, callbackClient2);
      assertTrue(callbackClient1.getInvoker() instanceof BisocketClientInvoker);
      MicroSocketClientInvoker clientInvoker1 = (MicroSocketClientInvoker) callbackClient1.getInvoker();
      assertTrue(callbackClient2.getInvoker() instanceof BisocketClientInvoker);
      MicroSocketClientInvoker clientInvoker2 = (MicroSocketClientInvoker) callbackClient2.getInvoker();
    
      Field field = MicroSocketClientInvoker.class.getDeclaredField("pool");
      field.setAccessible(true);
      List pool1 = (List) field.get(clientInvoker1);
      List pool2 = (List) field.get(clientInvoker2);
      assertEquals(0, pool1.size());
      assertEquals(0, pool2.size());
//      field = MicroSocketClientInvoker.class.getDeclaredField("usedPooled");
//      field.setAccessible(true);
//      Long usedPooled1 = (Long) field.get(clientInvoker1);
//      assertEquals(2, usedPooled1.intValue());
      assertEquals(2, clientInvoker1.getNumberOfUsedConnections());
//      Long usedPooled2 = (Long) field.get(clientInvoker2);
//      assertEquals(0, usedPooled2.intValue());
//      assertEquals(0, usedPooled2);
      assertEquals(0, clientInvoker2.getNumberOfUsedConnections());
     
      Thread.sleep(3000);
      assertEquals(2, pool1.size());
      assertEquals(0, pool2.size());
//      usedPooled1 = (Long) field.get(clientInvoker1);
//      assertEquals(0, usedPooled1.intValue());
      assertEquals(0, clientInvoker1.getNumberOfUsedConnections());
//      usedPooled2 = (Long) field.get(clientInvoker2);
//      assertEquals(2, usedPooled2.intValue());
      assertEquals(2, clientInvoker2.getNumberOfUsedConnections());
     
      Thread.sleep(3000);
      assertEquals(2, pool1.size());
      assertEquals(2, pool2.size());
//      usedPooled1 = (Long) field.get(clientInvoker1);
//      assertEquals(0, usedPooled1.intValue());
      assertEquals(0, clientInvoker1.getNumberOfUsedConnections());
//      usedPooled2 = (Long) field.get(clientInvoker2);
//      assertEquals(0, usedPooled2.intValue());
      assertEquals(0, clientInvoker2.getNumberOfUsedConnections());
     
      client.removeListener(callbackHandler);
      client.disconnect();
      callbackConnector1.stop();
      callbackConnector2.stop();
   }
View Full Code Here

      log.info("client is connected");
      assertTrue(client.getInvoker() instanceof BisocketClientInvoker);
     
      String callbackLocatorURI1 = getTransport() + "://" + host + ":1";
      config.put(Bisocket.IS_CALLBACK_SERVER, "true");
      Connector callbackConnector1 = new Connector(callbackLocatorURI1, config);
      callbackConnector1.start();
      String callbackLocatorURI2 = getTransport() + "://" + host + ":2";
      Connector callbackConnector2 = new Connector(callbackLocatorURI2, config);
      callbackConnector2.start();
     
      DelayedCallbackHandler callbackHandler1 = new DelayedCallbackHandler();
      client.addListener(callbackHandler1, new InvokerLocator(callbackLocatorURI1));
      DelayedCallbackHandler callbackHandler2 = new DelayedCallbackHandler();
      client.addListener(callbackHandler2, new InvokerLocator(callbackLocatorURI2));
      assertEquals(2, invocationHandler.callbackHandlers.size());
      log.info("clients added callback handler");
     
      Iterator it = invocationHandler.callbackHandlers.iterator();
      ServerInvokerCallbackHandler serverInvokerCallbackHandler1 = (ServerInvokerCallbackHandler) it.next();
      ServerInvokerCallbackHandler serverInvokerCallbackHandler2 = (ServerInvokerCallbackHandler) it.next();
     
      Client callbackClient1 = serverInvokerCallbackHandler1.getCallbackClient();
      Client callbackClient2 = serverInvokerCallbackHandler2.getCallbackClient();
      assertNotSame(callbackClient1, callbackClient2);
 
      ClientInvoker clientInvoker1 = callbackClient1.getInvoker();
      assertTrue(clientInvoker1 instanceof BisocketClientInvoker);
      ClientInvoker clientInvoker2 = callbackClient2.getInvoker();
      assertTrue(clientInvoker2 instanceof BisocketClientInvoker);
      assertNotSame(clientInvoker1, clientInvoker2);
     
      Field field = MicroSocketClientInvoker.class.getDeclaredField("pool");
      field.setAccessible(true);
      List pool1 = (List) field.get(clientInvoker1);
      List pool2 = (List) field.get(clientInvoker2);
     
//      field = MicroSocketClientInvoker.class.getDeclaredField("usedPooled");
//      field.setAccessible(true);
     
      assertEquals(0, callbackHandler1.callbackCounter);
      assertEquals(0, callbackHandler2.callbackCounter);
      assertEquals(0, pool1.size());
      assertEquals(0, pool2.size());
//      Long usedPooled1 = (Long) field.get(clientInvoker1);
//      Long usedPooled2 = (Long) field.get(clientInvoker2);
//      assertEquals(0, usedPooled1.longValue());
//      assertEquals(0, usedPooled2.longValue());
      assertEquals(0, ((MicroSocketClientInvoker) clientInvoker1).getNumberOfUsedConnections());
      assertEquals(0, ((MicroSocketClientInvoker) clientInvoker2).getNumberOfUsedConnections());
     
      client.invokeOneway(CALLBACK_TEST);
      client.invokeOneway(CALLBACK_TEST);
     
      Thread.sleep(500);
      int count1 = callbackHandler1.callbackCounter;
      int count2 = callbackHandler2.callbackCounter;
      assertTrue(count1 == 2 && count2 == 0 || count1 == 0 && count2 == 2);
      if (count1 == 0)
      {
         Object temp = callbackHandler1;
         callbackHandler1 = callbackHandler2;
         callbackHandler2 = (DelayedCallbackHandler) temp;;
      }
     
      assertEquals(2, callbackHandler1.callbackCounter);
      assertEquals(0, callbackHandler2.callbackCounter);
      assertEquals(0, pool1.size());
      assertEquals(0, pool2.size());
//      usedPooled1 = (Long) field.get(clientInvoker1);
//      usedPooled2 = (Long) field.get(clientInvoker2);
//      assertEquals(2, usedPooled1.longValue());
//      assertEquals(0, usedPooled2.longValue());
      assertEquals(2, ((MicroSocketClientInvoker) clientInvoker1).getNumberOfUsedConnections());
      assertEquals(0, ((MicroSocketClientInvoker) clientInvoker2).getNumberOfUsedConnections());
     
      Thread.sleep(2000);
      assertEquals(2, callbackHandler1.callbackCounter);
      assertEquals(2, callbackHandler2.callbackCounter);
      assertEquals(2, pool1.size());
      assertEquals(0, pool2.size());
//      usedPooled1 = (Long) field.get(clientInvoker1);
//      usedPooled2 = (Long) field.get(clientInvoker2);
//      assertEquals(0, usedPooled1.intValue());
//      assertEquals(2, usedPooled2.intValue());
      assertEquals(0, ((MicroSocketClientInvoker) clientInvoker1).getNumberOfUsedConnections());
      assertEquals(2, ((MicroSocketClientInvoker) clientInvoker2).getNumberOfUsedConnections());
     
      Thread.sleep(2000);
      assertEquals(2, callbackHandler1.callbackCounter);
      assertEquals(2, callbackHandler2.callbackCounter);
      assertEquals(2, pool1.size());
      assertEquals(2, pool2.size());
//      usedPooled1 = (Long) field.get(clientInvoker1);
//      usedPooled2 = (Long) field.get(clientInvoker2);
//      assertEquals(0, usedPooled1.intValue());
//      assertEquals(0, usedPooled2.intValue());
      assertEquals(0, ((MicroSocketClientInvoker) clientInvoker1).getNumberOfUsedConnections());
      assertEquals(0, ((MicroSocketClientInvoker) clientInvoker2).getNumberOfUsedConnections());
     
      client.removeListener(callbackHandler1);
      client.removeListener(callbackHandler2);
      client.disconnect();
      callbackConnector1.stop();
      callbackConnector2.stop();
   }
View Full Code Here

      assertTrue(client1.getInvoker() instanceof BisocketClientInvoker);
      assertTrue(client2.getInvoker() instanceof BisocketClientInvoker);
     
      String callbackLocatorURI = getTransport() + "://" + host + ":1";
      config.put(Bisocket.IS_CALLBACK_SERVER, "true");
      Connector callbackConnector = new Connector(callbackLocatorURI, config);
      callbackConnector.start();
     
      DelayedCallbackHandler callbackHandler = new DelayedCallbackHandler();
      client1.addListener(callbackHandler, new InvokerLocator(callbackLocatorURI));
      client2.addListener(callbackHandler, new InvokerLocator(callbackLocatorURI));
      assertEquals(1, invocationHandler.callbackHandlers.size());
      log.info("clients added callback handler");
     
      Iterator it = invocationHandler.callbackHandlers.iterator();
      ServerInvokerCallbackHandler serverInvokerCallbackHandler = (ServerInvokerCallbackHandler) it.next();
      Client callbackClient = serverInvokerCallbackHandler.getCallbackClient();
      ClientInvoker clientInvoker = callbackClient.getInvoker();
      assertTrue(clientInvoker instanceof BisocketClientInvoker);
     
      Field field = MicroSocketClientInvoker.class.getDeclaredField("pool");
      field.setAccessible(true);
      List pool = (List) field.get(clientInvoker);
//      field = MicroSocketClientInvoker.class.getDeclaredField("usedPooled");
//      field.setAccessible(true);
     
      assertEquals(0, callbackHandler.callbackCounter);
      assertEquals(0, pool.size());
//      Long usedPooled = (Long) field.get(clientInvoker);
//      assertEquals(0, usedPooled.longValue());
      assertEquals(0, ((MicroSocketClientInvoker) clientInvoker).getNumberOfUsedConnections());
      client1.invokeOneway(CALLBACK_TEST);
      client2.invokeOneway(CALLBACK_TEST);
     
      Thread.sleep(500);
      assertEquals(2, callbackHandler.callbackCounter);
      assertEquals(0, pool.size());
//      usedPooled = (Long) field.get(clientInvoker);
//      assertEquals(2, usedPooled.longValue());
      assertEquals(2, ((MicroSocketClientInvoker) clientInvoker).getNumberOfUsedConnections());
     
      Thread.sleep(2000);
      assertEquals(2, callbackHandler.callbackCounter);
      assertEquals(2, pool.size());
//      usedPooled = (Long) field.get(clientInvoker);
//      assertEquals(0, usedPooled.intValue());
      assertEquals(0, ((MicroSocketClientInvoker) clientInvoker).getNumberOfUsedConnections());
     
      client1.removeListener(callbackHandler);
      client1.disconnect();
      client2.removeListener(callbackHandler);
      client2.disconnect();
      callbackConnector.stop();
   }
View Full Code Here

      log.info("client is connected");
      assertTrue(client.getInvoker() instanceof BisocketClientInvoker);
     
      String callbackLocatorURI = getTransport() + "://" + host + ":1";
      config.put(Bisocket.IS_CALLBACK_SERVER, "true");
      Connector callbackConnector = new Connector(callbackLocatorURI, config);
      callbackConnector.start();
     
      DelayedCallbackHandler callbackHandler1 = new DelayedCallbackHandler();
      client.addListener(callbackHandler1, new InvokerLocator(callbackLocatorURI));
      DelayedCallbackHandler callbackHandler2 = new DelayedCallbackHandler();
      client.addListener(callbackHandler2, new InvokerLocator(callbackLocatorURI));
      assertEquals(2, invocationHandler.callbackHandlers.size());
      log.info("clients added callback handler");
     
      Iterator it = invocationHandler.callbackHandlers.iterator();
      ServerInvokerCallbackHandler serverInvokerCallbackHandler1 = (ServerInvokerCallbackHandler) it.next();
      ServerInvokerCallbackHandler serverInvokerCallbackHandler2 = (ServerInvokerCallbackHandler) it.next();
      Client callbackClient1 = serverInvokerCallbackHandler1.getCallbackClient();
      Client callbackClient2 = serverInvokerCallbackHandler2.getCallbackClient();
      assertNotSame(callbackClient1, callbackClient2);
      ClientInvoker clientInvoker1 = callbackClient1.getInvoker();
      assertTrue(clientInvoker1 instanceof BisocketClientInvoker);
      ClientInvoker clientInvoker2 = callbackClient2.getInvoker();
      assertTrue(clientInvoker2 instanceof BisocketClientInvoker);
      assertNotSame(clientInvoker1, clientInvoker2);
     
      Field field = MicroSocketClientInvoker.class.getDeclaredField("pool");
      field.setAccessible(true);
      List pool1 = (List) field.get(clientInvoker1);
      List pool2 = (List) field.get(clientInvoker2);
      assertNotSame(pool1, pool2);
     
//      field = MicroSocketClientInvoker.class.getDeclaredField("usedPooled");
//      field.setAccessible(true);
     
      assertEquals(0, callbackHandler1.callbackCounter);
      assertEquals(0, callbackHandler2.callbackCounter);
      assertEquals(0, pool1.size());
//      Long usedPooled1 = (Long) field.get(clientInvoker1);
//      Long usedPooled2 = (Long) field.get(clientInvoker2);
//      assertEquals(0, usedPooled1.longValue());
//      assertEquals(0, usedPooled2.longValue());
      assertEquals(0, ((MicroSocketClientInvoker) clientInvoker1).getNumberOfUsedConnections());
      assertEquals(0, ((MicroSocketClientInvoker) clientInvoker2).getNumberOfUsedConnections());
      client.invokeOneway(CALLBACK_TEST);
      client.invokeOneway(CALLBACK_TEST);
     
      Thread.sleep(500);
      int count1 = callbackHandler1.callbackCounter;
      int count2 = callbackHandler2.callbackCounter;
      assertTrue(count1 == 2 && count2 == 0 || count1 == 0 && count2 == 2);
      if (count1 == 0)
      {
         Object temp = callbackHandler1;
         callbackHandler1 = callbackHandler2;
         callbackHandler2 = (DelayedCallbackHandler) temp;;
      }
     
      assertEquals(2, callbackHandler1.callbackCounter);
      assertEquals(0, callbackHandler2.callbackCounter);
      assertEquals(0, pool1.size());
      assertEquals(0, pool2.size());
//      usedPooled1 = (Long) field.get(clientInvoker1);
//      usedPooled2 = (Long) field.get(clientInvoker2);
//      assertEquals(2, usedPooled1.longValue());
//      assertEquals(0, usedPooled2.longValue());
      assertEquals(2, ((MicroSocketClientInvoker) clientInvoker1).getNumberOfUsedConnections());
      assertEquals(0, ((MicroSocketClientInvoker) clientInvoker2).getNumberOfUsedConnections());
     
      Thread.sleep(2000);
      assertEquals(2, callbackHandler1.callbackCounter);
      assertEquals(2, callbackHandler2.callbackCounter);
      assertEquals(2, pool1.size());
      assertEquals(0, pool2.size());
//      usedPooled1 = (Long) field.get(clientInvoker1);
//      usedPooled2 = (Long) field.get(clientInvoker2);
//      assertEquals(0, usedPooled1.intValue());
//      assertEquals(2, usedPooled2.intValue());
      assertEquals(0, ((MicroSocketClientInvoker) clientInvoker1).getNumberOfUsedConnections());
      assertEquals(2, ((MicroSocketClientInvoker) clientInvoker2).getNumberOfUsedConnections());
     
      Thread.sleep(2000);
      assertEquals(2, callbackHandler1.callbackCounter);
      assertEquals(2, callbackHandler2.callbackCounter);
      assertEquals(2, pool1.size());
      assertEquals(2, pool2.size());
//      usedPooled1 = (Long) field.get(clientInvoker1);
//      usedPooled2 = (Long) field.get(clientInvoker2);
//      assertEquals(0, usedPooled1.intValue());
//      assertEquals(0, usedPooled2.intValue());
      assertEquals(0, ((MicroSocketClientInvoker) clientInvoker1).getNumberOfUsedConnections());
      assertEquals(0, ((MicroSocketClientInvoker) clientInvoker2).getNumberOfUsedConnections());
     
      client.removeListener(callbackHandler1);
      client.removeListener(callbackHandler2);
      client.disconnect();
      callbackConnector.stop();
   }
View Full Code Here

      assertTrue(client1.getInvoker() instanceof BisocketClientInvoker);
      assertTrue(client2.getInvoker() instanceof BisocketClientInvoker);
     
      String callbackLocatorURI1 = getTransport() + "://" + host + ":1";
      config.put(Bisocket.IS_CALLBACK_SERVER, "true");
      Connector callbackConnector1 = new Connector(callbackLocatorURI1, config);
      callbackConnector1.start();
      String callbackLocatorURI2 = getTransport() + "://" + host + ":2";
      Connector callbackConnector2 = new Connector(callbackLocatorURI2, config);
      callbackConnector2.start();
     
      DelayedCallbackHandler callbackHandler = new DelayedCallbackHandler();
      client1.addListener(callbackHandler, new InvokerLocator(callbackLocatorURI1));
      client2.addListener(callbackHandler, new InvokerLocator(callbackLocatorURI2));
      assertEquals(2, invocationHandler.callbackHandlers.size());
      log.info("clients added callback handler");
     
      Iterator it = invocationHandler.callbackHandlers.iterator();
      ServerInvokerCallbackHandler serverInvokerCallbackHandler1 = (ServerInvokerCallbackHandler) it.next();
      ServerInvokerCallbackHandler serverInvokerCallbackHandler2 = (ServerInvokerCallbackHandler) it.next();
      Client callbackClient1 = serverInvokerCallbackHandler1.getCallbackClient();
      Client callbackClient2 = serverInvokerCallbackHandler2.getCallbackClient();
      assertNotSame(callbackClient1, callbackClient2);
      ClientInvoker clientInvoker1 = callbackClient1.getInvoker();
      assertTrue(clientInvoker1 instanceof BisocketClientInvoker);
      ClientInvoker clientInvoker2 = callbackClient2.getInvoker();
      assertTrue(clientInvoker2 instanceof BisocketClientInvoker);
      assertNotSame(clientInvoker1, clientInvoker2);
     
      Field field = MicroSocketClientInvoker.class.getDeclaredField("pool");
      field.setAccessible(true);
      List pool1 = (List) field.get(clientInvoker1);
      List pool2 = (List) field.get(clientInvoker2);
     
//      field = MicroSocketClientInvoker.class.getDeclaredField("usedPooled");
//      field.setAccessible(true);
     
      assertEquals(0, callbackHandler.callbackCounter);
      assertEquals(0, pool1.size());
      assertEquals(0, pool2.size());
//      Long usedPooled1 = (Long) field.get(clientInvoker1);
//      Long usedPooled2 = (Long) field.get(clientInvoker2);
//      assertEquals(0, usedPooled1.longValue());
//      assertEquals(0, usedPooled2.longValue());
      assertEquals(0, ((MicroSocketClientInvoker) clientInvoker1).getNumberOfUsedConnections());
      assertEquals(0, ((MicroSocketClientInvoker) clientInvoker2).getNumberOfUsedConnections());
      client1.invokeOneway(CALLBACK_TEST);
      client2.invokeOneway(CALLBACK_TEST);
     
      Thread.sleep(500);
      assertEquals(2, callbackHandler.callbackCounter);
      assertEquals(0, pool1.size());
      assertEquals(0, pool2.size());
//      usedPooled1 = (Long) field.get(clientInvoker1);
//      usedPooled2 = (Long) field.get(clientInvoker2);
//      assertEquals(2, usedPooled1.longValue());
//      assertEquals(0, usedPooled2.longValue());
      assertEquals(2, ((MicroSocketClientInvoker) clientInvoker1).getNumberOfUsedConnections());
      assertEquals(0, ((MicroSocketClientInvoker) clientInvoker2).getNumberOfUsedConnections());
     
      Thread.sleep(2000);
      assertEquals(4, callbackHandler.callbackCounter);
      assertEquals(2, pool1.size());
      assertEquals(0, pool2.size());
//      usedPooled1 = (Long) field.get(clientInvoker1);
//      usedPooled2 = (Long) field.get(clientInvoker2);
//      assertEquals(0, usedPooled1.intValue());
//      assertEquals(2, usedPooled2.intValue());
      assertEquals(0, ((MicroSocketClientInvoker) clientInvoker1).getNumberOfUsedConnections());
      assertEquals(2, ((MicroSocketClientInvoker) clientInvoker2).getNumberOfUsedConnections());
     
      Thread.sleep(2000);
      assertEquals(4, callbackHandler.callbackCounter);
      assertEquals(2, pool1.size());
      assertEquals(2, pool2.size());
//      usedPooled1 = (Long) field.get(clientInvoker1);
//      usedPooled2 = (Long) field.get(clientInvoker2);
//      assertEquals(0, usedPooled1.intValue());
//      assertEquals(0, usedPooled2.intValue());
      assertEquals(0, ((MicroSocketClientInvoker) clientInvoker1).getNumberOfUsedConnections());
      assertEquals(0, ((MicroSocketClientInvoker) clientInvoker2).getNumberOfUsedConnections());
     
      client1.removeListener(callbackHandler);
      client1.disconnect();
      client2.removeListener(callbackHandler);
      client2.disconnect();
      callbackConnector1.stop();
      callbackConnector2.stop();
   }
View Full Code Here

      log.info("client is connected");
      assertTrue(client.getInvoker() instanceof BisocketClientInvoker);
     
      String callbackLocatorURI1 = getTransport() + "://" + host + ":1";
      config.put(Bisocket.IS_CALLBACK_SERVER, "true");
      Connector callbackConnector1 = new Connector(callbackLocatorURI1, config);
      callbackConnector1.start();
      String callbackLocatorURI2 = getTransport() + "://" + host + ":2";
      Connector callbackConnector2 = new Connector(callbackLocatorURI2, config);
      callbackConnector2.start();
     
      DelayedCallbackHandler callbackHandler1 = new DelayedCallbackHandler();
      client.addListener(callbackHandler1, new InvokerLocator(callbackLocatorURI1));
      DelayedCallbackHandler callbackHandler2 = new DelayedCallbackHandler();
      client.addListener(callbackHandler2, new InvokerLocator(callbackLocatorURI2));
      assertEquals(2, invocationHandler.callbackHandlers.size());
      log.info("clients added callback handler");
     
      Iterator it = invocationHandler.callbackHandlers.iterator();
      ServerInvokerCallbackHandler serverInvokerCallbackHandler1 = (ServerInvokerCallbackHandler) it.next();
      ServerInvokerCallbackHandler serverInvokerCallbackHandler2 = (ServerInvokerCallbackHandler) it.next();
      Client callbackClient1 = serverInvokerCallbackHandler1.getCallbackClient();
      Client callbackClient2 = serverInvokerCallbackHandler2.getCallbackClient();
      assertNotSame(callbackClient1, callbackClient2);
      ClientInvoker clientInvoker1 = callbackClient1.getInvoker();
      assertTrue(clientInvoker1 instanceof BisocketClientInvoker);
      ClientInvoker clientInvoker2 = callbackClient2.getInvoker();
      assertTrue(clientInvoker2 instanceof BisocketClientInvoker);
      assertNotSame(clientInvoker1, clientInvoker2);
     
      Field field = MicroSocketClientInvoker.class.getDeclaredField("pool");
      field.setAccessible(true);
      List pool1 = (List) field.get(clientInvoker1);
      List pool2 = (List) field.get(clientInvoker2);
     
//      field = MicroSocketClientInvoker.class.getDeclaredField("usedPooled");
//      field.setAccessible(true);
     
      assertEquals(0, callbackHandler1.callbackCounter);
      assertEquals(0, callbackHandler2.callbackCounter);
      assertEquals(0, pool1.size());
//      Long usedPooled1 = (Long) field.get(clientInvoker1);
//      Long usedPooled2 = (Long) field.get(clientInvoker2);
//      assertEquals(0, usedPooled1.longValue());
//      assertEquals(0, usedPooled2.longValue());
      assertEquals(0, ((MicroSocketClientInvoker) clientInvoker1).getNumberOfUsedConnections());
      assertEquals(0, ((MicroSocketClientInvoker) clientInvoker2).getNumberOfUsedConnections());
      client.invokeOneway(CALLBACK_TEST);
      client.invokeOneway(CALLBACK_TEST);
     
      Thread.sleep(500);
      int count1 = callbackHandler1.callbackCounter;
      int count2 = callbackHandler2.callbackCounter;
      assertTrue(count1 == 2 && count2 == 0 || count1 == 0 && count2 == 2);
      if (count1 == 0)
      {
         Object temp = callbackHandler1;
         callbackHandler1 = callbackHandler2;
         callbackHandler2 = (DelayedCallbackHandler) temp;;
      }
     
      assertEquals(2, callbackHandler1.callbackCounter);
      assertEquals(0, callbackHandler2.callbackCounter);
      assertEquals(0, pool1.size());
      assertEquals(0, pool2.size());
//      usedPooled1 = (Long) field.get(clientInvoker1);
//      usedPooled2 = (Long) field.get(clientInvoker2);
//      assertEquals(2, usedPooled1.longValue());
//      assertEquals(0, usedPooled2.longValue());
      assertEquals(2, ((MicroSocketClientInvoker) clientInvoker1).getNumberOfUsedConnections());
      assertEquals(0, ((MicroSocketClientInvoker) clientInvoker2).getNumberOfUsedConnections());
     
      Thread.sleep(2000);
      assertEquals(2, callbackHandler1.callbackCounter);
      assertEquals(2, callbackHandler2.callbackCounter);
      assertEquals(2, pool1.size());
      assertEquals(0, pool2.size());
//      usedPooled1 = (Long) field.get(clientInvoker1);
//      usedPooled2 = (Long) field.get(clientInvoker2);
//      assertEquals(0, usedPooled1.intValue());
//      assertEquals(2, usedPooled2.intValue());
      assertEquals(0, ((MicroSocketClientInvoker) clientInvoker1).getNumberOfUsedConnections());
      assertEquals(2, ((MicroSocketClientInvoker) clientInvoker2).getNumberOfUsedConnections());
     
      Thread.sleep(2000);
      assertEquals(2, callbackHandler1.callbackCounter);
      assertEquals(2, callbackHandler2.callbackCounter);
      assertEquals(2, pool1.size());
      assertEquals(2, pool2.size());
//      usedPooled1 = (Long) field.get(clientInvoker1);
//      usedPooled2 = (Long) field.get(clientInvoker2);
//      assertEquals(0, usedPooled1.intValue());
//      assertEquals(0, usedPooled2.intValue());
      assertEquals(0, ((MicroSocketClientInvoker) clientInvoker1).getNumberOfUsedConnections());
      assertEquals(0, ((MicroSocketClientInvoker) clientInvoker2).getNumberOfUsedConnections());
     
      client.removeListener(callbackHandler1);
      client.removeListener(callbackHandler2);
      client.disconnect();
      callbackConnector1.stop();
      callbackConnector2.stop();
   }
View Full Code Here

      field.setAccessible(true);
      Map callbackConnectors = (Map) field.get(client);
      assertEquals(1, callbackConnectors.size());
      Set callbackConnectorSet = (Set) callbackConnectors.values().iterator().next();
      assertEquals(1, callbackConnectorSet.size());
      Connector callbackConnector = (Connector) callbackConnectorSet.iterator().next();
      BisocketServerInvoker invoker = (BisocketServerInvoker) callbackConnector.getServerInvoker();
      field = BisocketServerInvoker.class.getDeclaredField("controlConnectionThreadMap");
      field.setAccessible(true);
      Map controlConnectionThreadMap = (Map) field.get(invoker);
      assertEquals(1, controlConnectionThreadMap.size());
      Thread t = (Thread) controlConnectionThreadMap.values().iterator().next();
View Full Code Here

      field.setAccessible(true);
      Map callbackConnectors = (Map) field.get(client);
      assertEquals(1, callbackConnectors.size());
      Set callbackConnectorSet = (Set) callbackConnectors.values().iterator().next();
      assertEquals(1, callbackConnectorSet.size());
      Connector callbackConnector = (Connector) callbackConnectorSet.iterator().next();
      BisocketServerInvoker invoker = (BisocketServerInvoker) callbackConnector.getServerInvoker();
      field = BisocketServerInvoker.class.getDeclaredField("controlConnectionThreadMap");
      field.setAccessible(true);
      Map controlConnectionThreadMap = (Map) field.get(invoker);
      assertEquals(1, controlConnectionThreadMap.size());
      Collection controlConnectionThreads = controlConnectionThreadMap.values();
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.