tomcat-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From fha...@apache.org
Subject svn commit: r399095 - /tomcat/container/tc5.5.x/modules/groupcom/src/share/org/apache/catalina/tribes/group/interceptors/TcpFailureDetector.java
Date Tue, 02 May 2006 23:58:20 GMT
Author: fhanik
Date: Tue May  2 16:58:18 2006
New Revision: 399095

URL: http://svn.apache.org/viewcvs?rev=399095&view=rev
Log:
implemented the heart beat, the failure detector should be ready to test

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

Modified: tomcat/container/tc5.5.x/modules/groupcom/src/share/org/apache/catalina/tribes/group/interceptors/TcpFailureDetector.java
URL: http://svn.apache.org/viewcvs/tomcat/container/tc5.5.x/modules/groupcom/src/share/org/apache/catalina/tribes/group/interceptors/TcpFailureDetector.java?rev=399095&r1=399094&r2=399095&view=diff
==============================================================================
--- tomcat/container/tc5.5.x/modules/groupcom/src/share/org/apache/catalina/tribes/group/interceptors/TcpFailureDetector.java
(original)
+++ tomcat/container/tc5.5.x/modules/groupcom/src/share/org/apache/catalina/tribes/group/interceptors/TcpFailureDetector.java
Tue May  2 16:58:18 2006
@@ -30,6 +30,7 @@
 import java.util.HashMap;
 import org.apache.catalina.tribes.membership.Membership;
 import org.apache.catalina.tribes.membership.MemberImpl;
+import java.util.Iterator;
 
 /**
  * <p>Title: A perfect failure detector </p>
@@ -137,9 +138,29 @@
         return super.getLocalMember(incAlive);
     }
     
-    public void heartbeat() {
-        //todo, implement an expiration of members that we deemed alive
-        //check them again and act accordingly
+    public synchronized void heartbeat() {
+        if ( membership == null ) setupMembership();
+        //update all alive times
+        Member[] members = super.getMembers();
+        for ( int i=0; i<members.length; i++ ) {
+            if ( membership.memberAlive((MemberImpl)members[i]) ) {
+                log.warn("Member added, even though we werent notified:"+members[i]);
+                super.memberAdded(members[i]);
+            }//end if
+        }//for
+        
+        //check suspect members if they are still alive,
+        //if not, simply issue the memberDisappeared message
+        
+        for (Iterator i = suspect.keySet().iterator(); i.hasNext(); ) {
+            MemberImpl m = (MemberImpl)i.next();
+            if (!memberAlive(m)) {
+                membership.removeMember(m);
+                super.memberDisappeared(m);
+                suspect.remove(m);
+            }//end if
+        }
+        
         super.heartbeat();
     }
     



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


Mime
View raw message