[jboss-cvs] JBossAS SVN: r68766 - projects/cluster/varia/sessionstress.
jboss-cvs-commits at lists.jboss.org
jboss-cvs-commits at lists.jboss.org
Wed Jan 9 17:32:57 EST 2008
Author: bstansberry at jboss.com
Date: 2008-01-09 17:32:56 -0500 (Wed, 09 Jan 2008)
New Revision: 68766
Modified:
projects/cluster/varia/sessionstress/PerfTest.java
Log:
Read response
Encapsulate request handling
Modified: projects/cluster/varia/sessionstress/PerfTest.java
===================================================================
--- projects/cluster/varia/sessionstress/PerfTest.java 2008-01-09 22:32:33 UTC (rev 68765)
+++ projects/cluster/varia/sessionstress/PerfTest.java 2008-01-09 22:32:56 UTC (rev 68766)
@@ -6,6 +6,8 @@
import javax.naming.NamingException;
import java.io.IOException;
+import java.io.PrintWriter;
+import java.io.StringWriter;
import java.text.NumberFormat;
import java.util.concurrent.BrokenBarrierException;
import java.util.concurrent.CyclicBarrier;
@@ -275,7 +277,7 @@
/** Create NUM_SESSIONS sessions with NUM_ATTRS attributes of SIZE size. Total size is multiplication of the 3 */
private void init(int num_attrs, int size) throws IOException {
- int rc=session.executeMethod(setup_method);
+ int rc=executeRequest(setup_method);
if(rc != HttpStatus.SC_OK) {
throw new RuntimeException("failed initializing session", null);
}
@@ -285,7 +287,7 @@
}
private void terminate() throws IOException {
- int rc=session.executeMethod(destroy_method);
+ int rc=executeRequest(destroy_method);
if(rc != HttpStatus.SC_OK) {
throw new RuntimeException("failed destroying session", null);
}
@@ -306,7 +308,7 @@
id=(int)random(num_attrs -1);
if(random <= read_percentage) { // read
read_method=new GetMethod(read_url + id);
- try {
+// try {
rc=session.executeMethod(read_method);
if(rc == HttpStatus.SC_OK) {
successful_reads++;
@@ -315,15 +317,15 @@
else {
failed_reads++;
}
- }
- finally {
- read_method.releaseConnection();
- }
+// }
+// finally {
+// read_method.releaseConnection();
+// }
}
else { // write
write_method=new GetMethod(write_url + id);
- try {
- rc=session.executeMethod(write_method);
+// try {
+ rc=executeRequest(write_method);
if(rc == HttpStatus.SC_OK) {
successful_writes++;
bytes_written+=size; // bytes read from the session, not by the HttpClient !
@@ -331,16 +333,27 @@
else {
failed_writes++;
}
- }
- finally {
- write_method.releaseConnection();
- }
+// }
+// finally {
+// write_method.releaseConnection();
+// }
}
total++;
if(total % print == 0)
log(total + " / " + num_requests);
}
}
+
+ private int executeRequest(GetMethod method) throws IOException {
+ try {
+ int rc = session.executeMethod(method);
+ method.getResponseBody();
+ return rc;
+ }
+ finally {
+ method.releaseConnection();
+ }
+ }
private static void log(String msg) {
System.out.println("[thread-" + Thread.currentThread().getId() + "]: " + msg);
@@ -348,9 +361,16 @@
private static void error(String msg, Throwable th) {
String tmp="[thread-" + Thread.currentThread().getId() + "]: " + msg;
- if(th != null)
- tmp+=", ex: " + th;
+ if(th != null) {
+ tmp+=", ex: " + th + "\n";
+ StringWriter writer = new StringWriter();
+ PrintWriter pw = new PrintWriter(writer);
+ th.printStackTrace(pw);
+ pw.flush();
+ tmp+= writer.toString();
+ }
System.err.println(tmp);
+// log(tmp);
}
private static long random(long range) {
More information about the jboss-cvs-commits
mailing list