[jboss-cvs] JBossAS SVN: r68872 - projects/cluster/varia/sessionstress.
jboss-cvs-commits at lists.jboss.org
jboss-cvs-commits at lists.jboss.org
Fri Jan 11 06:06:50 EST 2008
Author: bela at jboss.com
Date: 2008-01-11 06:06:50 -0500 (Fri, 11 Jan 2008)
New Revision: 68872
Modified:
projects/cluster/varia/sessionstress/PerfTest.java
Log:
ns
Modified: projects/cluster/varia/sessionstress/PerfTest.java
===================================================================
--- projects/cluster/varia/sessionstress/PerfTest.java 2008-01-11 10:19:10 UTC (rev 68871)
+++ projects/cluster/varia/sessionstress/PerfTest.java 2008-01-11 11:06:50 UTC (rev 68872)
@@ -1,8 +1,6 @@
package multicast;
-import org.apache.commons.httpclient.HttpClient;
-import org.apache.commons.httpclient.HttpStatus;
-import org.apache.commons.httpclient.MultiThreadedHttpConnectionManager;
+import org.apache.commons.httpclient.*;
import org.apache.commons.httpclient.params.HttpConnectionManagerParams;
import org.apache.commons.httpclient.methods.GetMethod;
@@ -22,7 +20,8 @@
public class PerfTest {
private Client[] clients;
private CyclicBarrier barrier;
- private MultiThreadedHttpConnectionManager pool=new MultiThreadedHttpConnectionManager();
+ private final MultiThreadedHttpConnectionManager pool=new MultiThreadedHttpConnectionManager();
+ private final HttpClient session=new HttpClient(pool);
static NumberFormat f;
@@ -36,16 +35,18 @@
private void start(String host, String setup_url, String read_url, String write_url, String destroy_url,
int num_threads, int num_requests, int num_attrs, int size, int write_percentage)
- throws NamingException, BrokenBarrierException, InterruptedException {
+ throws NamingException, BrokenBarrierException, InterruptedException, URIException {
HttpConnectionManagerParams params=new HttpConnectionManagerParams();
params.setDefaultMaxConnectionsPerHost(200);
params.setMaxTotalConnections(500);
pool.setParams(params);
+ HostConfiguration cfg=new HostConfiguration();
+ cfg.setHost(new URI("http://" + host + "/", false));
this.clients=new Client[num_threads];
this.barrier=new CyclicBarrier(num_threads + 1);
System.out.println("Starting " + num_threads + " clients");
for(int i=0; i < clients.length; i++) {
- Client client=new Client(barrier, host, setup_url, read_url, write_url, destroy_url, write_percentage,
+ Client client=new Client(barrier, session, host, setup_url, read_url, write_url, destroy_url, write_percentage,
num_requests, num_attrs, size);
clients[i]=client;
client.start();
@@ -53,6 +54,13 @@
System.out.println("Waiting for clients to complete");
barrier.await();
+
+ int connectionsInPool=pool.getConnectionsInPool();
+ HostConfiguration cfg2=new HostConfiguration();
+ cfg2.setHost("localhost", 80, "http");
+ int connectionsForLocalhost80=pool.getConnectionsInPool(cfg2);
+ System.out.println("connections for " + cfg2 + ": " + connectionsForLocalhost80 +
+ ", connections overall: " + connectionsInPool);
pool.shutdown();
@@ -211,7 +219,7 @@
private static class Client extends Thread {
private final int read_percentage;
private final int num_requests, num_attrs, size;
- private final HttpClient session=new HttpClient(new MultiThreadedHttpConnectionManager());
+ private final HttpClient session;
private final GetMethod setup_method, destroy_method;
private final String read_url;
private final String write_url;
@@ -221,13 +229,15 @@
private long bytes_read=0, bytes_written=0;
private long start=0, stop=0;
private boolean successful=true;
+ private final byte[] buffer=new byte[1024];
- private Client(CyclicBarrier barrier, String host,
+ private Client(CyclicBarrier barrier, HttpClient session, String host,
String setup_url, String read_url, String write_url, String destroy_url,
int write_percentage, int num_requests, int num_attrs, int size) {
this.barrier=barrier;
+ this.session=session;
this.read_percentage=100 - write_percentage;
this.num_requests=num_requests;
this.num_attrs=num_attrs;
@@ -252,7 +262,6 @@
finally {
stop=System.currentTimeMillis();
try {terminate();} catch(IOException e) {}
- log("barrier.await()");
try {barrier.await();} catch(Exception e) {}
setup_method.releaseConnection();
}
@@ -346,25 +355,12 @@
}
}
-// private int executeRequest(GetMethod method) throws IOException {
-// try {
-// int rc = session.executeMethod(method);
-// method.getResponseBody();
-// return rc;
-// }
-// finally {
-// method.releaseConnection();
-// }
-// }
private int executeRequest(GetMethod method) throws IOException {
try {
int rc = session.executeMethod(method);
- // method.getResponseBody();
-
InputStream input=method.getResponseBodyAsStream();
- byte[] buffer = new byte[4096];
while ((input.read(buffer)) > 0) {
;
}
@@ -392,7 +388,6 @@
tmp+= writer.toString();
}
System.err.println(tmp);
-// log(tmp);
}
private static long random(long range) {
More information about the jboss-cvs-commits
mailing list