tomcat-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From fha...@apache.org
Subject svn commit: r407555 - in /tomcat/container/tc5.5.x/modules/groupcom: ./ src/share/org/apache/catalina/tribes/group/interceptors/ test/java/org/apache/catalina/tribes/demos/
Date Thu, 18 May 2006 14:15:27 GMT
Author: fhanik
Date: Thu May 18 07:15:27 2006
New Revision: 407555

URL: http://svn.apache.org/viewvc?rev=407555&view=rev
Log:
Added throughput interceptor to measure send speed

Added:
    tomcat/container/tc5.5.x/modules/groupcom/src/share/org/apache/catalina/tribes/group/interceptors/ThroughputInterceptor.java
Modified:
    tomcat/container/tc5.5.x/modules/groupcom/VERSION
    tomcat/container/tc5.5.x/modules/groupcom/test/java/org/apache/catalina/tribes/demos/ChannelCreator.java
    tomcat/container/tc5.5.x/modules/groupcom/test/java/org/apache/catalina/tribes/demos/LoadTest.java

Modified: tomcat/container/tc5.5.x/modules/groupcom/VERSION
URL: http://svn.apache.org/viewvc/tomcat/container/tc5.5.x/modules/groupcom/VERSION?rev=407555&r1=407554&r2=407555&view=diff
==============================================================================
--- tomcat/container/tc5.5.x/modules/groupcom/VERSION (original)
+++ tomcat/container/tc5.5.x/modules/groupcom/VERSION Thu May 18 07:15:27 2006
@@ -1,3 +1,6 @@
+0.9.2.3
+  - Keep alive pings for AbstractReplicatedMap
+  - Improved TcpFailureDetector
 0.9.2.2
   - removed getMemberProperties from the membership interface
 0.9.2.1

Added: tomcat/container/tc5.5.x/modules/groupcom/src/share/org/apache/catalina/tribes/group/interceptors/ThroughputInterceptor.java
URL: http://svn.apache.org/viewvc/tomcat/container/tc5.5.x/modules/groupcom/src/share/org/apache/catalina/tribes/group/interceptors/ThroughputInterceptor.java?rev=407555&view=auto
==============================================================================
--- tomcat/container/tc5.5.x/modules/groupcom/src/share/org/apache/catalina/tribes/group/interceptors/ThroughputInterceptor.java
(added)
+++ tomcat/container/tc5.5.x/modules/groupcom/src/share/org/apache/catalina/tribes/group/interceptors/ThroughputInterceptor.java
Thu May 18 07:15:27 2006
@@ -0,0 +1,86 @@
+/*
+ * Copyright 1999,2004 The Apache Software Foundation.
+ * 
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ * 
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ * 
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ */
+
+package org.apache.catalina.tribes.group.interceptors;
+
+import org.apache.catalina.tribes.ChannelException;
+import org.apache.catalina.tribes.ChannelMessage;
+import org.apache.catalina.tribes.Member;
+import org.apache.catalina.tribes.group.ChannelInterceptorBase;
+import org.apache.catalina.tribes.group.InterceptorPayload;
+import org.apache.catalina.tribes.io.ChannelData;
+import org.apache.catalina.tribes.io.XByteBuffer;
+import java.text.DecimalFormat;
+
+
+
+/**
+ *
+ *
+ * @author Filip Hanik
+ * @version 1.0
+ */
+public class ThroughputInterceptor extends ChannelInterceptorBase {
+    
+    double mbTx = 0;
+    double mbRx = 0;
+    double timeTx = 0;
+    long msgTxCnt = 1;
+    long msgRxCnt = 1;
+    int interval = 10000;
+    DecimalFormat df = new DecimalFormat("##.00");
+
+    public void sendMessage(Member[] destination, ChannelMessage msg, InterceptorPayload
payload) throws ChannelException {
+        long bytes = XByteBuffer.getDataPackageLength(((ChannelData)msg).getDataPackage().length);
+        long start = System.currentTimeMillis();
+        super.sendMessage(destination,msg,payload);
+        long stop = System.currentTimeMillis();
+        timeTx+= ((double)(stop-start))/1000d;
+        mbTx += ((double)bytes)/(1024d*1024d);
+        if ( msgTxCnt % interval == 0 ) report();
+        msgTxCnt++;
+    }
+
+    public void messageReceived(ChannelMessage msg) {
+        long bytes = XByteBuffer.getDataPackageLength(((ChannelData)msg).getDataPackage().length);
+        mbRx += ((double)bytes)/(1024d*1024d);
+        if ( msgRxCnt % interval == 0 ) report();
+        msgRxCnt++;
+    }
+    
+    public void report() {
+        StringBuffer buf = new StringBuffer("ThroughputInterceptor Report[\n\tTx Msg:");
+        buf.append(msgTxCnt).append(" messages\n\tSent:");
+        buf.append(df.format(mbTx));
+        buf.append(" MB\n\tTime:");
+        buf.append(df.format(timeTx));
+        buf.append(" seconds\n\tSpeed:");
+        buf.append(df.format(mbTx/timeTx));
+        buf.append(" MB/sec\n\tRx Msg:");
+        buf.append(msgRxCnt);
+        buf.append(" messages\n\tReceived:");
+        buf.append(df.format(mbRx)).append(" MB]\n");
+        System.out.println(buf);
+    }
+
+    public void setInterval(int interval) {
+        this.interval = interval;
+    }
+
+    public int getInterval() {
+        return interval;
+    }
+
+}

Modified: tomcat/container/tc5.5.x/modules/groupcom/test/java/org/apache/catalina/tribes/demos/ChannelCreator.java
URL: http://svn.apache.org/viewvc/tomcat/container/tc5.5.x/modules/groupcom/test/java/org/apache/catalina/tribes/demos/ChannelCreator.java?rev=407555&r1=407554&r2=407555&view=diff
==============================================================================
--- tomcat/container/tc5.5.x/modules/groupcom/test/java/org/apache/catalina/tribes/demos/ChannelCreator.java
(original)
+++ tomcat/container/tc5.5.x/modules/groupcom/test/java/org/apache/catalina/tribes/demos/ChannelCreator.java
Thu May 18 07:15:27 2006
@@ -29,6 +29,7 @@
 import org.apache.catalina.tribes.transport.MultiPointSender;
 import org.apache.catalina.tribes.transport.ReceiverBase;
 import org.apache.catalina.tribes.transport.ReplicationTransmitter;
+import org.apache.catalina.tribes.group.interceptors.ThroughputInterceptor;
 
 /**
  * <p>Title: </p>
@@ -65,6 +66,7 @@
            .append("\n\t\t[-ordersize maxorderqueuesize]")
            .append("\n\t\t[-frag]")
            .append("\n\t\t[-fragsize maxmsgsize]")
+           .append("\n\t\t[-throughput]")
            .append("\n\t\t[-async]")
            .append("\n\t\t[-asyncsize maxqueuesizeinbytes]");
        return buf;
@@ -93,6 +95,7 @@
         String receiver = "org.apache.catalina.tribes.transport.nio.NioReceiver";
         boolean async = false;
         int asyncsize = 1024*1024*50; //50MB
+        boolean throughput = false;
         
         for (int i = 0; i < args.length; i++) {
             if ("-bind".equals(args[i])) {
@@ -112,6 +115,8 @@
             } else if ("-asyncsize".equals(args[i])) {
                 asyncsize = Integer.parseInt(args[++i]);
                 System.out.println("Setting MessageDispatchInterceptor.maxQueueSize="+asyncsize);
+            } else if ("-throughput".equals(args[i])) {
+                throughput = true;
             } else if ("-order".equals(args[i])) {
                 order = true;
             } else if ("-ordersize".equals(args[i])) {
@@ -185,6 +190,7 @@
         channel.setChannelSender(ps);
         channel.setMembershipService(service);
 
+        if ( throughput ) channel.addInterceptor(new ThroughputInterceptor());
         if (gzip) channel.addInterceptor(new GzipInterceptor());
         if ( frag ) {
             FragmentationInterceptor fi = new FragmentationInterceptor();

Modified: tomcat/container/tc5.5.x/modules/groupcom/test/java/org/apache/catalina/tribes/demos/LoadTest.java
URL: http://svn.apache.org/viewvc/tomcat/container/tc5.5.x/modules/groupcom/test/java/org/apache/catalina/tribes/demos/LoadTest.java?rev=407555&r1=407554&r2=407555&view=diff
==============================================================================
--- tomcat/container/tc5.5.x/modules/groupcom/test/java/org/apache/catalina/tribes/demos/LoadTest.java
(original)
+++ tomcat/container/tc5.5.x/modules/groupcom/test/java/org/apache/catalina/tribes/demos/LoadTest.java
Thu May 18 07:15:27 2006
@@ -232,7 +232,7 @@
                      "\n\tTotal mbytes  :"+(long)mBytesReceived+
                      "\n\tTime since 1st:"+seconds+" seconds"+
                      "\n\tBytes/second  :"+(bytes/seconds)+
-                     "\n\tMBytes/second :"+(mBytesReceived/seconds));
+                     "\n\tMBytes/second :"+(mBytesReceived/seconds)+"\n");
 
         }
     }



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


Mime
View raw message