[jboss-cvs] JBossAS SVN: r68892 - projects/cluster/varia/sessionstress.

jboss-cvs-commits at lists.jboss.org jboss-cvs-commits at lists.jboss.org
Fri Jan 11 09:39:07 EST 2008


Author: bela at jboss.com
Date: 2008-01-11 09:39:07 -0500 (Fri, 11 Jan 2008)
New Revision: 68892

Modified:
   projects/cluster/varia/sessionstress/PerfTest2.java
Log:
added -slient flag

Modified: projects/cluster/varia/sessionstress/PerfTest2.java
===================================================================
--- projects/cluster/varia/sessionstress/PerfTest2.java	2008-01-11 14:31:43 UTC (rev 68891)
+++ projects/cluster/varia/sessionstress/PerfTest2.java	2008-01-11 14:39:07 UTC (rev 68892)
@@ -31,7 +31,7 @@
 
 
 
-    private void start(String host, String setup_url, String read_url, String write_url, String destroy_url,
+    private void start(String host, boolean silent, 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, MalformedURLException {
         this.clients=new Client[num_threads];
@@ -39,7 +39,7 @@
 
         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, host, silent, setup_url, read_url, write_url, destroy_url, write_percentage,
                                      num_requests, num_attrs, size);
             clients[i]=client;
             client.start();
@@ -134,6 +134,7 @@
         int num_attrs=40;
         int size=1000;
         int write_percentage=10; // percent
+        boolean silent=false;
         String host="localhost";
         String setup_url="web/setup.jsp";
         String read_url="web/read.jsp";
@@ -145,6 +146,10 @@
                 host=args[++i];
                 continue;
             }
+            if(args[i].equals("-silent")) {
+                silent=true;
+                continue;
+            }
             if(args[i].equals("-setup_url")) {
                 setup_url=args[++i];
                 continue;
@@ -191,11 +196,11 @@
 
         // CookieHandler.setDefault(new MyCookieHandler());
 
-        new PerfTest2().start(host, setup_url, read_url, write_url, destroy_url, num_threads, num_requests, num_attrs, size, write_percentage);
+        new PerfTest2().start(host, silent, 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>] " +
+        System.out.println("PerfTest [-host <host[:port] of apache>] [-silent] [-read_url <URL>] " +
                 "[-num_threads <number of client sessions>] " +
                 "[-write_url <URL>] [-setup_url <URL>] [-destroy_url <URL>] [-num_requests <requests>] " +
                 "[-num_attrs <attrs>] [-size <bytes>] [-write_percentage <percentage, 0-100>]");
@@ -213,13 +218,16 @@
         private boolean             successful=true;
         private final byte[]        buffer=new byte[1024];
         private String              cookie=null;
+        private boolean             silent=false;
 
 
 
-        private Client(CyclicBarrier barrier, String host,
+
+        private Client(CyclicBarrier barrier, String host, boolean silent,
                        String setup_url, String read_url, String write_url, String destroy_url,
                        int write_percentage, int num_requests, int num_attrs, int size) throws MalformedURLException {
             this.barrier=barrier;
+            this.silent=silent;
             this.read_percentage=100 - write_percentage;
             this.num_requests=num_requests;
             this.num_attrs=num_attrs;
@@ -289,7 +297,8 @@
 
         private void terminate() throws IOException {
             executeRequest(destroy_url);
-            log("destroyed session");
+            if(!silent)
+                log("destroyed session");
         }
 
         private void loop(int num_requests) throws IOException {
@@ -323,7 +332,7 @@
                     }
                 }
                 total++;
-                if(print > 0 && total % print == 0)
+                if(!silent && print > 0 && total % print == 0)
                     log(total + " / " + num_requests);
             }
         }
@@ -346,7 +355,8 @@
                 String tmp_cookie=conn.getHeaderField("set-cookie");
                 if(tmp_cookie != null && cookie == null) {
                     cookie=tmp_cookie;
-                    System.out.println("set-cookie: " + cookie);
+                    if(!silent)
+                        System.out.println("set-cookie: " + cookie);
                 }
                 return conn.getResponseCode();
             }




More information about the jboss-cvs-commits mailing list