tomcat-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From fha...@apache.org
Subject svn commit: r408121 - /tomcat/container/tc5.5.x/modules/groupcom/src/share/org/apache/catalina/tribes/group/interceptors/NonBlockingCoordinator.java
Date Sun, 21 May 2006 02:01:06 GMT
Author: fhanik
Date: Sat May 20 19:01:05 2006
New Revision: 408121

URL: http://svn.apache.org/viewvc?rev=408121&view=rev
Log:
starting to add more helper method, still need clarification on message exchange during election

Modified:
    tomcat/container/tc5.5.x/modules/groupcom/src/share/org/apache/catalina/tribes/group/interceptors/NonBlockingCoordinator.java

Modified: tomcat/container/tc5.5.x/modules/groupcom/src/share/org/apache/catalina/tribes/group/interceptors/NonBlockingCoordinator.java
URL: http://svn.apache.org/viewvc/tomcat/container/tc5.5.x/modules/groupcom/src/share/org/apache/catalina/tribes/group/interceptors/NonBlockingCoordinator.java?rev=408121&r1=408120&r2=408121&view=diff
==============================================================================
--- tomcat/container/tc5.5.x/modules/groupcom/src/share/org/apache/catalina/tribes/group/interceptors/NonBlockingCoordinator.java
(original)
+++ tomcat/container/tc5.5.x/modules/groupcom/src/share/org/apache/catalina/tribes/group/interceptors/NonBlockingCoordinator.java
Sat May 20 19:01:05 2006
@@ -61,6 +61,7 @@
     
     protected Member coordinator = null;
     
+    
     public NonBlockingCoordinator() {
         super();
     }
@@ -70,6 +71,7 @@
     }
     
     public void sendMessage(Member[] destination, ChannelMessage msg, InterceptorPayload
payload) throws ChannelException {
+        waitForRelease();
         super.sendMessage(destination, msg, payload);
     }
 
@@ -86,14 +88,24 @@
     }
 
     public void memberAdded(Member member) {
-        if ( membership == null ) setupMembership();
-        membership.addMember((MemberImpl)member);
+        try {
+            halt();
+            if (membership == null) setupMembership();
+            membership.addMember( (MemberImpl) member);
+        }finally {
+            release();
+        }
         super.memberAdded(member);
     }
 
     public void memberDisappeared(Member member) {
-        if ( membership == null ) setupMembership();
-        membership.removeMember((MemberImpl)member);
+        try {
+            halt();
+            if (membership == null) setupMembership();
+            membership.removeMember( (MemberImpl) member);
+        }finally {
+            release();
+        }
         super.memberDisappeared(member);
     }
 
@@ -145,16 +157,36 @@
         if ( membership == null ) {
             membership = new Membership((MemberImpl)super.getLocalMember(true));
         }
-
+    }
+    
+    /**
+     * Block in/out messages while a election is going on
+     */
+    protected void halt() {
+        
+    }
+    
+    /**
+     * Release lock for in/out messages election is completed
+     */
+    protected void release() {
+        
+    }
+    
+    /**
+     * Wait for an election to end
+     */
+    protected void waitForRelease() {
+        
     }
     
     /**
      * A message is:<br>
-     * HEADER, REQUEST|REPLY, ID, MSG, SOURCE_LEN, SOURCE
+     * HEADER, REQUEST|REPLY, ID, MSG, SOURCE_LEN, SOURCE, PAYLOAD_LEN, PAYLOAD
      * @param type byte[] - either NBC_REQUEST or NBC_REPLY
      * @param msg byte[] - NBC_HALT, NBC_ACK, NBC_NORM, NBC_NOTNORM, NBC_LDR
      */
-    protected UniqueId createNBCMessage(XByteBuffer buf, byte[] type, byte[] msg) {
+    protected UniqueId createNBCMessage(XByteBuffer buf, byte[] type, byte[] msg, byte[]
payload) {
         UniqueId id = new UniqueId(UUIDGenerator.randomUUID(true));
         Member local = getLocalMember(false);
         byte[] ldata = ((MemberImpl)local).getData(false,false);
@@ -165,6 +197,8 @@
         buf.append(msg,0,msg.length);
         buf.append(ldata.length);
         buf.append(ldata,0,ldata.length);
+        buf.append(payload.length);
+        buf.append(payload,0,payload.length);
         return id;
     }
     



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


Mime
View raw message