[jboss-cvs] JBossRemoting/src/tests/org/jboss/test/remoting/performance/spring/rmi ...

Tom Elrod tom.elrod at jboss.com
Sun Aug 13 15:30:06 EDT 2006


  User: telrod  
  Date: 06/08/13 15:30:06

  Added:       src/tests/org/jboss/test/remoting/performance/spring/rmi             
                        MultiThreadedSpringRMIPerformanceClient.java
                        MultiThreadedSpringRMIPerformanceTestCase.java
                        SpringRMICallbackServer.java
                        SpringRMICallbackServerImpl.java
                        SpringRMICallbackServerService.xml
                        SpringRMIClientService.xml SpringRMIHandler.java
                        SpringRMIPerformanceClient.java
                        SpringRMIPerformanceServer.java
                        SpringRMIPerformanceTestCase.java
                        SpringRMIServer.java SpringRMIServerImpl.java
                        SpringRMIServerService.xml
  Log:
  JBREM-578 - including spring remoting tests (rmi and hessian transports) to the performance benchmark testing.
  
  Revision  Changes    Path
  1.1      date: 2006/08/13 19:30:05;  author: telrod;  state: Exp;JBossRemoting/src/tests/org/jboss/test/remoting/performance/spring/rmi/MultiThreadedSpringRMIPerformanceClient.java
  
  Index: MultiThreadedSpringRMIPerformanceClient.java
  ===================================================================
  /***************************************
   *                                     *
   *  JBoss: The OpenSource J2EE WebOS   *
   *                                     *
   *  Distributable under LGPL license.  *
   *  See terms of license at gnu.org.   *
   *                                     *
   ***************************************/
  package org.jboss.test.remoting.performance.spring.rmi;
  
  import EDU.oswego.cs.dl.util.concurrent.Latch;
  import junit.framework.Test;
  import org.jboss.jrunit.decorators.ThreadLocalDecorator;
  import org.jboss.logging.Logger;
  import org.jboss.remoting.InvokerLocator;
  import org.jboss.test.remoting.performance.synchronous.MultiThreadedPerformanceClientTest;
  import org.jboss.test.remoting.performance.synchronous.PerformanceCallbackKeeper;
  import org.springframework.beans.factory.BeanFactory;
  import org.springframework.beans.factory.xml.XmlBeanFactory;
  import org.springframework.context.ApplicationContext;
  import org.springframework.context.support.FileSystemXmlApplicationContext;
  import org.springframework.core.io.ClassPathResource;
  import org.springframework.core.io.Resource;
  
  import java.rmi.server.UID;
  import java.util.Map;
  
  /**
   * @author <a href="mailto:tom at jboss.org">Tom Elrod</a>
   */
  public class MultiThreadedSpringRMIPerformanceClient extends MultiThreadedPerformanceClientTest
  {
     private SpringRMIServer springRMIServerService;
     private String clientSessionId = new UID().toString();
  
     protected static final Logger log = Logger.getLogger(MultiThreadedSpringRMIPerformanceClient.class);
  
     public static Test suite()
     {
        return new ThreadLocalDecorator(MultiThreadedSpringRMIPerformanceClient.class, 1);
     }
  
     public SpringRMIServer getSpringRMIServerService()
     {
        return springRMIServerService;
     }
  
     public void setSpringRMIServerService(SpringRMIServer springRMIServerService)
     {
        this.springRMIServerService = springRMIServerService;
     }
  
     public void init()
     {
  
        Resource res = new ClassPathResource("SpringRMIClientService.xml", SpringRMIPerformanceClient.class);
        BeanFactory factory = new XmlBeanFactory(res);
        springRMIServerService = (SpringRMIServer)factory.getBean("springRMIServerService");
  
        /*
        //super.init();
  
        String name = "//localhost/RMIServer";
  //         RMIServer svr = (RMIServer) Naming.lookup(name);
  
        try
        {
           //Registry regsitry = LocateRegistry.getRegistry("localhost", rmiPort);
           Registry regsitry = LocateRegistry.getRegistry(rmiPort);
           Remote remoteObj = regsitry.lookup(name);
           rmiServer = (RMIServerRemote) remoteObj;
        }
        catch(Exception e)
        {
           log.error("Error initializating rmi client.", e);
        }
        */
     }
  
     /**
      * This will be used to create callback server
      *
      * @param port
      * @return
      * @throws Exception
      */
     protected InvokerLocator initServer(int port) throws Exception
     {
        return null;
     }
  
     protected PerformanceCallbackKeeper addCallbackListener(String sessionId, Latch serverDoneLock)
           throws Throwable
     {
        String springServiceXml = this.getClass().getResource("SpringRMIClientService.xml").getFile();
  
        ApplicationContext context = new FileSystemXmlApplicationContext(springServiceXml);
        SpringRMICallbackServer callbackServer = (SpringRMICallbackServer) context.getBean("springRMICallbackServerService");
        callbackServer.setClientSessionId(clientSessionId);
        callbackServer.setServerDoneLock(serverDoneLock);
        return callbackServer;
  
  //      RMICallbackServer callbackServer = new RMICallbackServer(clientSessionId, serverDoneLock);
  //      callbackServer.start();
  //      return callbackServer;
     }
  
     protected void populateMetadata(Map metadata)
     {
        super.populateMetadata(metadata);
        metadata.put("transport", "spring_rmi");
        metadata.put("serialization", "java");
     }
  
     protected Object getBenchmarkAlias()
     {
        String config = System.getProperty("alias");
        if(config == null || config.length() == 0)
        {
           config = System.getProperty("jboss-junit-configuration");
           if(config == null || config.length() == 0)
           {
              config = "spring_rmi" + "_" + getNumberOfCalls() + "_" + getPayloadSize() + "_" + "java";
           }
        }
        return config;
     }
  
  
     protected Object makeInvocation(String method, Object param) throws Throwable
     {
        if(method.equals(NUM_OF_CALLS))
        {
           return springRMIServerService.sendNumberOfCalls(clientSessionId, param);
        }
        else if(method.equals(TEST_INVOCATION))
        {
           return springRMIServerService.makeCall(clientSessionId, param);
        }
        else
        {
           throw new Exception("Was not able to find remote method call for " + method);
        }
     }
  
     public static void main(String[] args)
     {
        MultiThreadedPerformanceClientTest test = new MultiThreadedSpringRMIPerformanceClient();
        try
        {
           test.setUp();
           test.testClientCalls();
           test.tearDown();
        }
        catch(Throwable throwable)
        {
           throwable.printStackTrace();
        }
     }
  
  
  }
  
  
  1.1      date: 2006/08/13 19:30:05;  author: telrod;  state: Exp;JBossRemoting/src/tests/org/jboss/test/remoting/performance/spring/rmi/MultiThreadedSpringRMIPerformanceTestCase.java
  
  Index: MultiThreadedSpringRMIPerformanceTestCase.java
  ===================================================================
  /***************************************
   *                                     *
   *  JBoss: The OpenSource J2EE WebOS   *
   *                                     *
   *  Distributable under LGPL license.  *
   *  See terms of license at gnu.org.   *
   *                                     *
   ***************************************/
  package org.jboss.test.remoting.performance.spring.rmi;
  
  /**
   * @author <a href="mailto:tom at jboss.org">Tom Elrod</a>
   */
  public class MultiThreadedSpringRMIPerformanceTestCase extends SpringRMIPerformanceTestCase
       {
          protected String getClientTestClass()
          {
             return MultiThreadedSpringRMIPerformanceClient.class.getName();
          }
  
  }
  
  
  1.1      date: 2006/08/13 19:30:05;  author: telrod;  state: Exp;JBossRemoting/src/tests/org/jboss/test/remoting/performance/spring/rmi/SpringRMICallbackServer.java
  
  Index: SpringRMICallbackServer.java
  ===================================================================
  /***************************************
   *                                     *
   *  JBoss: The OpenSource J2EE WebOS   *
   *                                     *
   *  Distributable under LGPL license.  *
   *  See terms of license at gnu.org.   *
   *                                     *
   ***************************************/
  package org.jboss.test.remoting.performance.spring.rmi;
  
  import EDU.oswego.cs.dl.util.concurrent.Latch;
  import org.jboss.remoting.callback.InvokerCallbackHandler;
  import org.jboss.test.remoting.performance.synchronous.PerformanceCallbackKeeper;
  
  /**
   * @author <a href="mailto:tom at jboss.org">Tom Elrod</a>
   */
  public interface SpringRMICallbackServer extends PerformanceCallbackKeeper, InvokerCallbackHandler
  {
      public void finishedProcessing(Object obj);
  
     void setClientSessionId(String clientSessionId);
  
     void setServerDoneLock(Latch serverDoneLock);
  }
  
  
  1.1      date: 2006/08/13 19:30:05;  author: telrod;  state: Exp;JBossRemoting/src/tests/org/jboss/test/remoting/performance/spring/rmi/SpringRMICallbackServerImpl.java
  
  Index: SpringRMICallbackServerImpl.java
  ===================================================================
  /***************************************
   *                                     *
   *  JBoss: The OpenSource J2EE WebOS   *
   *                                     *
   *  Distributable under LGPL license.  *
   *  See terms of license at gnu.org.   *
   *                                     *
   ***************************************/
  package org.jboss.test.remoting.performance.spring.rmi;
  
  import EDU.oswego.cs.dl.util.concurrent.Latch;
  import org.jboss.remoting.callback.Callback;
  import org.jboss.remoting.callback.HandleCallbackException;
  
  /**
   * @author <a href="mailto:tom at jboss.org">Tom Elrod</a>
   */
  public class SpringRMICallbackServerImpl implements SpringRMICallbackServer
  {
     private String sessionId;
     private Latch lock;
     private int numberOfCallsProcessed = 0;
     private int numberOfDuplicates = 0;
  
  
  //   public SpringRMICallbackServerImpl(String sessionId, Latch lock)
  //   {
  //      this.sessionId = sessionId;
  //      this.lock = lock;
  //   }
  
     public void finishedProcessing(Object obj)
     {
        System.out.println("finishedProcessing called with " + obj);
        Callback callback = (Callback)obj;
        try
        {
           handleCallback(callback);
        }
        catch(HandleCallbackException e)
        {
           e.printStackTrace();
        }
     }
  
     public void setClientSessionId(String clientSessionId)
     {
        this.sessionId = clientSessionId;
     }
  
     public void setServerDoneLock(Latch serverDoneLock)
     {
        this.lock = serverDoneLock;
     }
  
     public int getNumberOfCallsProcessed()
     {
        return numberOfCallsProcessed;
     }
  
     public int getNumberOfDuplicates()
     {
        return numberOfDuplicates;
     }
  
     public void handleCallback(Callback callback) throws HandleCallbackException
     {
        Object ret = callback.getCallbackObject();
        Integer[] handledArray = (Integer[])ret;
        Integer numOfCallsHandled = (Integer) handledArray[0];
        Integer numOfDuplicates = (Integer) handledArray[1];
        System.out.println("Server is done.  Number of calls handled: " + numOfCallsHandled);
        numberOfCallsProcessed = numOfCallsHandled.intValue();
        System.out.println("Number of duplicate calls: " + numOfDuplicates);
        numberOfDuplicates = numOfDuplicates.intValue();
        Object obj = callback.getCallbackHandleObject();
        //String handbackObj = (String) obj;
        //System.out.println("Handback object should be " + sessionId + " and server called back with " + handbackObj);
        lock.release();
  
     }
  
  }
  
  
  1.1      date: 2006/08/13 19:30:05;  author: telrod;  state: Exp;JBossRemoting/src/tests/org/jboss/test/remoting/performance/spring/rmi/SpringRMICallbackServerService.xml
  
  Index: SpringRMICallbackServerService.xml
  ===================================================================
  <?xml version="1.0" encoding="UTF-8"?>
  
  <!DOCTYPE beans PUBLIC "-//SPRING//DTD BEAN//EN"
  
        "http://www.springframework.org/dtd/spring-beans.dtd">
  
  <beans>
  
     <bean class="org.jboss.test.remoting.performance.spring.rmi.SpringRMIHandler">
        <property name="springRMICallbackServerService" ref="springRMICallbackServerService"/>
     </bean>
  
     <bean id="springRMICallbackServerService" class="org.springframework.remoting.rmi.RmiProxyFactoryBean">
        <property name="serviceUrl" value="rmi://localhost:1299/SpringRMICallbackServerService"/>
        <property name="serviceInterface" value="org.jboss.test.remoting.performance.spring.rmi.SpringRMICallbackServer"/>
     </bean>
  
  
  </beans>
  
  
  1.1      date: 2006/08/13 19:30:05;  author: telrod;  state: Exp;JBossRemoting/src/tests/org/jboss/test/remoting/performance/spring/rmi/SpringRMIClientService.xml
  
  Index: SpringRMIClientService.xml
  ===================================================================
  <?xml version="1.0" encoding="UTF-8"?>
  
  <!DOCTYPE beans PUBLIC "-//SPRING//DTD BEAN//EN"
  
        "http://www.springframework.org/dtd/spring-beans.dtd">
  
  <beans>
  
     <bean class="org.jboss.test.remoting.performance.spring.rmi.SpringRMIPerformanceClient">
        <property name="springRMIServerService" ref="springRMIServerService"/>
     </bean>
  
     <bean id="springRMIServerService" class="org.springframework.remoting.rmi.RmiProxyFactoryBean">
        <property name="serviceUrl" value="rmi://localhost:1199/SpringRMIServerService"/>
        <property name="serviceInterface" value="org.jboss.test.remoting.performance.spring.rmi.SpringRMIServer"/>
     </bean>
  
     <bean class="org.springframework.remoting.rmi.RmiServiceExporter">
        <property name="serviceName" value="SpringRMICallbackServerService"/>
        <property name="service" ref="springRMICallbackServerService"/>
        <property name="servicePort" value="1300"/>
        <property name="serviceInterface" value="org.jboss.test.remoting.performance.spring.rmi.SpringRMICallbackServer"/>
        <property name="registryPort" value="1299"/>
     </bean>
  
     <bean id="springRMICallbackServerService"
           class="org.jboss.test.remoting.performance.spring.rmi.SpringRMICallbackServerImpl">
     </bean>
  
  
  </beans>
  
  
  1.1      date: 2006/08/13 19:30:05;  author: telrod;  state: Exp;JBossRemoting/src/tests/org/jboss/test/remoting/performance/spring/rmi/SpringRMIHandler.java
  
  Index: SpringRMIHandler.java
  ===================================================================
  /***************************************
   *                                     *
   *  JBoss: The OpenSource J2EE WebOS   *
   *                                     *
   *  Distributable under LGPL license.  *
   *  See terms of license at gnu.org.   *
   *                                     *
   ***************************************/
  package org.jboss.test.remoting.performance.spring.rmi;
  
  import org.jboss.remoting.callback.Callback;
  import org.jboss.remoting.callback.HandleCallbackException;
  import org.jboss.remoting.callback.InvokerCallbackHandler;
  import org.springframework.beans.factory.BeanFactory;
  import org.springframework.beans.factory.xml.XmlBeanFactory;
  import org.springframework.core.io.ClassPathResource;
  import org.springframework.core.io.Resource;
  
  /**
   * @author <a href="mailto:tom at jboss.org">Tom Elrod</a>
   */
  public class SpringRMIHandler implements InvokerCallbackHandler
  {
     private SpringRMICallbackServer springRMICallbackServer;
  
     public void start()
     {
        Resource res = new ClassPathResource("SpringRMICallbackServerService.xml", SpringRMIHandler.class);
        BeanFactory factory = new XmlBeanFactory(res);
        springRMICallbackServer = (SpringRMICallbackServer)factory.getBean("springRMICallbackServerService");
  
     }
  
     public SpringRMICallbackServer getSpringRMICallbackServer()
     {
        return springRMICallbackServer;
     }
  
     public void setSpringRMICallbackServer(SpringRMICallbackServer springRMICallbackServer)
     {
        this.springRMICallbackServer = springRMICallbackServer;
     }
  
     public void handleCallback(Callback callback) throws HandleCallbackException
     {
        System.out.println("Need to make call on SpringRMICallbackServer with results. " + callback);
  
        try
        {
           springRMICallbackServer.finishedProcessing(callback);
        }
        catch(Exception e)
        {
           e.printStackTrace();
           throw new HandleCallbackException(e.getMessage());
        }
     }
  }
  
  
  1.1      date: 2006/08/13 19:30:05;  author: telrod;  state: Exp;JBossRemoting/src/tests/org/jboss/test/remoting/performance/spring/rmi/SpringRMIPerformanceClient.java
  
  Index: SpringRMIPerformanceClient.java
  ===================================================================
  /***************************************
   *                                     *
   *  JBoss: The OpenSource J2EE WebOS   *
   *                                     *
   *  Distributable under LGPL license.  *
   *  See terms of license at gnu.org.   *
   *                                     *
   ***************************************/
  package org.jboss.test.remoting.performance.spring.rmi;
  
  import EDU.oswego.cs.dl.util.concurrent.Latch;
  import junit.framework.Test;
  import org.jboss.jrunit.decorators.ThreadLocalDecorator;
  import org.jboss.logging.Logger;
  import org.jboss.remoting.InvokerLocator;
  import org.jboss.test.remoting.performance.synchronous.PerformanceCallbackKeeper;
  import org.jboss.test.remoting.performance.synchronous.PerformanceClientTest;
  import org.springframework.beans.factory.BeanFactory;
  import org.springframework.beans.factory.xml.XmlBeanFactory;
  import org.springframework.context.ApplicationContext;
  import org.springframework.context.support.FileSystemXmlApplicationContext;
  import org.springframework.core.io.ClassPathResource;
  import org.springframework.core.io.Resource;
  
  import java.rmi.server.UID;
  import java.util.Map;
  
  /**
   * @author <a href="mailto:tom at jboss.org">Tom Elrod</a>
   */
  public class SpringRMIPerformanceClient extends PerformanceClientTest
  {
  
     private SpringRMIServer springRMIServerService;
     private String clientSessionId = new UID().toString();
  
     protected static final Logger log = Logger.getLogger(SpringRMIPerformanceClient.class);
  
     public static Test suite()
     {
        return new ThreadLocalDecorator(SpringRMIPerformanceClient.class, 1);
     }
  
     public SpringRMIServer getSpringRMIServerService()
     {
        return springRMIServerService;
     }
  
     public void setSpringRMIServerService(SpringRMIServer springRMIServerService)
     {
        this.springRMIServerService = springRMIServerService;
     }
  
     public void init()
     {
  
        Resource res = new ClassPathResource("SpringRMIClientService.xml", SpringRMIPerformanceClient.class);
        BeanFactory factory = new XmlBeanFactory(res);
        springRMIServerService = (SpringRMIServer)factory.getBean("springRMIServerService");
  
        /*
        //super.init();
  
        String name = "//localhost/RMIServer";
  //         RMIServer svr = (RMIServer) Naming.lookup(name);
  
        try
        {
           //Registry regsitry = LocateRegistry.getRegistry("localhost", rmiPort);
           Registry regsitry = LocateRegistry.getRegistry(rmiPort);
           Remote remoteObj = regsitry.lookup(name);
           rmiServer = (RMIServerRemote) remoteObj;
        }
        catch(Exception e)
        {
           log.error("Error initializating rmi client.", e);
        }
        */
     }
  
     /**
      * This will be used to create callback server
      *
      * @param port
      * @return
      * @throws Exception
      */
     protected InvokerLocator initServer(int port) throws Exception
     {
        return null;
     }
  
     protected PerformanceCallbackKeeper addCallbackListener(String sessionId, Latch serverDoneLock)
           throws Throwable
     {
        String springServiceXml = this.getClass().getResource("SpringRMIClientService.xml").getFile();
  
        ApplicationContext context = new FileSystemXmlApplicationContext(springServiceXml);
        SpringRMICallbackServer callbackServer = (SpringRMICallbackServer) context.getBean("springRMICallbackServerService");
        callbackServer.setClientSessionId(clientSessionId);
        callbackServer.setServerDoneLock(serverDoneLock);
        return callbackServer;
  
  //      RMICallbackServer callbackServer = new RMICallbackServer(clientSessionId, serverDoneLock);
  //      callbackServer.start();
  //      return callbackServer;
     }
  
     protected void populateMetadata(Map metadata)
     {
        super.populateMetadata(metadata);
        metadata.put("transport", "spring_rmi");
        metadata.put("serialization", "java");
     }
  
     protected Object getBenchmarkAlias()
     {
        String config = System.getProperty("alias");
        if(config == null || config.length() == 0)
        {
           config = System.getProperty("jboss-junit-configuration");
           if(config == null || config.length() == 0)
           {
              config = "spring_rmi" + "_" + getNumberOfCalls() + "_" + getPayloadSize() + "_" + "java";
           }
        }
        return config;
     }
  
  
     protected Object makeInvocation(String method, Object param) throws Throwable
     {
        if(method.equals(NUM_OF_CALLS))
        {
           return springRMIServerService.sendNumberOfCalls(clientSessionId, param);
        }
        else if(method.equals(TEST_INVOCATION))
        {
           return springRMIServerService.makeCall(clientSessionId, param);
        }
        else
        {
           throw new Exception("Was not able to find remote method call for " + method);
        }
     }
  
     public static void main(String[] args)
     {
        SpringRMIPerformanceClient test = new SpringRMIPerformanceClient();
        try
        {
           test.setUp();
           test.testClientCalls();
           test.tearDown();
        }
        catch(Throwable throwable)
        {
           throwable.printStackTrace();
        }
     }
  
  }
  
  
  1.1      date: 2006/08/13 19:30:05;  author: telrod;  state: Exp;JBossRemoting/src/tests/org/jboss/test/remoting/performance/spring/rmi/SpringRMIPerformanceServer.java
  
  Index: SpringRMIPerformanceServer.java
  ===================================================================
  /***************************************
   *                                     *
   *  JBoss: The OpenSource J2EE WebOS   *
   *                                     *
   *  Distributable under LGPL license.  *
   *  See terms of license at gnu.org.   *
   *                                     *
   ***************************************/
  package org.jboss.test.remoting.performance.spring.rmi;
  
  import org.jboss.test.remoting.performance.synchronous.PerformanceServerTest;
  import org.springframework.context.ApplicationContext;
  import org.springframework.context.support.FileSystemXmlApplicationContext;
  
  import java.util.Map;
  
  /**
   * @author <a href="mailto:tom at jboss.org">Tom Elrod</a>
   */
  public class SpringRMIPerformanceServer extends PerformanceServerTest
  {
     public void init(Map metadata)
     {
        String springServiceXml = this.getClass().getResource("SpringRMIServerService.xml").getFile();
  
        ApplicationContext context = new FileSystemXmlApplicationContext(springServiceXml);
        SpringRMIServer server = (SpringRMIServer) context.getBean("springRMIServerService");
     }
  
     public static void main(String[] args)
     {
        PerformanceServerTest server = new SpringRMIPerformanceServer();
        try
        {
           server.setUp();
           Thread.currentThread().sleep(60000);
           server.tearDown();
        }
        catch (Exception e)
        {
           e.printStackTrace();
        }
     }
  
  }
  
  
  1.1      date: 2006/08/13 19:30:05;  author: telrod;  state: Exp;JBossRemoting/src/tests/org/jboss/test/remoting/performance/spring/rmi/SpringRMIPerformanceTestCase.java
  
  Index: SpringRMIPerformanceTestCase.java
  ===================================================================
  /***************************************
   *                                     *
   *  JBoss: The OpenSource J2EE WebOS   *
   *                                     *
   *  Distributable under LGPL license.  *
   *  See terms of license at gnu.org.   *
   *                                     *
   ***************************************/
  package org.jboss.test.remoting.performance.spring.rmi;
  
  import org.apache.log4j.Level;
  import org.jboss.jrunit.harness.BenchmarkTestDriver;
  
  import java.io.IOException;
  
  /**
   * @author <a href="mailto:tom at jboss.org">Tom Elrod</a>
   */
  public class SpringRMIPerformanceTestCase extends BenchmarkTestDriver
  {
     protected int numberOfClients = 1;
  
     public static final String REMOTING_TRANSPORT = "remoting.transport";
     public static final String REMOTING_METADATA = "remoting.metadata";
     public static final String REMOTING_SERIALIZATION = "remoting.serialization";
     public static final String PAYLOAD_SIZE = "remoting.payload.size";
     public static final String NUMBER_OF_CLIENTS = "remoting.number_of_clients";
     public static final String NUMBER_OF_CALLS = "remoting.number_of_calls";
     public static final String JVM_MAX_HEAP_SIZE = "jvm.mx";
     public static final String RESULT_TIMEOUT = "jrunit.result_timeout";
     public static final String TEAR_DOWN_TIMEOUT = "jrunit.tear_down_timeout";
     public static final String RUN_TEST_TIMEOUT = "jrunit.run_test_timeout";
  
     public void declareTestClasses()
     {
        //**************** LOGGING ***********************
        org.apache.log4j.BasicConfigurator.configure();
        org.apache.log4j.Category.getRoot().setLevel(Level.DEBUG);
        //org.apache.log4j.Category.getInstance("org.jboss.remoting").setLevel(Level.DEBUG);
  
        org.apache.log4j.SimpleLayout layout = new org.apache.log4j.SimpleLayout();
  
        try
        {
           org.apache.log4j.FileAppender fileAppender = new org.apache.log4j.FileAppender(layout, "debug_output.log");
           fileAppender.setThreshold(Level.DEBUG);
           fileAppender.setAppend(false);
           org.apache.log4j.Category.getRoot().addAppender(fileAppender);
        }
        catch(IOException e)
        {
           e.printStackTrace();
        }
        //*************** END LOGGING ***********************
  
  
        String numOfClients = System.getProperty(NUMBER_OF_CLIENTS);
        if(numOfClients != null && numOfClients.length() > 0)
        {
           try
           {
              numberOfClients = Integer.parseInt(numOfClients);
           }
           catch(NumberFormatException e)
           {
              e.printStackTrace();
           }
        }
  
        addTestClasses(getClientTestClass(),
                       numberOfClients,
                       SpringRMIPerformanceServer.class.getName());
     }
  
     protected String getClientTestClass()
     {
        return SpringRMIPerformanceClient.class.getName();
     }
  
     protected Level getTestHarnessLogLevel()
     {
        return Level.INFO;
        //return Level.DEBUG;
     }
  
     /**
      * The log level to run as for the test case.
      *
      * @return
      */
     protected Level getTestLogLevel()
     {
        return Level.INFO;
        //return Level.DEBUG;
     }
  
     /**
      * Returns the VM arguments to be passed to the vm when creating the client test cases (actually their harness).
      * The default value is null.
      *
      * @return
      */
     protected String getClientJVMArguments()
     {
        return getJVMArguments();
  //      String args = "-Xdebug -Xnoagent -Djava.compiler=NONE -Xrunjdwp:transport=dt_socket,server=y,suspend=y,address=5000 ";
  //      args = args + getJVMArguments();
  //      return args;
     }
  
     /**
      * Returns the VM arguments to be passed to the vm when creating the server test cases (actually their harness).
      * The default value is null.
      *
      * @return
      */
     protected String getServerJVMArguments()
     {
        return getJVMArguments();
     }
  
     /**
      * Returns the VM arguments to be passed to the vm when creating the client and server test cases (actually their harness).
      * The default value is null.
      *
      * @return
      */
     private String getJVMArguments()
     {
        String vmArgs = "";
  
        String transport = System.getProperty(REMOTING_TRANSPORT);
        if(transport != null && transport.length() > 0)
        {
           vmArgs = "-D" + REMOTING_TRANSPORT + "=" + transport;
        }
        String serialization = System.getProperty(REMOTING_SERIALIZATION);
        if(serialization != null && serialization.length() > 0)
        {
           vmArgs = vmArgs + " -D" + REMOTING_SERIALIZATION + "=" + serialization;
        }
        String metadata = System.getProperty(REMOTING_METADATA);
        if(metadata != null && metadata.length() > 0)
        {
           vmArgs = vmArgs + " -D" + REMOTING_METADATA + "=" + metadata;
        }
        String payloadSize = System.getProperty(PAYLOAD_SIZE);
        if(payloadSize != null && payloadSize.length() > 0)
        {
           vmArgs = vmArgs + " -D" + PAYLOAD_SIZE + "=" + payloadSize;
        }
        String numOfCalls = System.getProperty(NUMBER_OF_CALLS);
        if(numOfCalls != null && numOfCalls.length() > 0)
        {
           vmArgs = vmArgs + " -D" + NUMBER_OF_CALLS + "=" + numOfCalls;
        }
        String jvmMx = System.getProperty(JVM_MAX_HEAP_SIZE);
        if(jvmMx != null && jvmMx.length() > 0)
        {
           vmArgs = vmArgs + " -Xmx" + jvmMx + "m";
        }
  
        return vmArgs;
     }
  
     /**
      * How long to wait for test results to be returned from the client(s).  If goes longer than the
      * specified limit, will throw an exception and kill the running test cases.  Default value is
      * RESULTS_TIMEOUT.
      *
      * @return
      */
     protected long getResultsTimeout()
     {
        long defaultTimeout = 600000; // default to 10 minutes
  
        String timeout = System.getProperty(RESULT_TIMEOUT);
        if(timeout != null && timeout.length() > 0)
        {
           try
           {
              defaultTimeout = Long.parseLong(timeout);
           }
           catch(NumberFormatException e)
           {
              System.out.println("Can not use " + timeout + " as timeout value as is not a number");
           }
        }
        return defaultTimeout;
     }
  
     /**
      * How long for the server test case to wait for tear down message.  If exceeds timeout,
      * will throw exception.  The default value is TEARDOWN_TIMEOUT.
      *
      * @return
      */
     protected long getTearDownTimeout()
     {
        long defaultTimeout = 600000; // default to 10 minutes
  
        String timeout = System.getProperty(TEAR_DOWN_TIMEOUT);
        if(timeout != null && timeout.length() > 0)
        {
           try
           {
              defaultTimeout = Long.parseLong(timeout);
           }
           catch(NumberFormatException e)
           {
              System.out.println("Can not use " + timeout + " as timeout value as is not a number");
           }
        }
        return defaultTimeout;
     }
  
     /**
      * How long to allow each of the test cases to run their tests.  If exceeds this timeout
      * will throw exception and kill tests.  The default value is RUN_TEST_TIMEOUT.
      *
      * @return
      */
     protected long getRunTestTimeout()
     {
        long defaultTimeout = 600000; // default to 10 minutes
  
        String timeout = System.getProperty(RUN_TEST_TIMEOUT);
        if(timeout != null && timeout.length() > 0)
        {
           try
           {
              defaultTimeout = Long.parseLong(timeout);
           }
           catch(NumberFormatException e)
           {
              System.out.println("Can not use " + timeout + " as timeout value as is not a number");
           }
        }
        return defaultTimeout;
     }
  
  
  }
  
  
  1.1      date: 2006/08/13 19:30:05;  author: telrod;  state: Exp;JBossRemoting/src/tests/org/jboss/test/remoting/performance/spring/rmi/SpringRMIServer.java
  
  Index: SpringRMIServer.java
  ===================================================================
  /***************************************
   *                                     *
   *  JBoss: The OpenSource J2EE WebOS   *
   *                                     *
   *  Distributable under LGPL license.  *
   *  See terms of license at gnu.org.   *
   *                                     *
   ***************************************/
  package org.jboss.test.remoting.performance.spring.rmi;
  
  /**
   * @author <a href="mailto:tom at jboss.org">Tom Elrod</a>
   */
  public interface SpringRMIServer
  {
     public Object makeCall(Object obj, Object param);
  
     public Object sendNumberOfCalls(Object obj, Object param);
  
  }
  
  
  1.1      date: 2006/08/13 19:30:05;  author: telrod;  state: Exp;JBossRemoting/src/tests/org/jboss/test/remoting/performance/spring/rmi/SpringRMIServerImpl.java
  
  Index: SpringRMIServerImpl.java
  ===================================================================
  /***************************************
   *                                     *
   *  JBoss: The OpenSource J2EE WebOS   *
   *                                     *
   *  Distributable under LGPL license.  *
   *  See terms of license at gnu.org.   *
   *                                     *
   ***************************************/
  package org.jboss.test.remoting.performance.spring.rmi;
  
  import EDU.oswego.cs.dl.util.concurrent.ConcurrentHashMap;
  import org.jboss.test.remoting.performance.synchronous.CallTracker;
  import org.jboss.test.remoting.performance.synchronous.Payload;
  
  import java.util.Map;
  
  /**
   * @author <a href="mailto:tom at jboss.org">Tom Elrod</a>
   */
  public class SpringRMIServerImpl implements SpringRMIServer
  {
     private Map callTrackers = new ConcurrentHashMap();
  
     public Object sendNumberOfCalls(Object obj, Object param)
     {
        System.out.println("sent number of calls " + obj + " " + param);
        String sessionId = (String) obj;
        Integer totalCountInteger = (Integer) param;
        int totalCount = totalCountInteger.intValue();
        System.out.println("received totalCallCount call with total count of " + totalCount + " from " + sessionId);
        CallTracker tracker = (CallTracker) callTrackers.get(sessionId);
        if (tracker != null)
        {
           tracker.createTotalCount(totalCount);
        }
        else
        {
           SpringRMIHandler callbackHandler = new SpringRMIHandler();
           callbackHandler.start();
           tracker = new CallTracker(sessionId, callbackHandler);
           callTrackers.put(sessionId, tracker);
           tracker.createTotalCount(totalCount);
        }
        return totalCountInteger;
     }
  
     public Object makeCall(Object obj, Object param)
     {
        Payload payload = (Payload) param;
        int clientInvokeCallCount = payload.getCallNumber();
  
        String sessionId = (String) obj;
        CallTracker tracker = (CallTracker) callTrackers.get(sessionId);
        if (tracker != null)
        {
           tracker.verifyClientInvokeCount(clientInvokeCallCount);
        }
        else
        {
           System.err.println("No call tracker exists for session id " + sessionId);
           throw new RuntimeException("No call tracker exists for session id " + sessionId);
        }
  
        return new Integer(clientInvokeCallCount);
     }
  
  }
  
  
  1.1      date: 2006/08/13 19:30:05;  author: telrod;  state: Exp;JBossRemoting/src/tests/org/jboss/test/remoting/performance/spring/rmi/SpringRMIServerService.xml
  
  Index: SpringRMIServerService.xml
  ===================================================================
  <?xml version="1.0" encoding="UTF-8"?>
  
  <!DOCTYPE beans PUBLIC "-//SPRING//DTD BEAN//EN"
  
        "http://www.springframework.org/dtd/spring-beans.dtd">
  
  <beans>
  
     <bean class="org.springframework.remoting.rmi.RmiServiceExporter">
        <property name="serviceName" value="SpringRMIServerService"/>
        <property name="service" ref="springRMIServerService"/>
        <property name="servicePort" value="1200"/>
        <property name="serviceInterface" value="org.jboss.test.remoting.performance.spring.rmi.SpringRMIServer"/>
        <property name="registryPort" value="1199"/>
     </bean>
  
     <bean id="springRMIServerService" class="org.jboss.test.remoting.performance.spring.rmi.SpringRMIServerImpl">
     </bean>
  
  </beans>
  
  



More information about the jboss-cvs-commits mailing list