[jboss-cvs] JBossAS SVN: r68842 - projects/cluster/varia/sessionstress.
jboss-cvs-commits at lists.jboss.org
jboss-cvs-commits at lists.jboss.org
Thu Jan 10 16:16:05 EST 2008
Author: bela at jboss.com
Date: 2008-01-10 16:16:05 -0500 (Thu, 10 Jan 2008)
New Revision: 68842
Modified:
projects/cluster/varia/sessionstress/PerfTest.java
Log:
added -destroy_url
Modified: projects/cluster/varia/sessionstress/PerfTest.java
===================================================================
--- projects/cluster/varia/sessionstress/PerfTest.java 2008-01-10 20:56:25 UTC (rev 68841)
+++ projects/cluster/varia/sessionstress/PerfTest.java 2008-01-10 21:16:05 UTC (rev 68842)
@@ -30,12 +30,13 @@
- private void start(String host, String setup_url, String read_url, String write_url, int num_threads, int num_requests, int num_attrs, int size, int write_percentage) throws NamingException, BrokenBarrierException, InterruptedException {
+ 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 {
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, write_percentage,
+ Client client=new Client(barrier, host, setup_url, read_url, write_url, destroy_url, write_percentage,
num_requests, num_attrs, size);
clients[i]=client;
client.start();
@@ -134,6 +135,7 @@
String setup_url="web/setup.jsp";
String read_url="web/read.jsp";
String write_url="web/write.jsp";
+ String destroy_url="web/destroy.jsp";
for(int i=0; i < args.length; i++) {
if(args[i].equals("-host")) {
@@ -152,6 +154,10 @@
write_url=args[++i];
continue;
}
+ if(args[i].equals("-destroy_url")) {
+ destroy_url=args[++i];
+ continue;
+ }
if(args[i].equals("-num_threads")) {
num_threads=Integer.parseInt(args[++i]);
continue;
@@ -180,13 +186,13 @@
return;
}
- new PerfTest().start(host, setup_url, read_url, write_url, num_threads, num_requests, num_attrs, size, write_percentage);
+ new PerfTest().start(host, setup_url, read_url, write_url, destroy_url, num_threads, num_requests, num_attrs, size, write_percentage);
}
private static void help() {
System.out.println("PerfTest [-host <host[:port] of apache>] [-read_url <URL>] " +
"[-num_threads <number of client sessions>] " +
- "[-write_url <URL>] [-setup_url <URL>] [-num_requests <requests>] " +
+ "[-write_url <URL>] [-setup_url <URL>] [-destroy_url <URL>] [-num_requests <requests>] " +
"[-num_attrs <attrs>] [-size <bytes>] [-write_percentage <percentage, 0-100>]");
}
@@ -200,14 +206,15 @@
private final String write_url;
private final CyclicBarrier barrier;
- private int successful_reads=0, failed_reads=0, successful_writes=0, failed_writes=0;
- private long bytes_read=0, bytes_written=0;
- private long start=0, stop=0;
+ private int successful_reads=0, failed_reads=0, successful_writes=0, failed_writes=0;
+ private long bytes_read=0, bytes_written=0;
+ private long start=0, stop=0;
private boolean successful=true;
- private Client(CyclicBarrier barrier, String host, String setup_url, String read_url, String write_url,
+ private Client(CyclicBarrier barrier, 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.read_percentage=100 - write_percentage;
@@ -218,7 +225,7 @@
this.read_url=tmp + read_url + "?id=";
this.write_url=tmp + write_url + "?size=" + size + "&id=";
this.setup_method=new GetMethod(tmp + setup_url + "?num_attrs=" + num_attrs + "&size=" + size);
- this.destroy_method=new GetMethod(tmp + "web/destroy.jsp");
+ this.destroy_method=new GetMethod(tmp + destroy_url + "web/destroy.jsp");
}
public void run() {
@@ -286,13 +293,8 @@
}
private void terminate() throws IOException {
- int rc=executeRequest(destroy_method);
- if(rc != HttpStatus.SC_OK) {
- throw new RuntimeException("failed destroying session", null);
- }
- else {
- log("destroyed session");
- }
+ executeRequest(destroy_method);
+ log("destroyed session");
}
private void loop(int num_requests) throws IOException {
@@ -307,45 +309,35 @@
id=(int)random(num_attrs -1);
if(random <= read_percentage) { // read
read_method=new GetMethod(read_url + id);
-// try {
- rc=session.executeMethod(read_method);
- if(rc == HttpStatus.SC_OK) {
- successful_reads++;
- bytes_read+=size; // bytes read from the session, not by the HttpClient !
- }
- else {
- failed_reads++;
- }
-// }
-// finally {
-// read_method.releaseConnection();
-// }
+ rc=executeRequest(read_method);
+ if(rc == HttpStatus.SC_OK) {
+ successful_reads++;
+ bytes_read+=size; // bytes read from the session, not by the HttpClient !
+ }
+ else {
+ failed_reads++;
+ }
}
else { // write
write_method=new GetMethod(write_url + id);
-// try {
- rc=executeRequest(write_method);
- if(rc == HttpStatus.SC_OK) {
- successful_writes++;
- bytes_written+=size; // bytes read from the session, not by the HttpClient !
- }
- else {
- failed_writes++;
- }
-// }
-// finally {
-// write_method.releaseConnection();
-// }
+ rc=executeRequest(write_method);
+ if(rc == HttpStatus.SC_OK) {
+ successful_writes++;
+ bytes_written+=size; // bytes read from the session, not by the HttpClient !
+ }
+ else {
+ failed_writes++;
+ }
}
total++;
- if(total % print == 0)
+ if(print > 0 && total % print == 0)
log(total + " / " + num_requests);
}
}
private int executeRequest(GetMethod method) throws IOException {
- try {
- int rc = session.executeMethod(method);
+ try {
+ int rc = session.executeMethod(method);
method.getResponseBody();
return rc;
}
More information about the jboss-cvs-commits
mailing list