tomcat-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From fha...@apache.org
Subject svn commit: r382068 - in /tomcat/container/tc5.5.x/modules/groupcom/src/share/org/apache/catalina/tribes: demos/LoadTest.java io/ObjectReader.java
Date Wed, 01 Mar 2006 16:05:25 GMT
Author: fhanik
Date: Wed Mar  1 08:05:24 2006
New Revision: 382068

URL: http://svn.apache.org/viewcvs?rev=382068&view=rev
Log:
The object reader buffer should be the same as the channel's receiver buffer to avoid having
to grow the byte buffer
Added in the ability to control the size of the messages in the LoadTest

Modified:
    tomcat/container/tc5.5.x/modules/groupcom/src/share/org/apache/catalina/tribes/demos/LoadTest.java
    tomcat/container/tc5.5.x/modules/groupcom/src/share/org/apache/catalina/tribes/io/ObjectReader.java

Modified: tomcat/container/tc5.5.x/modules/groupcom/src/share/org/apache/catalina/tribes/demos/LoadTest.java
URL: http://svn.apache.org/viewcvs/tomcat/container/tc5.5.x/modules/groupcom/src/share/org/apache/catalina/tribes/demos/LoadTest.java?rev=382068&r1=382067&r2=382068&view=diff
==============================================================================
--- tomcat/container/tc5.5.x/modules/groupcom/src/share/org/apache/catalina/tribes/demos/LoadTest.java
(original)
+++ tomcat/container/tc5.5.x/modules/groupcom/src/share/org/apache/catalina/tribes/demos/LoadTest.java
Wed Mar  1 08:05:24 2006
@@ -41,6 +41,7 @@
  */
 public class LoadTest implements MembershipListener,ChannelListener, Runnable {
     protected static org.apache.commons.logging.Log log = org.apache.commons.logging.LogFactory.getLog(LoadTest.class);
+    public static int size = 1020;
     public static Object mutex = new Object();
     public boolean doRun = true;
     
@@ -240,7 +241,7 @@
     
     
     public static class LoadMessage extends ByteMessage implements Serializable  {
-        public static int size = 1020;
+        
         public static byte[] outdata = new byte[size];
         public static Random r = new Random(System.currentTimeMillis());
         public static int getMessageSize (LoadMessage msg) {
@@ -304,6 +305,7 @@
                            "[-stats statinterval]  \n\t\t"+
                            "[-pause nrofsecondstopausebetweensends]  \n\t\t"+
                            "[-threads numberofsenderthreads]  \n\t\t"+
+                           "[-size messagesize]  \n\t\t"+
                            "[-break (halts execution on exception)]\n"+
                            "\tChannel options:"+
                            ChannelCreator.usage()+"\n\n"+
@@ -337,6 +339,9 @@
             } else if ("-stats".equals(args[i])) {
                 stats = Integer.parseInt(args[++i]);
                 System.out.println("Stats every "+stats+" message");
+            } else if ("-size".equals(args[i])) {
+                size = Integer.parseInt(args[++i])-4;
+                System.out.println("Message size will be:"+(size+4)+" bytes");
             } else if ("-mode".equals(args[i])) {
                 if ( "receive".equals(args[++i]) ) send = false;
             } else if ("-debug".equals(args[i])) {

Modified: tomcat/container/tc5.5.x/modules/groupcom/src/share/org/apache/catalina/tribes/io/ObjectReader.java
URL: http://svn.apache.org/viewcvs/tomcat/container/tc5.5.x/modules/groupcom/src/share/org/apache/catalina/tribes/io/ObjectReader.java?rev=382068&r1=382067&r2=382068&view=diff
==============================================================================
--- tomcat/container/tc5.5.x/modules/groupcom/src/share/org/apache/catalina/tribes/io/ObjectReader.java
(original)
+++ tomcat/container/tc5.5.x/modules/groupcom/src/share/org/apache/catalina/tribes/io/ObjectReader.java
Wed Mar  1 08:05:24 2006
@@ -19,6 +19,7 @@
 import java.nio.channels.Selector;
 import java.nio.channels.SocketChannel;
 import org.apache.catalina.tribes.ChannelMessage;
+import java.io.IOException;
 
 
 
@@ -32,11 +33,12 @@
  * for message encoding and decoding.
  *
  * @author Filip Hanik
- * @author Peter Rossbach
  * @version $Revision: 377484 $, $Date: 2006-02-13 15:00:05 -0600 (Mon, 13 Feb 2006) $
  */
 public class ObjectReader {
 
+    protected static org.apache.commons.logging.Log log = org.apache.commons.logging.LogFactory.getLog(ObjectReader.class);
+
     private SocketChannel channel;
 
     private ListenCallback callback;
@@ -52,7 +54,13 @@
     public ObjectReader(SocketChannel channel, Selector selector, ListenCallback callback)
{
         this.channel = channel;
         this.callback = callback;
-        this.buffer = new XByteBuffer(true);
+        try {
+            this.buffer = new XByteBuffer(channel.socket().getReceiveBufferSize(), true);
+        }catch ( IOException x ) {
+            //unable to get buffer size
+            log.warn("Unable to retrieve the socket channel receiver buffer size, setting
to default 43800 bytes.");
+            this.buffer = new XByteBuffer(43800,true);
+        }
     }
 
     /**



---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@tomcat.apache.org
For additional commands, e-mail: dev-help@tomcat.apache.org


Mime
View raw message