KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > jboss > remoting > performance > oneway > ServerOnewayInvocationTest


1 /*
2  * JBoss, the OpenSource J2EE webOS
3  *
4  * Distributable under LGPL license.
5  * See terms of license at gnu.org.
6  */

7 package org.jboss.remoting.performance.oneway;
8
9 import org.apache.log4j.Level;
10 import org.jboss.dtf.MultipleTestRunner;
11 import org.jboss.remoting.oneway.OnewayInvokerClientTest;
12 import org.jboss.remoting.performance.PerformanceTest;
13
14 /**
15  * Makes oneway (client side thread pooling) call a number of times using multiple threads
16  *
17  * @author <a HREF="mailto:telrod@e2technologies.net">Tom Elrod</a>
18  */

19 public class ServerOnewayInvocationTest extends OnewayTest
20 {
21    public ServerOnewayInvocationTest(String JavaDoc name)
22    {
23       super(name);
24    }
25
26    public ServerOnewayInvocationTest(int numberOfInstances)
27    {
28       super(numberOfInstances);
29    }
30
31    public ServerOnewayInvocationTest(String JavaDoc transport, int port)
32    {
33       super(transport, port);
34    }
35
36    public ServerOnewayInvocationTest(String JavaDoc transport, int port, int numberOfInstances)
37    {
38       super(transport, port, numberOfInstances);
39    }
40
41    protected void printStartMessage()
42    {
43       System.out.println("\n*****************************************************\n" +
44                          "Starting oneway preformance test with server oneway.\n" +
45                          "*****************************************************\n");
46    }
47
48    protected Runnable JavaDoc getRunner(String JavaDoc method)
49    {
50       return new ServerRunner(method);
51    }
52
53    public void testOnewayClientInvocation() throws Throwable JavaDoc
54    {
55       //NO OP since don't want to run this one in this case
56
}
57
58    public void testInvocation() throws Throwable JavaDoc
59    {
60       //NO OP since don't want to run this one in this case
61
}
62
63
64    public class ServerRunner implements Runnable JavaDoc
65    {
66       private String JavaDoc method;
67
68       public ServerRunner(String JavaDoc method)
69       {
70          this.method = method;
71       }
72
73       public void run()
74       {
75          for(int i = 0; i < PerformanceTest.NUM_OF_CALLS; i++)
76          {
77             try
78             {
79                superMakeServerOnewayInvocation(this.method,
80                                                String.valueOf(incrementCallCount()));
81             }
82             catch(Throwable JavaDoc throwable)
83             {
84                throwable.printStackTrace();
85             }
86          }
87       }
88    }
89
90
91    public static void main(String JavaDoc[] args)
92    {
93
94       org.apache.log4j.BasicConfigurator.configure();
95       org.apache.log4j.Category.getRoot().setLevel(Level.INFO);
96       org.apache.log4j.Category.getInstance("org.jgroups").setLevel(Level.INFO);
97       //org.apache.log4j.Category.getInstance("org.jboss.remoting").setLevel(Level.DEBUG);
98
//org.apache.log4j.Category.getInstance("test").setLevel(Level.DEBUG);
99

100       ServerOnewayInvocationTest client = null;
101       if(args.length == 1)
102       {
103          int instances = Integer.parseInt(args[0]);
104          client = new ServerOnewayInvocationTest(instances);
105       }
106       else if(args.length == 2)
107       {
108          String JavaDoc transport = args[0];
109          int port = Integer.parseInt(args[1]);
110          client = new ServerOnewayInvocationTest(transport, port);
111       }
112       else if(args.length == 3)
113       {
114          String JavaDoc transport = args[0];
115          int port = Integer.parseInt(args[1]);
116          int instances = Integer.parseInt(args[2]);
117          client = new ServerOnewayInvocationTest(transport, port, instances);
118       }
119       else
120       {
121          client = new ServerOnewayInvocationTest(OnewayInvokerClientTest.class.getName());
122          System.out.println("Using default transport (" + client.getTransport() +
123                             ") and default port (" + client.getPort() + ") and " +
124                             "default number of instances (" + client.getNumberOfInstances() + ")" +
125                             "\nCan enter transport, port, and instances via command line.");
126       }
127
128       try
129       {
130          //regular class run
131
//client.runInvokers();
132
MultipleTestRunner runner = new MultipleTestRunner();
133          runner.doRun(client, true);
134       }
135       catch(Throwable JavaDoc e)
136       {
137          e.printStackTrace();
138          System.exit(1);
139       }
140       System.exit(0);
141    }
142
143 }
Popular Tags