KickJava   Java API By Example, From Geeks To Geeks.

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


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 ClientOnewayInvocationTest extends OnewayTest
20 {
21    public ClientOnewayInvocationTest(String JavaDoc name)
22    {
23       super(name);
24    }
25
26    public ClientOnewayInvocationTest(int numberOfInstances)
27    {
28       super(numberOfInstances);
29    }
30
31    public ClientOnewayInvocationTest(String JavaDoc transport, int port)
32    {
33       super(transport, port);
34    }
35
36    public ClientOnewayInvocationTest(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 client oneway.\n" +
45                          "*****************************************************\n");
46    }
47
48    protected Runnable JavaDoc getRunner(String JavaDoc method)
49    {
50       return new ClientRunner(method);
51    }
52
53    public void testOnewayServerInvocation() 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 ClientRunner implements Runnable JavaDoc
65    {
66       private String JavaDoc method;
67
68       public ClientRunner(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                superMakeClientOnewayInvocation(this.method, String.valueOf(incrementCallCount()));
80             }
81             catch(Throwable JavaDoc throwable)
82             {
83                throwable.printStackTrace();
84             }
85          }
86       }
87
88    }
89
90    public static void main(String JavaDoc[] args)
91    {
92
93       org.apache.log4j.BasicConfigurator.configure();
94       org.apache.log4j.Category.getRoot().setLevel(Level.INFO);
95       org.apache.log4j.Category.getInstance("org.jgroups").setLevel(Level.INFO);
96       //org.apache.log4j.Category.getInstance("org.jboss.remoting").setLevel(Level.DEBUG);
97
//org.apache.log4j.Category.getInstance("test").setLevel(Level.DEBUG);
98

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