1
package org.jboss.test.remoting.transport.socket.stress;
3
import org.jboss.remoting.Client;
4
import org.jboss.remoting.InvokerLocator;
7
* @author <a href="mailto:tom.elrod@jboss.com">Tom Elrod</a>
9
public class SocketInvokerClientTest
11
private int numOfThreads = 250;
12
// private int numOfCalls = 1000;
13
private int numOfCalls = 1000000;
15
// private int maxClientPoolSize = 50;
16
private int maxClientPoolSize = 250;
18
private boolean[] finishedThreads = new boolean[numOfThreads];
20
public String getTransport()
25
public void testClientCalls() throws Exception
27
Thread currentThread = null;
29
for (int x = 0; x < numOfThreads; x++)
31
currentThread = new Thread(new Runnable()
39
InvokerLocator locator = new InvokerLocator(getTransport() + "://" + "localhost" + ":" + 6700 + "/?" +
40
"clientMaxPoolSize=" + maxClientPoolSize);
41
client = new Client(locator);
43
String threadName = Thread.currentThread().getName();
44
for (int i = 0; i < numOfCalls; i++)
46
Object ret = client.invoke(threadName);
47
if(!ret.equals(threadName))
49
System.out.println("ERROR - Should have returned " + threadName + " but returned " + ret);
52
if(i % 500 == 0 && i > 0)
54
System.out.println("Thread " + threadName + " has made " + i + " invocations.");
57
System.out.println(threadName + " -- done.");
58
int threadNum = Integer.parseInt(threadName);
59
finishedThreads[threadNum] = true;
71
currentThread.start();
75
// Thread.currentThread().sleep(300000);
76
Thread.currentThread().sleep(7200000);
78
for (int r = 0; r < finishedThreads.length; r++)
80
if (!finishedThreads[r])
82
System.out.println("Failed - thread " + r + " never finished.");
87
public static void main(String[] args)
89
SocketInvokerClientTest client = new SocketInvokerClientTest();
92
client.testClientCalls();