tomcat-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From kfuj...@apache.org
Subject svn commit: r1489752 - in /tomcat/trunk: java/org/apache/catalina/tribes/group/interceptors/TcpFailureDetector.java webapps/docs/config/cluster-interceptor.xml
Date Wed, 05 Jun 2013 09:03:02 GMT
Author: kfujino
Date: Wed Jun  5 09:03:01 2013
New Revision: 1489752

URL: http://svn.apache.org/r1489752
Log:
Add removeSuspectsTimeout attribute in order to dispel remove suspect.
The removeSuspects members never be removed until disappeared really.
Remove members that worked properly specified time by removeSuspectsTimeout from removeSuspects.

Modified:
    tomcat/trunk/java/org/apache/catalina/tribes/group/interceptors/TcpFailureDetector.java
    tomcat/trunk/webapps/docs/config/cluster-interceptor.xml

Modified: tomcat/trunk/java/org/apache/catalina/tribes/group/interceptors/TcpFailureDetector.java
URL: http://svn.apache.org/viewvc/tomcat/trunk/java/org/apache/catalina/tribes/group/interceptors/TcpFailureDetector.java?rev=1489752&r1=1489751&r2=1489752&view=diff
==============================================================================
--- tomcat/trunk/java/org/apache/catalina/tribes/group/interceptors/TcpFailureDetector.java
(original)
+++ tomcat/trunk/java/org/apache/catalina/tribes/group/interceptors/TcpFailureDetector.java
Wed Jun  5 09:03:01 2013
@@ -83,6 +83,8 @@ public class TcpFailureDetector extends 
 
     protected final HashMap<Member, Long> addSuspects = new HashMap<>();
 
+    protected int removeSuspectsTimeout = 300; // 5 minutes
+
     @Override
     public void sendMessage(Member[] destination, ChannelMessage msg, InterceptorPayload
payload) throws ChannelException {
         try {
@@ -271,7 +273,15 @@ public class TcpFailureDetector extends 
                 removeSuspects.remove(m);
                 if(log.isInfoEnabled())
                     log.info("Suspect member, confirmed dead.["+m+"]");
-            } //end if
+            } else {
+                if (removeSuspectsTimeout > 0) {
+                    long timeNow = System.currentTimeMillis();
+                    int timeIdle = (int) ((timeNow - removeSuspects.get(m)) / 1000L);
+                    if (timeIdle > removeSuspectsTimeout) {
+                        removeSuspects.remove(m); // remove suspect member 
+                    }
+                }
+            }
         }
 
         //check add suspects members if they are alive now,
@@ -362,6 +372,10 @@ public class TcpFailureDetector extends 
         return connectTimeout;
     }
 
+    public int getRemoveSuspectsTimeout() {
+        return removeSuspectsTimeout;
+    }
+
     public void setPerformConnectTest(boolean performConnectTest) {
         this.performConnectTest = performConnectTest;
     }
@@ -382,4 +396,8 @@ public class TcpFailureDetector extends 
         this.connectTimeout = connectTimeout;
     }
 
+    public void setRemoveSuspectsTimeout(int removeSuspectsTimeout) {
+        this.removeSuspectsTimeout = removeSuspectsTimeout;
+    }
+
 }
\ No newline at end of file

Modified: tomcat/trunk/webapps/docs/config/cluster-interceptor.xml
URL: http://svn.apache.org/viewvc/tomcat/trunk/webapps/docs/config/cluster-interceptor.xml?rev=1489752&r1=1489751&r2=1489752&view=diff
==============================================================================
--- tomcat/trunk/webapps/docs/config/cluster-interceptor.xml (original)
+++ tomcat/trunk/webapps/docs/config/cluster-interceptor.xml Wed Jun  5 09:03:01 2013
@@ -157,6 +157,13 @@
        Specifies the timeout, in milliseconds, to use when performing a read test
        to the suspicious node. Default is 5000.
      </attribute>
+     <attribute name="removeSuspectsTimeout" required="false">
+       The maximum time(in seconds)  for remove from removeSuspects. Member of
+       removeSuspects will be automatically removed after removeSuspectsTimeout.
+       If a negative value specified, the removeSuspects members never be
+       removed until disappeared really. If the attribute is not provided,
+       a default of 300 milliseconds (5 minutes) is used.
+     </attribute>
    </attributes>
   </subsection>
   <subsection name="org.apache.catalina.tribes.group.interceptors.TcpPingInterceptor Attributes">



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


Mime
View raw message