[jboss-cvs] JBossRemoting/src/tests/org/jboss/test/remoting/transport/socket/load ...

Tom Elrod tom.elrod at jboss.com
Wed Sep 27 13:17:33 EDT 2006


  User: telrod  
  Date: 06/09/27 13:17:33

  Added:       src/tests/org/jboss/test/remoting/transport/socket/load  
                        Tag: remoting_1_4 SampleInvocationHandler.java
                        SocketLoadTestCase.java
  Log:
  JBREM-409 - fixes for the 1.4 branch for socket server thread not being cleaned up (leaking).  Targeted for 1.4.5.GA
  
  Revision  Changes    Path
  No                   revision
  
  
  No                   revision
  
  
  1.1.4.2   +62 -0     JBossRemoting/src/tests/org/jboss/test/remoting/transport/socket/load/SampleInvocationHandler.java
  
  (In the diff below, changes in quantity of whitespace are not shown.)
  
  Index: SampleInvocationHandler.java
  ===================================================================
  RCS file: SampleInvocationHandler.java
  diff -N SampleInvocationHandler.java
  --- /dev/null	1 Jan 1970 00:00:00 -0000
  +++ SampleInvocationHandler.java	27 Sep 2006 17:17:33 -0000	1.1.4.2
  @@ -0,0 +1,62 @@
  +/*
  +* JBoss, Home of Professional Open Source
  +* Copyright 2005, JBoss Inc., and individual contributors as indicated
  +* by the @authors tag. See the copyright.txt in the distribution for a
  +* full listing of individual contributors.
  +*
  +* This is free software; you can redistribute it and/or modify it
  +* under the terms of the GNU Lesser General Public License as
  +* published by the Free Software Foundation; either version 2.1 of
  +* the License, or (at your option) any later version.
  +*
  +* This software is distributed in the hope that it will be useful,
  +* but WITHOUT ANY WARRANTY; without even the implied warranty of
  +* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
  +* Lesser General Public License for more details.
  +*
  +* You should have received a copy of the GNU Lesser General Public
  +* License along with this software; if not, write to the Free
  +* Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
  +* 02110-1301 USA, or see the FSF site: http://www.fsf.org.
  +*/
  +package org.jboss.test.remoting.transport.socket.load;
  +
  +import org.apache.log4j.Logger;
  +import org.jboss.remoting.InvocationRequest;
  +import org.jboss.remoting.ServerInvocationHandler;
  +import org.jboss.remoting.ServerInvoker;
  +import org.jboss.remoting.callback.InvokerCallbackHandler;
  +
  +import javax.management.MBeanServer;
  +
  +public class SampleInvocationHandler implements ServerInvocationHandler
  +{
  +   private static Logger logger = Logger.getRootLogger();
  +
  +   public Object invoke(InvocationRequest invocation) throws Throwable
  +   {
  +      String parm = (String) invocation.getParameter();
  +      System.out.println(Thread.currentThread() + "******* Invoked " + parm);
  +      Thread.sleep(5000);
  +      System.out.println(Thread.currentThread() + "******* Returning - response" + parm);
  +      String s = "response" + parm;
  +      return s;
  +   }
  +
  +   public void setMBeanServer(MBeanServer server)
  +   {
  +   }
  +
  +   public void setInvoker(ServerInvoker invoker)
  +   {
  +   }
  +
  +   public void addListener(InvokerCallbackHandler callbackHandler)
  +   {
  +   }
  +
  +   public void removeListener(InvokerCallbackHandler callbackHandler)
  +   {
  +   }
  +
  +}
  \ No newline at end of file
  
  
  
  1.2.4.2   +119 -0    JBossRemoting/src/tests/org/jboss/test/remoting/transport/socket/load/SocketLoadTestCase.java
  
  (In the diff below, changes in quantity of whitespace are not shown.)
  
  Index: SocketLoadTestCase.java
  ===================================================================
  RCS file: SocketLoadTestCase.java
  diff -N SocketLoadTestCase.java
  --- /dev/null	1 Jan 1970 00:00:00 -0000
  +++ SocketLoadTestCase.java	27 Sep 2006 17:17:33 -0000	1.2.4.2
  @@ -0,0 +1,119 @@
  +/*
  +* JBoss, Home of Professional Open Source
  +* Copyright 2005, JBoss Inc., and individual contributors as indicated
  +* by the @authors tag. See the copyright.txt in the distribution for a
  +* full listing of individual contributors.
  +*
  +* This is free software; you can redistribute it and/or modify it
  +* under the terms of the GNU Lesser General Public License as
  +* published by the Free Software Foundation; either version 2.1 of
  +* the License, or (at your option) any later version.
  +*
  +* This software is distributed in the hope that it will be useful,
  +* but WITHOUT ANY WARRANTY; without even the implied warranty of
  +* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
  +* Lesser General Public License for more details.
  +*
  +* You should have received a copy of the GNU Lesser General Public
  +* License along with this software; if not, write to the Free
  +* Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
  +* 02110-1301 USA, or see the FSF site: http://www.fsf.org.
  +*/
  +package org.jboss.test.remoting.transport.socket.load;
  +
  +import junit.framework.TestCase;
  +import org.apache.log4j.Logger;
  +import org.jboss.remoting.Client;
  +import org.jboss.remoting.InvokerLocator;
  +import org.jboss.remoting.transport.Connector;
  +
  +public class SocketLoadTestCase extends TestCase
  +{
  +   private static int numOfRunnerThreads = 10;
  +   private static int responseCount = 0;
  +   private Connector connector;
  +
  +//   static
  +//   {
  +//      BasicConfigurator.configure();
  +//      Logger.getRootLogger().setLevel(Level.INFO);
  +//      Logger.getInstance("org.jboss.remoting.transport.socket").setLevel(Level.ALL);
  +//   }
  +
  +   private Logger logger = Logger.getRootLogger();
  +
  +   public static void main(String[] args) throws Throwable
  +   {
  +      SocketLoadTestCase rt = new SocketLoadTestCase();
  +      rt.startServer();
  +//      rt.runMultipleClients(Integer.parseInt(args[1]));
  +      rt.runMultipleClients(numOfRunnerThreads);
  +      System.in.read();
  +   }
  +
  +   public void setUp() throws Exception
  +   {
  +      startServer();
  +   }
  +
  +   public void tearDown() throws Exception
  +   {
  +      if(connector != null)
  +      {
  +         connector.stop();
  +         connector.destroy();
  +      }
  +   }
  +
  +   public void startServer() throws Exception
  +   {
  +      String locatorURI = "socket://localhost:54000/?maxPoolSize=2&timeout=10000";
  +      InvokerLocator locator = new InvokerLocator(locatorURI);
  +
  +      connector = new Connector();
  +
  +      connector.setInvokerLocator(locator.getLocatorURI());
  +      connector.create();
  +
  +      SampleInvocationHandler invocationHandler = new SampleInvocationHandler();
  +      connector.addInvocationHandler("sample", invocationHandler);
  +      connector.start();
  +   }
  +
  +   public void testRunClients() throws Throwable
  +   {
  +      runMultipleClients(numOfRunnerThreads);
  +      Thread.currentThread().sleep(120000);
  +      System.out.println("Response count = " + responseCount + ".  Expected 10.");
  +      assertEquals(10, responseCount);
  +   }
  +
  +   public void runClient(String clientId) throws Throwable
  +   {
  +      String locatorURI = "socket://localhost:54000/";
  +      InvokerLocator locator = new InvokerLocator(locatorURI);
  +      Client client = new Client(locator);
  +      client.connect();
  +      String req = clientId;
  +      Object resp = client.invoke(req);
  +      responseCount++;
  +      System.out.println("Received response of: " + resp + ".  Response count = " + responseCount);
  +      System.in.read();
  +   }
  +
  +      public void runMultipleClients(int cnt) throws Throwable {
  +      for (int i = 0; i < cnt; i++) {
  +         Thread t = new Thread(new Runnable() {
  +            public void run() {
  +               try {
  +                  Thread.sleep(1000);
  +                  runClient(Thread.currentThread().getName());
  +               } catch (Throwable e) {
  +                  logger.error(e);
  +               }
  +            }
  +         }, Integer.toString(i));
  +         t.start();
  +      }
  +   }
  +}
  \ No newline at end of file
  
  
  



More information about the jboss-cvs-commits mailing list