geronimo-scm mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From jdil...@apache.org
Subject svn commit: r576645 - in /geronimo/sandbox/gshell/trunk/gshell-remote/gshell-remote-common/src/main/java/org/apache/geronimo/gshell/remote/message: Message.java MessageSupport.java
Date Tue, 18 Sep 2007 01:33:05 GMT
Author: jdillon
Date: Mon Sep 17 18:33:04 2007
New Revision: 576645

URL: http://svn.apache.org/viewvc?rev=576645&view=rev
Log:
Add a sequence number to the message, mostly for debugging to make sure that ordering is correct(ish)

Modified:
    geronimo/sandbox/gshell/trunk/gshell-remote/gshell-remote-common/src/main/java/org/apache/geronimo/gshell/remote/message/Message.java
    geronimo/sandbox/gshell/trunk/gshell-remote/gshell-remote-common/src/main/java/org/apache/geronimo/gshell/remote/message/MessageSupport.java

Modified: geronimo/sandbox/gshell/trunk/gshell-remote/gshell-remote-common/src/main/java/org/apache/geronimo/gshell/remote/message/Message.java
URL: http://svn.apache.org/viewvc/geronimo/sandbox/gshell/trunk/gshell-remote/gshell-remote-common/src/main/java/org/apache/geronimo/gshell/remote/message/Message.java?rev=576645&r1=576644&r2=576645&view=diff
==============================================================================
--- geronimo/sandbox/gshell/trunk/gshell-remote/gshell-remote-common/src/main/java/org/apache/geronimo/gshell/remote/message/Message.java
(original)
+++ geronimo/sandbox/gshell/trunk/gshell-remote/gshell-remote-common/src/main/java/org/apache/geronimo/gshell/remote/message/Message.java
Mon Sep 17 18:33:04 2007
@@ -42,6 +42,8 @@
 
     long getTimestamp();
 
+    long getSequence();
+
     void setSession(IoSession session);
 
     IoSession getSession();

Modified: geronimo/sandbox/gshell/trunk/gshell-remote/gshell-remote-common/src/main/java/org/apache/geronimo/gshell/remote/message/MessageSupport.java
URL: http://svn.apache.org/viewvc/geronimo/sandbox/gshell/trunk/gshell-remote/gshell-remote-common/src/main/java/org/apache/geronimo/gshell/remote/message/MessageSupport.java?rev=576645&r1=576644&r2=576645&view=diff
==============================================================================
--- geronimo/sandbox/gshell/trunk/gshell-remote/gshell-remote-common/src/main/java/org/apache/geronimo/gshell/remote/message/MessageSupport.java
(original)
+++ geronimo/sandbox/gshell/trunk/gshell-remote/gshell-remote-common/src/main/java/org/apache/geronimo/gshell/remote/message/MessageSupport.java
Mon Sep 17 18:33:04 2007
@@ -23,6 +23,7 @@
 import java.nio.charset.CharacterCodingException;
 import java.nio.charset.Charset;
 import java.util.UUID;
+import java.util.concurrent.atomic.AtomicLong;
 
 import org.apache.geronimo.gshell.common.tostring.ReflectionToStringBuilder;
 import org.apache.mina.common.ByteBuffer;
@@ -37,12 +38,16 @@
 public abstract class MessageSupport
     implements Message
 {
-    private MessageType type;
+    private static final AtomicLong SEQUENCE_COUNTER = new AtomicLong(0);
+
+    private transient MessageType type;
 
     private UUID id;
 
     private UUID correlationId;
 
+    private long sequence;
+
     private long timestamp;
     
     private transient IoSession session;
@@ -57,6 +62,12 @@
         this.id = UUID.randomUUID();
 
         this.timestamp = System.currentTimeMillis();
+
+        //
+        // FIXME: This might end up skipping numbers, which while is okay, isn't really very
nice
+        //
+        
+        this.sequence = SEQUENCE_COUNTER.getAndIncrement();
     }
 
     public String toString() {
@@ -76,6 +87,8 @@
     }
 
     public void setCorrelationId(final UUID id) {
+        assert id != null;
+        
         ensureWritable();
         
         this.correlationId = id;
@@ -85,6 +98,10 @@
         return timestamp;
     }
 
+    public long getSequence() {
+        return sequence;
+    }
+
     public void setSession(final IoSession session) {
         ensureWritable();
         
@@ -124,25 +141,25 @@
     public void readExternal(final ByteBuffer buff) throws Exception {
         assert buff != null;
 
-        type = buff.getEnum(MessageType.class);
-
         id = readUuid(buff);
 
         correlationId = readUuid(buff);
 
         timestamp = buff.getLong();
+
+        sequence = buff.getLong();
     }
 
     public void writeExternal(final ByteBuffer buff) throws Exception {
         assert buff != null;
 
-        buff.putEnum(type);
-
         writeUuid(buff, id);
 
         writeUuid(buff, correlationId);
 
         buff.putLong(timestamp);
+
+        buff.putLong(sequence);
     }
 
     //



Mime
View raw message