Author: ron.sigal(a)jboss.com
Date: 2008-03-17 03:46:10 -0400 (Mon, 17 Mar 2008)
New Revision: 3657
Modified:
remoting2/branches/2.x/src/tests/org/jboss/test/remoting/soak/ClientLauncher.java
remoting2/branches/2.x/src/tests/org/jboss/test/remoting/soak/HeavyComputeClient.java
remoting2/branches/2.x/src/tests/org/jboss/test/remoting/soak/MockEJBClient.java
remoting2/branches/2.x/src/tests/org/jboss/test/remoting/soak/MockJBMClient.java
remoting2/branches/2.x/src/tests/org/jboss/test/remoting/soak/SoakConstants.java
Log:
JBREM-931: Better reporting.
Modified:
remoting2/branches/2.x/src/tests/org/jboss/test/remoting/soak/ClientLauncher.java
===================================================================
---
remoting2/branches/2.x/src/tests/org/jboss/test/remoting/soak/ClientLauncher.java 2008-03-17
07:36:49 UTC (rev 3656)
+++
remoting2/branches/2.x/src/tests/org/jboss/test/remoting/soak/ClientLauncher.java 2008-03-17
07:46:10 UTC (rev 3657)
@@ -22,9 +22,13 @@
package org.jboss.test.remoting.soak;
import java.net.InetAddress;
+import java.util.Collections;
import java.util.HashMap;
+import java.util.HashSet;
+import java.util.Iterator;
import java.util.Map;
import java.util.Random;
+import java.util.Set;
import java.util.Timer;
import java.util.TimerTask;
@@ -47,9 +51,9 @@
{
private static Logger log = Logger.getLogger(ClientLauncher.class);
- private static Counter mockEJBClientCurrentCounter = new Counter();
- private static Counter mockJBMClientCurrentCounter = new Counter();
- private static Counter heavyComputeClientCurrentCounter = new Counter();
+ private static Set mockEJBClientsInUse = Collections.synchronizedSet(new HashSet());
+ private static Set mockJBMClientsInUse = Collections.synchronizedSet(new HashSet());
+ private static Set heavyComputeClientsInUse = Collections.synchronizedSet(new
HashSet());
private static Counter mockEJBClientCounter = new Counter();
private static Counter mockJBMClientCounter = new Counter();
@@ -66,9 +70,18 @@
private static String host;
private static boolean creationDone;
- private static long DURATION = 3600000;
- private static int MAX_CLIENTS = 20;
+ // Configuration parameters.
+// private static long DURATION = 12 * 60 * 60 * 1000;
+// private static long DURATION = 1 * 60 * 60 * 1000;
+ private static long DURATION = 30000;
+ private static int MAX_CLIENTS = 30;
+ private static int NUMBER_OF_EJB_CALLS = 4000;
+ private static int NUMBER_OF_JBM_CALLS = 2000;
+ private static int NUMBER_OF_JBM_CALLBACKS = 4;
+ private static int NUMBER_OF_HEAVY_COMPUTE_CALLS = 5;
+ private static String HEAVY_COMPUTE_SPIN_TIME = "4000";
+
public static void main(String[] args)
{
try
@@ -88,14 +101,14 @@
while (System.currentTimeMillis() - start < DURATION)
{
- if (mockEJBClientCurrentCounter.getCount() +
- mockJBMClientCurrentCounter.getCount() +
- heavyComputeClientCurrentCounter.getCount() < MAX_CLIENTS)
+ if (mockEJBClientsInUse.size() +
+ mockJBMClientsInUse.size() +
+ heavyComputeClientsInUse.size() < MAX_CLIENTS)
{
createClient();
}
- int n = random.nextInt(80) * 100;
+ int n = random.nextInt(40) * 100;
log.debug("waiting " + n + " ms");
Thread.sleep(n);
}
@@ -113,7 +126,6 @@
protected static void createClient() throws Throwable
{
int k = random.nextInt(4);
- k = 3;
String transport = transports[k];
int port = ports[k];
transportCounters[k]++;
@@ -139,9 +151,9 @@
String locatorURI = transport + "://" + host + ":" + port +
"/?timeout=0";
Map metadata = new HashMap();
metadata.put(NAME, "MockEJBClient" + mockEJBClientCounter.increment() +
"[" + transport + "]");
- metadata.put(COUNTER, mockEJBClientCurrentCounter);
+ metadata.put(IN_USE_SET, mockEJBClientsInUse);
metadata.put(FAILURE_COUNTER, mockEJBClientFailureCounter);
- metadata.put(NUMBER_OF_CALLS, Integer.toString(random.nextInt(2000)));
+ metadata.put(NUMBER_OF_CALLS,
Integer.toString(random.nextInt(NUMBER_OF_EJB_CALLS)));
MockEJBClient c = new MockEJBClient(locatorURI, metadata);
Thread t = new Thread(c);
t.start();
@@ -153,10 +165,10 @@
String locatorURI = transport + "://" + host + ":" + port +
"/?timeout=0";
Map metadata = new HashMap();
metadata.put(NAME, "MockJBMClient" + mockJBMClientCounter.increment() +
"[" + transport + "]");
- metadata.put(COUNTER, mockJBMClientCurrentCounter);
+ metadata.put(IN_USE_SET, mockJBMClientsInUse);
metadata.put(FAILURE_COUNTER, mockJBMClientFailureCounter);
- metadata.put(NUMBER_OF_CALLS, Integer.toString(random.nextInt(1000)));
- metadata.put(NUMBER_OF_CALLBACKS, Integer.toString(random.nextInt(3)));
+ metadata.put(NUMBER_OF_CALLS,
Integer.toString(random.nextInt(NUMBER_OF_JBM_CALLS)));
+ metadata.put(NUMBER_OF_CALLBACKS,
Integer.toString(random.nextInt(NUMBER_OF_JBM_CALLBACKS)));
MockJBMClient c = new MockJBMClient(locatorURI, metadata);
Thread t = new Thread(c);
t.start();
@@ -168,10 +180,10 @@
String locatorURI = transport + "://" + host + ":" + port +
"/?timeout=0";
Map metadata = new HashMap();
metadata.put(NAME, "HeavyComputeClient" +
heavyComputeClientCounter.increment() + "[" + transport + "]");
- metadata.put(COUNTER, heavyComputeClientCurrentCounter);
+ metadata.put(IN_USE_SET, heavyComputeClientsInUse);
metadata.put(FAILURE_COUNTER, heavyComputeClientFailureCounter);
- metadata.put(NUMBER_OF_CALLS, Integer.toString(random.nextInt(5)));
- metadata.put(SPIN_TIME, "4000");
+ metadata.put(NUMBER_OF_CALLS,
Integer.toString(random.nextInt(NUMBER_OF_HEAVY_COMPUTE_CALLS)));
+ metadata.put(SPIN_TIME, HEAVY_COMPUTE_SPIN_TIME);
HeavyComputeClient c = new HeavyComputeClient(locatorURI, metadata);
heavyComputeClientCounter.increment();
Thread t = new Thread(c);
@@ -194,9 +206,9 @@
{
System.out.println("");
System.out.println("=========================================");
- System.out.println("current MockEJBCLients: " +
mockEJBClientCurrentCounter.getCount());
- System.out.println("current MockJBMClients: " +
mockJBMClientCurrentCounter.getCount());
- System.out.println("current HeavyComputeClients: " +
heavyComputeClientCurrentCounter.getCount());
+ System.out.println("current MockEJBCLients: " +
mockEJBClientsInUse.size());
+ System.out.println("current MockJBMClients: " +
mockJBMClientsInUse.size());
+ System.out.println("current HeavyComputeClients: " +
heavyComputeClientsInUse.size());
System.out.println("-----------------------------------------");
System.out.println("bisocket clients: " +
transportCounters[0]);
System.out.println("http clients: " +
transportCounters[1]);
@@ -206,15 +218,29 @@
System.out.println("failed MockEJBCLients: " +
mockEJBClientFailureCounter.getCount());
System.out.println("failed MockJBMClients: " +
mockJBMClientFailureCounter.getCount());
System.out.println("failed HeavyComputeClients: " +
heavyComputeClientFailureCounter.getCount());
+ System.out.println("-----------------------------------------");
+ printSet(mockEJBClientsInUse);
+ printSet(mockJBMClientsInUse);
+ printSet(heavyComputeClientsInUse);
System.out.println("=========================================");
System.out.println("");
- if (creationDone &&
- mockEJBClientCurrentCounter.getCount() == 0 &&
- mockJBMClientCurrentCounter.getCount() == 0 &&
- heavyComputeClientCurrentCounter.getCount() == 0)
+ if (creationDone &&
+ mockEJBClientsInUse.size() == 0 &&
+ mockJBMClientsInUse.size() == 0 &&
+ heavyComputeClientsInUse.size() == 0)
+
cancel();
}
+
+ private void printSet(Set set)
+ {
+ Iterator it = set.iterator();
+ while(it.hasNext())
+ {
+ System.out.println(it.next().toString());
+ }
+ }
}
}
Modified:
remoting2/branches/2.x/src/tests/org/jboss/test/remoting/soak/HeavyComputeClient.java
===================================================================
---
remoting2/branches/2.x/src/tests/org/jboss/test/remoting/soak/HeavyComputeClient.java 2008-03-17
07:36:49 UTC (rev 3656)
+++
remoting2/branches/2.x/src/tests/org/jboss/test/remoting/soak/HeavyComputeClient.java 2008-03-17
07:46:10 UTC (rev 3657)
@@ -21,8 +21,8 @@
*/
package org.jboss.test.remoting.soak;
-import java.util.HashMap;
import java.util.Map;
+import java.util.Set;
import org.apache.log4j.Logger;
import org.jboss.remoting.Client;
@@ -45,7 +45,7 @@
protected Map metadata;
protected String name;
protected boolean ok = true;
- protected ClientLauncher.Counter counter;
+ protected Set inUseSet;
protected ClientLauncher.Counter failureCounter;
public HeavyComputeClient(String locator, Map metadata) throws Exception
@@ -53,8 +53,8 @@
this.locator = new InvokerLocator(locator);
this.metadata = metadata;
this.name = (String) metadata.get(SoakConstants.NAME);
- counter = (ClientLauncher.Counter) metadata.remove(COUNTER);
- counter.increment();
+ this.inUseSet = (Set) metadata.remove(IN_USE_SET);
+ inUseSet.add(this);
failureCounter = (ClientLauncher.Counter) metadata.remove(FAILURE_COUNTER);
log.info("created " + name);
}
@@ -77,7 +77,7 @@
finally
{
log.info(name + ": " + (ok ? "PASS" : "FAIL"));
- counter.decrement();
+ inUseSet.remove(this);
if (!ok) failureCounter.increment();
}
}
@@ -108,5 +108,10 @@
client.disconnect();
}
}
+
+ public String toString()
+ {
+ return name;
+ }
}
Modified:
remoting2/branches/2.x/src/tests/org/jboss/test/remoting/soak/MockEJBClient.java
===================================================================
---
remoting2/branches/2.x/src/tests/org/jboss/test/remoting/soak/MockEJBClient.java 2008-03-17
07:36:49 UTC (rev 3656)
+++
remoting2/branches/2.x/src/tests/org/jboss/test/remoting/soak/MockEJBClient.java 2008-03-17
07:46:10 UTC (rev 3657)
@@ -23,6 +23,7 @@
import java.util.HashMap;
import java.util.Map;
+import java.util.Set;
import org.apache.log4j.Logger;
import org.jboss.remoting.Client;
@@ -45,7 +46,7 @@
protected Map metadata;
protected String name;
protected boolean ok = true;
- protected ClientLauncher.Counter counter;
+ protected Set inUseSet;
protected ClientLauncher.Counter failureCounter;
public MockEJBClient(String locator, Map metadata) throws Exception
@@ -53,8 +54,8 @@
this.locator = new InvokerLocator(locator);
this.metadata = metadata;
this.name = (String) metadata.get(SoakConstants.NAME);
- counter = (ClientLauncher.Counter) metadata.remove(COUNTER);
- counter.increment();
+ this.inUseSet = (Set) metadata.remove(IN_USE_SET);
+ inUseSet.add(this);
failureCounter = (ClientLauncher.Counter) metadata.remove(FAILURE_COUNTER);
log.info("created " + name);
}
@@ -76,7 +77,7 @@
}
finally
{
- counter.decrement();
+ inUseSet.remove(this);
log.info(name + ": " + (ok ? "PASS" : "FAIL"));
if (!ok) failureCounter.increment();
}
@@ -110,5 +111,10 @@
client.disconnect();
}
}
+
+ public String toString()
+ {
+ return name;
+ }
}
Modified:
remoting2/branches/2.x/src/tests/org/jboss/test/remoting/soak/MockJBMClient.java
===================================================================
---
remoting2/branches/2.x/src/tests/org/jboss/test/remoting/soak/MockJBMClient.java 2008-03-17
07:36:49 UTC (rev 3656)
+++
remoting2/branches/2.x/src/tests/org/jboss/test/remoting/soak/MockJBMClient.java 2008-03-17
07:46:10 UTC (rev 3657)
@@ -23,6 +23,7 @@
import java.util.HashMap;
import java.util.Map;
+import java.util.Set;
import org.apache.log4j.Logger;
import org.jboss.remoting.Client;
@@ -48,7 +49,7 @@
protected String name;
protected boolean ok = true;
protected Client client;
- protected ClientLauncher.Counter counter;
+ protected Set inUseSet;
protected ClientLauncher.Counter failureCounter;
public MockJBMClient(String locator, Map metadata) throws Exception
@@ -56,8 +57,8 @@
this.locator = new InvokerLocator(locator);
this.metadata = metadata;
this.name = (String) metadata.get(NAME);
- counter = (ClientLauncher.Counter) metadata.remove(COUNTER);
- counter.increment();
+ this.inUseSet = (Set) metadata.remove(IN_USE_SET);
+ inUseSet.add(this);
failureCounter = (ClientLauncher.Counter) metadata.remove(FAILURE_COUNTER);
log.info("created " + name);
}
@@ -101,7 +102,7 @@
{
client.disconnect();
log.info(name + ": " + (ok ? "PASS" : "FAIL"));
- counter.decrement();
+ inUseSet.remove(this);
if (!ok) failureCounter.increment();
}
}
@@ -121,5 +122,10 @@
log.debug("received callback");
}
}
+
+ public String toString()
+ {
+ return name;
+ }
}
Modified:
remoting2/branches/2.x/src/tests/org/jboss/test/remoting/soak/SoakConstants.java
===================================================================
---
remoting2/branches/2.x/src/tests/org/jboss/test/remoting/soak/SoakConstants.java 2008-03-17
07:36:49 UTC (rev 3656)
+++
remoting2/branches/2.x/src/tests/org/jboss/test/remoting/soak/SoakConstants.java 2008-03-17
07:46:10 UTC (rev 3657)
@@ -60,5 +60,7 @@
public static final String COUNTER = "counter";
public static final String FAILURE_COUNTER = "failureCounter";
+
+ public static final String IN_USE_SET = "inUseSet";
}