geronimo-scm mailing list archives

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

URL: http://svn.apache.org/viewvc?rev=576650&view=rev
Log:
Set the sequence upon write so we don't have gaps

Modified:
    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/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=576650&r1=576649&r2=576650&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:48:49 2007
@@ -46,7 +46,7 @@
 
     private UUID correlationId;
 
-    private long sequence;
+    private Long sequence;
 
     private long timestamp;
     
@@ -62,12 +62,6 @@
         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() {
@@ -99,6 +93,10 @@
     }
 
     public long getSequence() {
+        if (sequence == null) {
+            throw new IllegalStateException("Sequence number is set upon write and is not
yet available");
+        }
+
         return sequence;
     }
 
@@ -159,6 +157,8 @@
 
         buff.putLong(timestamp);
 
+        sequence = SEQUENCE_COUNTER.getAndIncrement();
+        
         buff.putLong(sequence);
     }
 
@@ -225,7 +225,8 @@
         IoSession session = getSession();
 
         msg.setCorrelationId(getId());
-
+        msg.freeze();
+        
         return session.write(msg);
     }
 }



Mime
View raw message