Package org.jboss.remoting.transport.socket

Examples of org.jboss.remoting.transport.socket.ServerThread


      Field field = SocketServerInvoker.class.getDeclaredField("clientpool");
      field.setAccessible(true);
      LRUPool clientpool = (LRUPool) field.get(invoker);
      assertEquals(1, clientpool.size());
      Set clientpoolContents =  clientpool.getContents();
      ServerThread serverThread1 = (ServerThread) clientpoolContents.iterator().next();
     
      // Get threadpool.
      field = SocketServerInvoker.class.getDeclaredField("threadpool");
      field.setAccessible(true);
      LinkedList threadpool = (LinkedList) field.get(invoker);
      assertEquals(0, threadpool.size());
     
      // Wait for ServerThread to time out.
      Thread.sleep(8000);
     
      // Verify original ServerThread remains in clientpool.
      assertEquals(0, threadpool.size());
      assertEquals(1, clientpool.size());
      clientpoolContents =  clientpool.getContents();
      assertEquals(serverThread1, clientpoolContents.iterator().next());
     
      // Make another invocation and verify ServerThread was reused.
      client.invoke("xyz");
      assertEquals(1, clientpool.size());
      clientpoolContents =  clientpool.getContents();
      ServerThread serverThread2 = (ServerThread) clientpoolContents.iterator().next();
      assertEquals(serverThread1, serverThread2);
     
      client.disconnect();
      shutdownServer();
      log.info(getName() + " PASSES");
View Full Code Here


         threads = new HashSet(threads);
         log.info("NUMBER of SERVER THREADS: " + threads.size());
         Iterator it = threads.iterator();
         while (it.hasNext())
         {
            ServerThread t = (ServerThread) it.next();
            log.info("CLOSING " + t);
            ServerSocketWrapper socketWrapper = (ServerSocketWrapper) socketWrapperField.get(t);
            socketWrapper.close();
            log.info(this + " CLOSED " + socketWrapper);
         }
View Full Code Here

         LRUPool clientpool = (LRUPool) clientpoolField.get(invoker);
         Set threads = clientpool.getContents();
         Iterator it = threads.iterator();
         while (it.hasNext())
         {
            ServerThread t = (ServerThread) it.next();
            ServerSocketWrapper socketWrapper = (ServerSocketWrapper) socketWrapperField.get(t);
            socketWrapper.close();
            log.info(this + " closed " + socketWrapper);
         }
        
View Full Code Here

      protected void processInvocation(Socket socket) throws Exception
      {
         clientpool = new LRUPool(2, maxPoolSize);
         clientpool.create();
         threadpool = new LinkedList();
         ServerThread worker = new TestServerThread(socket, this, clientpool, threadpool, 0, 0, ServerSocketWrapper.class.getName());
         worker.start();
      }
View Full Code Here

      assertEquals(0, threadpool.size());
      assertEquals(1, clientpool.size());
     
      // Kill worker thread's socket.
      Set clientpoolContents = clientpool.getContents();
      ServerThread serverThread1 = (ServerThread) clientpoolContents.iterator().next();
      field = ServerThread.class.getDeclaredField("socket");
      field.setAccessible(true);
      Socket socket = (Socket) field.get(serverThread1);
      socket.close();
      Thread.sleep(4000);
      assertEquals(1, threadpool.size());
      assertEquals(0, clientpool.size());
     
      // Make second callback and verify that worker thread gets reused.
      client.invoke("callback");
      assertEquals(2, callbackHandler.counter);
      log.info("second callback successful");
      assertEquals(0, threadpool.size());
      assertEquals(1, clientpool.size());
      clientpoolContents = clientpool.getContents();
      ServerThread serverThread2 = (ServerThread) clientpoolContents.iterator().next();
      assertEquals(serverThread2, serverThread1);
      log.info("ServerThread was reused");
     
      client.removeListener(callbackHandler);
      client.disconnect();
View Full Code Here

TOP

Related Classes of org.jboss.remoting.transport.socket.ServerThread

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.