tomcat-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From fha...@apache.org
Subject svn commit: r381458 - in /tomcat/container/tc5.5.x/modules/groupcom/src/share/org/apache/catalina/tribes: demos/LoadTest.java io/ClusterData.java io/ObjectReader.java tcp/TcpReplicationThread.java
Date Mon, 27 Feb 2006 21:42:36 GMT
Author: fhanik
Date: Mon Feb 27 13:42:34 2006
New Revision: 381458

URL: http://svn.apache.org/viewcvs?rev=381458&view=rev
Log:
improved speed. countPackages doesn't have to be counted each time we append data, as this
is a very frequent call

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/ClusterData.java
    tomcat/container/tc5.5.x/modules/groupcom/src/share/org/apache/catalina/tribes/io/ObjectReader.java
    tomcat/container/tc5.5.x/modules/groupcom/src/share/org/apache/catalina/tribes/tcp/TcpReplicationThread.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=381458&r1=381457&r2=381458&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
Mon Feb 27 13:42:34 2006
@@ -50,12 +50,13 @@
     
     static int messageSize = 0;
     
-    public static int messagesSent = 0;
+    public static long messagesSent = 0;
     public static long messageSendTime = 0;
     
-    public static synchronized void addSendStats(int count, long time) {
+    public static synchronized long addSendStats(long count, long time) {
         messagesSent+=count;
         messageSendTime+=time;
+        return 0l;
     }    
     
     
@@ -79,7 +80,7 @@
     
     public void run() {
         
-        int counter = 0;
+        long counter = 0;
         LoadMessage msg = new LoadMessage();
         int messageSize = LoadTest.messageSize;
         long sendTime = 0;
@@ -95,7 +96,7 @@
                     }
                 } else {
                     try {
-                        msg.setMsgNr(++counter);
+                        msg.setMsgNr((int)++counter);
                         long start = System.currentTimeMillis();
                         if (debug) {
                             printArray(msg.getMessage());
@@ -116,9 +117,11 @@
                 }
                 if ( (counter % statsInterval) == 0 && (counter > 0)) {
                     //add to the global counter
-                    addSendStats(counter,sendTime);
+                    //counter = sendTime = addSendStats(counter,sendTime);
                     //print from the global counter
-                    printSendStats(LoadTest.messagesSent, LoadTest.messageSize, LoadTest.messageSendTime);
+                    //printSendStats(LoadTest.messagesSent, LoadTest.messageSize, LoadTest.messageSendTime);
+                    printSendStats(counter, LoadTest.messageSize, sendTime);
+                    
                 }
 
             }
@@ -128,7 +131,7 @@
         }
     }
 
-    private void printSendStats(int counter, int messageSize, long sendTime) {
+    private void printSendStats(long counter, int messageSize, long sendTime) {
         float cnt = (float)counter;
         float size = (float)messageSize;
         float time = (float)sendTime / 1000;

Modified: tomcat/container/tc5.5.x/modules/groupcom/src/share/org/apache/catalina/tribes/io/ClusterData.java
URL: http://svn.apache.org/viewcvs/tomcat/container/tc5.5.x/modules/groupcom/src/share/org/apache/catalina/tribes/io/ClusterData.java?rev=381458&r1=381457&r2=381458&view=diff
==============================================================================
--- tomcat/container/tc5.5.x/modules/groupcom/src/share/org/apache/catalina/tribes/io/ClusterData.java
(original)
+++ tomcat/container/tc5.5.x/modules/groupcom/src/share/org/apache/catalina/tribes/io/ClusterData.java
Mon Feb 27 13:42:34 2006
@@ -25,6 +25,7 @@
 import java.io.ByteArrayInputStream;
 import java.io.ObjectInputStream;
 import java.util.UUID;
+import java.util.Arrays;
 
 /**
  * The cluster data class is used to transport around the byte array from
@@ -202,6 +203,25 @@
         System.arraycopy(b,offset,data.message,0,data.message.length);
         offset += data.message.length; //message data
         return data;
+    }
+    
+    public static void main(String[] args) throws Exception {
+        ClusterData data1 = new ClusterData();
+        data1.setAddress(new McastMember("domain","127.0.0.1",1000,System.currentTimeMillis()));
+        data1.setMessage(new byte[1024]);
+        
+        byte[] b = data1.getDataPackage();
+        
+        ClusterData data2 = ClusterData.getDataFromPackage(b);
+        
+        if ( !(data1.getAddress().equals(data2.getAddress())) ||
+             !(Arrays.equals(data1.getMessage(),data2.getMessage())) ||
+             !(Arrays.equals(data1.getUniqueId(),data2.getUniqueId())) ||
+             !(data1.getTimestamp() == data2.timestamp) ||
+             !(data1.getOptions() == data2.getOptions() ) ) {
+            throw new Exception("Not Equal");
+        }
+                         
     }
     
 }

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=381458&r1=381457&r2=381458&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
Mon Feb 27 13:42:34 2006
@@ -80,9 +80,10 @@
      * @return number of messages that sended to callback
      * @throws java.io.IOException
      */
-     public int append(byte[] data,int off,int len) throws java.io.IOException {
+     public int append(byte[] data,int off,int len, boolean count) throws java.io.IOException
{
         buffer.append(data,off,len);
-        int pkgCnt = buffer.countPackages();
+        int pkgCnt = -1;
+        if ( count ) pkgCnt = buffer.countPackages();
         return pkgCnt;
     }
 

Modified: tomcat/container/tc5.5.x/modules/groupcom/src/share/org/apache/catalina/tribes/tcp/TcpReplicationThread.java
URL: http://svn.apache.org/viewcvs/tomcat/container/tc5.5.x/modules/groupcom/src/share/org/apache/catalina/tribes/tcp/TcpReplicationThread.java?rev=381458&r1=381457&r2=381458&view=diff
==============================================================================
--- tomcat/container/tc5.5.x/modules/groupcom/src/share/org/apache/catalina/tribes/tcp/TcpReplicationThread.java
(original)
+++ tomcat/container/tc5.5.x/modules/groupcom/src/share/org/apache/catalina/tribes/tcp/TcpReplicationThread.java
Mon Feb 27 13:42:34 2006
@@ -131,7 +131,7 @@
         // loop while data available, channel is non-blocking
         while ((count = channel.read (buffer)) > 0) {
             buffer.flip();		// make buffer readable
-            reader.append(buffer.array(),0,count);
+            reader.append(buffer.array(),0,count,false);
             buffer.clear();		// make buffer empty
         }
         



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


Mime
View raw message