tomcat-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From fha...@apache.org
Subject svn commit: r381395 - in /tomcat/container/tc5.5.x/modules/groupcom/src/share/org/apache/catalina/tribes: ChannelMessage.java group/GroupChannel.java io/ClusterData.java tcp/FastAsyncSocketSender.java
Date Mon, 27 Feb 2006 17:44:57 GMT
Author: fhanik
Date: Mon Feb 27 09:44:54 2006
New Revision: 381395

URL: http://svn.apache.org/viewcvs?rev=381395&view=rev
Log:
unique Id for cluster data is now a 16 digit byte array for faster serialization

Modified:
    tomcat/container/tc5.5.x/modules/groupcom/src/share/org/apache/catalina/tribes/ChannelMessage.java
    tomcat/container/tc5.5.x/modules/groupcom/src/share/org/apache/catalina/tribes/group/GroupChannel.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/tcp/FastAsyncSocketSender.java

Modified: tomcat/container/tc5.5.x/modules/groupcom/src/share/org/apache/catalina/tribes/ChannelMessage.java
URL: http://svn.apache.org/viewcvs/tomcat/container/tc5.5.x/modules/groupcom/src/share/org/apache/catalina/tribes/ChannelMessage.java?rev=381395&r1=381394&r2=381395&view=diff
==============================================================================
--- tomcat/container/tc5.5.x/modules/groupcom/src/share/org/apache/catalina/tribes/ChannelMessage.java
(original)
+++ tomcat/container/tc5.5.x/modules/groupcom/src/share/org/apache/catalina/tribes/ChannelMessage.java
Mon Feb 27 09:44:54 2006
@@ -57,9 +57,9 @@
      * Each message must have a unique ID, in case of using async replication,
      * and a smart queue, this id is used to replace messages not yet sent.
      *
-     * @return String
+     * @return byte
      */
-    public String getUniqueId();
+    public byte[] getUniqueId();
     
     public void setMessage(byte[] data);
     

Modified: tomcat/container/tc5.5.x/modules/groupcom/src/share/org/apache/catalina/tribes/group/GroupChannel.java
URL: http://svn.apache.org/viewcvs/tomcat/container/tc5.5.x/modules/groupcom/src/share/org/apache/catalina/tribes/group/GroupChannel.java?rev=381395&r1=381394&r2=381395&view=diff
==============================================================================
--- tomcat/container/tc5.5.x/modules/groupcom/src/share/org/apache/catalina/tribes/group/GroupChannel.java
(original)
+++ tomcat/container/tc5.5.x/modules/groupcom/src/share/org/apache/catalina/tribes/group/GroupChannel.java
Mon Feb 27 09:44:54 2006
@@ -18,14 +18,12 @@
 
 import org.apache.catalina.tribes.ChannelException;
 import org.apache.catalina.tribes.ChannelInterceptor;
-import org.apache.catalina.tribes.Channel;
 import org.apache.catalina.tribes.ChannelMessage;
 import org.apache.catalina.tribes.ChannelReceiver;
 import org.apache.catalina.tribes.ChannelSender;
 import org.apache.catalina.tribes.Member;
 import org.apache.catalina.tribes.MembershipListener;
 import org.apache.catalina.tribes.MembershipService;
-import org.apache.catalina.tribes.MessageListener;
 import org.apache.catalina.tribes.io.ClusterData;
 import org.apache.catalina.tribes.io.XByteBuffer;
 import java.io.Serializable;
@@ -82,6 +80,16 @@
         super.heartbeat();
     }
     
+    
+    public byte[] getUUID() {
+        UUID id = UUID.randomUUID();
+        long msb = id.getMostSignificantBits();
+        long lsb = id.getLeastSignificantBits();
+        byte[] data = new byte[16];
+        System.arraycopy(XByteBuffer.toBytes(msb),0,data,0,8);
+        System.arraycopy(XByteBuffer.toBytes(lsb),0,data,8,8);
+        return data;
+    }
     /**
      * Send a message to one or more members in the cluster
      * @param destination Member[] - the destinations, null or zero length means all
@@ -95,7 +103,7 @@
             int options = 0;
             ClusterData data = new ClusterData();
             data.setAddress(getLocalMember());
-            data.setUniqueId(UUID.randomUUID().toString());
+            data.setUniqueId(getUUID());
             data.setTimestamp(System.currentTimeMillis());
             byte[] b = null;
             if ( msg instanceof ByteMessage ){

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=381395&r1=381394&r2=381395&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 09:44:54 2006
@@ -39,7 +39,7 @@
     private int options = 0 ;
     private byte[] message ;
     private long timestamp ;
-    private String uniqueId ;
+    private byte[] uniqueId ;
     private Member address;
 
     public ClusterData() {}
@@ -50,7 +50,7 @@
      * @param message message data
      * @param timestamp message creation date
      */
-    public ClusterData(String uniqueId, byte[] message, long timestamp) {
+    public ClusterData(byte[] uniqueId, byte[] message, long timestamp) {
         this.uniqueId = uniqueId;
         this.message = message;
         this.timestamp = timestamp;
@@ -83,13 +83,13 @@
     /**
      * @return Returns the uniqueId.
      */
-    public String getUniqueId() {
+    public byte[] getUniqueId() {
         return uniqueId;
     }
     /**
      * @param uniqueId The uniqueId to set.
      */
-    public void setUniqueId(String uniqueId) {
+    public void setUniqueId(byte[] uniqueId) {
         this.uniqueId = uniqueId;
     }
     /**
@@ -134,7 +134,8 @@
         ObjectOutputStream out = new ObjectOutputStream(bout);
         out.writeInt(options);
         out.writeLong(timestamp);
-        out.writeUTF(uniqueId);
+        out.writeInt(uniqueId.length);
+        out.write(uniqueId);
         byte[] addr = ((McastMember)address).getData();
         out.writeInt(addr.length);
         out.write(addr);
@@ -150,7 +151,9 @@
         ClusterData data = new ClusterData();
         data.setOptions(in.readInt());
         data.setTimestamp(in.readLong());
-        data.setUniqueId(in.readUTF());
+        byte[] uniqueId = new byte[in.readInt()];
+        in.read(uniqueId);
+        data.setUniqueId(uniqueId);
         byte[] addr = new byte[in.readInt()];
         in.read(addr);
         data.setAddress(McastMember.getMember(addr));

Modified: tomcat/container/tc5.5.x/modules/groupcom/src/share/org/apache/catalina/tribes/tcp/FastAsyncSocketSender.java
URL: http://svn.apache.org/viewcvs/tomcat/container/tc5.5.x/modules/groupcom/src/share/org/apache/catalina/tribes/tcp/FastAsyncSocketSender.java?rev=381395&r1=381394&r2=381395&view=diff
==============================================================================
--- tomcat/container/tc5.5.x/modules/groupcom/src/share/org/apache/catalina/tribes/tcp/FastAsyncSocketSender.java
(original)
+++ tomcat/container/tc5.5.x/modules/groupcom/src/share/org/apache/catalina/tribes/tcp/FastAsyncSocketSender.java
Mon Feb 27 09:44:54 2006
@@ -22,6 +22,7 @@
 import org.apache.catalina.tribes.util.FastQueue;
 import org.apache.catalina.tribes.util.IQueue;
 import org.apache.catalina.tribes.util.LinkObject;
+import org.apache.catalina.tribes.io.XByteBuffer;
 
 /**
  * Send cluster messages from a Message queue with only one socket. Ack and keep
@@ -300,6 +301,12 @@
         // close socket
         super.disconnect();
     }
+    
+    public String getUniqueIdAsString(byte[] data) {
+        long msb = XByteBuffer.toLong(data,0);
+        long lsb = XByteBuffer.toLong(data,8);
+        return Long.toHexString(msb)+Long.toHexString(lsb);
+    }
 
     /**
      * Send message to queue for later sending.
@@ -308,7 +315,7 @@
      */
     public void sendMessage(ChannelMessage data)
             throws java.io.IOException {
-        queue.add(data.getUniqueId(), data);
+        queue.add(getUniqueIdAsString(data.getUniqueId()), data);
         synchronized (this) {
             inQueueCounter++;
             if(queueThread != null)



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


Mime
View raw message