Author: fhanik
Date: Tue May 23 14:59:43 2006
New Revision: 409012

URL: http://svn.apache.org/viewvc?rev=409012&view=rev
Log:
More changes to coordination, 

Modified:
    
tomcat/container/tc5.5.x/modules/groupcom/doc/leader-election-message-arrives.dia
    
tomcat/container/tc5.5.x/modules/groupcom/doc/leader-election-message-arrives.jpg
    
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/doc/leader-election-message-arrives.dia
URL: 
http://svn.apache.org/viewvc/tomcat/container/tc5.5.x/modules/groupcom/doc/leader-election-message-arrives.dia?rev=409012&r1=409011&r2=409012&view=diff
==============================================================================
Binary files - no diff available.

Modified: 
tomcat/container/tc5.5.x/modules/groupcom/doc/leader-election-message-arrives.jpg
URL: 
http://svn.apache.org/viewvc/tomcat/container/tc5.5.x/modules/groupcom/doc/leader-election-message-arrives.jpg?rev=409012&r1=409011&r2=409012&view=diff
==============================================================================
Binary files - no diff available.

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=409012&r1=409011&r2=409012&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
 Tue May 23 14:59:43 2006
@@ -162,6 +162,7 @@
      * and this is the one we are running
      */
     protected UniqueId suggestedviewId;
+    protected Membership suggestedView;
     
     protected LinkedHashMap rotatingViews = new LinkedHashMap();
     
@@ -174,24 +175,9 @@
         super();
     }
     
-    public void start(int svc) throws ChannelException {
-        if ( membership == null ) setupMembership();
-        if (started)return;
-        super.start(startsvc);
-        startElection(false);
-        started = true;
-    }
-    
-    public void stop(int svc) throws ChannelException {
-        try {
-            halt();
-            if ( !started ) return;
-            super.stop(startsvc);
-            started = false;
-        }finally {
-            release();
-        }
-    }
+//============================================================================================================
    
+//              COORDINATION HANDLING
+//============================================================================================================
     
     public Membership getView(UniqueId id) {
         return (Membership)rotatingViews.get(id);
@@ -229,6 +215,8 @@
             MemberImpl[] mbrs = m.getMembers();
             CoordinationMessage msg = new CoordinationMessage(leader, local, 
mbrs,new UniqueId(UUIDGenerator.randomUUID(true)), this.COORD_REQUEST);
             suggestedviewId = msg.getId();
+            suggestedView = new Membership(local);
+            Arrays.fill(suggestedView,mbrs);
             rotatingViews.put(suggestedviewId, msg);
             super.sendMessage(new Member[] {others[0]}, createData(msg, 
local), null);
         }
@@ -273,17 +261,28 @@
     protected void processCoordMessage(CoordinationMessage msg, Member sender) 
{
         synchronized (electionMutex) {
             msg.timestamp = System.currentTimeMillis();
+            rotatingViews.put(msg.getId(),msg);
+            Membership merged = mergeOnArrive(msg,sender);
+            if ( isViewConf(msg) ) handleViewConf(msg, sender,merged);
         }
     }
-
     
-    protected void sendMessage(CoordinationMessage msg, Member dest) throws 
ChannelException {
-        ChannelData data = new 
ChannelData(UUIDGenerator.randomUUID(false),msg.getBuffer(),System.currentTimeMillis());
-        data.setOptions(Channel.SEND_OPTIONS_USE_ACK);
-        Member[] destination = new Member[] {dest};
-        sendMessage(destination,data,null);
+    protected void handleViewConf(CoordinationMessage msg, Member sender,
+                                  Membership merged) {
+        this.view = new 
Membership((MemberImpl)getLocalMember(false),AbsoluteOrder.comp);
+        this.viewId = msg.getId();
+        if ( viewId.equals(this.suggestedviewId) ) {
+            this.suggestedView = null;
+            this.suggestedviewId = null;
+        }
+        this.viewChange(viewId,view.getMembers());
+        
     }
     
+    protected boolean isViewConf(CoordinationMessage msg) {
+        return Arrays.contains(msg.getType(),0,COORD_CONF,0,COORD_CONF.length);
+    }
+
     
     /**
      * Returns coordinator if one is available
@@ -293,6 +292,51 @@
         return (view != null && view.hasMembers()) ? view.getMembers()[0] : 
null;
     }
     
+    /**
+    * 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() {
+
+   }
+
+    
+//============================================================================================================
    
+//              OVERRIDDEN METHODS FROM CHANNEL INTERCEPTOR BASE    
+//============================================================================================================
+    public void start(int svc) throws ChannelException {
+        if ( membership == null ) setupMembership();
+        if (started)return;
+        super.start(startsvc);
+        startElection(false);
+        started = true;
+    }
+
+    public void stop(int svc) throws ChannelException {
+        try {
+            halt();
+            if ( !started ) return;
+            super.stop(startsvc);
+            started = false;
+        }finally {
+            release();
+        }
+    }
+    
+    
     public void sendMessage(Member[] destination, ChannelMessage msg, 
InterceptorPayload payload) throws ChannelException {
         waitForRelease();
         super.sendMessage(destination, msg, payload);
@@ -390,26 +434,13 @@
         }
     }
     
-    /**
-     * 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() {
-        
-    }
+//============================================================================================================
    
+//              HELPER CLASSES FOR COORDINATION
+//============================================================================================================
     
-    /**
-     * Wait for an election to end
-     */
-    protected void waitForRelease() {
-        
-    }
+    
+   
     
     public static class CoordinationMessage {
         //X{A-ldr, A-src, mbrs-A,B,C,D}



---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to