tomcat-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From fha...@apache.org
Subject svn commit: r567117 - in /tomcat/tc6.0.x/trunk/java/org/apache/catalina/tribes/membership: McastService.java McastServiceImpl.java
Date Fri, 17 Aug 2007 19:36:20 GMT
Author: fhanik
Date: Fri Aug 17 12:36:19 2007
New Revision: 567117

URL: http://svn.apache.org/viewvc?view=rev&rev=567117
Log:
back port from trunk, recovery options and retain membership

Modified:
    tomcat/tc6.0.x/trunk/java/org/apache/catalina/tribes/membership/McastService.java
    tomcat/tc6.0.x/trunk/java/org/apache/catalina/tribes/membership/McastServiceImpl.java

Modified: tomcat/tc6.0.x/trunk/java/org/apache/catalina/tribes/membership/McastService.java
URL: http://svn.apache.org/viewvc/tomcat/tc6.0.x/trunk/java/org/apache/catalina/tribes/membership/McastService.java?view=diff&rev=567117&r1=567116&r2=567117
==============================================================================
--- tomcat/tc6.0.x/trunk/java/org/apache/catalina/tribes/membership/McastService.java (original)
+++ tomcat/tc6.0.x/trunk/java/org/apache/catalina/tribes/membership/McastService.java Fri
Aug 17 12:36:19 2007
@@ -217,6 +217,19 @@
     public void setPort(int port) {
         properties.setProperty("mcastPort", String.valueOf(port));
     }
+    
+    public void setRecoveryCounter(int recoveryCounter) {
+        properties.setProperty("recoveryCounter", String.valueOf(recoveryCounter));
+    }
+
+    public void setRecoveryEnabled(boolean recoveryEnabled) {
+        properties.setProperty("recoveryEnabled", String.valueOf(recoveryEnabled));
+    }
+
+    public void setRecoverySleepTime(long recoverySleepTime) {
+        properties.setProperty("recoverySleepTime", String.valueOf(recoverySleepTime));
+    }
+
 
     /**
      * @deprecated use getPort()
@@ -348,6 +361,13 @@
                                     ttl,
                                     soTimeout,
                                     this);
+        boolean recEnabled = Boolean.getBoolean(properties.getProperty("recoveryEnabled","true"));
+        impl.setRecoveryEnabled(recEnabled);        
+        int recCnt = Integer.parseInt(properties.getProperty("recoveryCounter","10"));
+        impl.setRecoveryCounter(recCnt);
+        long recSlpTime = Long.parseLong(properties.getProperty("recoverySleepTime","5000"));
+        impl.setRecoverySleepTime(recSlpTime);
+        
         
         impl.start(level);
 		

Modified: tomcat/tc6.0.x/trunk/java/org/apache/catalina/tribes/membership/McastServiceImpl.java
URL: http://svn.apache.org/viewvc/tomcat/tc6.0.x/trunk/java/org/apache/catalina/tribes/membership/McastServiceImpl.java?view=diff&rev=567117&r1=567116&r2=567117
==============================================================================
--- tomcat/tc6.0.x/trunk/java/org/apache/catalina/tribes/membership/McastServiceImpl.java
(original)
+++ tomcat/tc6.0.x/trunk/java/org/apache/catalina/tribes/membership/McastServiceImpl.java
Fri Aug 17 12:36:19 2007
@@ -21,14 +21,14 @@
 import java.io.IOException;
 import java.net.DatagramPacket;
 import java.net.InetAddress;
+import java.net.InetSocketAddress;
 import java.net.MulticastSocket;
-
-import org.apache.catalina.tribes.MembershipListener;
-import java.util.Arrays;
 import java.net.SocketTimeoutException;
-import org.apache.catalina.tribes.Member;
+import java.util.Arrays;
+
 import org.apache.catalina.tribes.Channel;
-import java.net.InetSocketAddress;
+import org.apache.catalina.tribes.Member;
+import org.apache.catalina.tribes.MembershipListener;
 
 /**
  * A <b>membership</b> implementation using simple multicast.
@@ -126,6 +126,15 @@
     protected int recoveryCounter = 10;
     
     /**
+     * The time the recovery thread sleeps between recovery attempts
+     */
+    protected long recoverySleepTime = 5000;
+    
+    /**
+     * Add the ability to turn on/off recovery
+     */
+    protected boolean recoveryEnabled = true;
+    /**
      * Create a new mcast service impl
      * @param member - the local member
      * @param sendFrequency - the time (ms) in between pings sent out
@@ -169,7 +178,7 @@
         receivePacket.setPort(port);
         member.setCommand(new byte[0]);
         member.getData(true, true);
-        membership = new Membership(member);
+        if ( membership == null ) membership = new Membership(member);
     }
     
     protected void setupSocket() throws IOException {
@@ -365,6 +374,17 @@
        return this.serviceStartTime;
     }
 
+    public int getRecoveryCounter() {
+        return recoveryCounter;
+    }
+
+    public boolean isRecoveryEnabled() {
+        return recoveryEnabled;
+    }
+
+    public long getRecoverySleepTime() {
+        return recoverySleepTime;
+    }
 
     public class ReceiverThread extends Thread {
         int errorCounter = 0;
@@ -431,6 +451,7 @@
         
         public static synchronized boolean init(RecoveryThread t) {
             if ( running ) return false;
+            if ( !t.parent.isRecoveryEnabled()) return false;
             running = true;
             t.setName("Tribes-MembershipRecovery");
             t.setDaemon(true);
@@ -470,7 +491,7 @@
                     try {
                         if (!success) {
                             log.info("Recovery attempt "+(++attempt)+" failed, trying again
in 5 seconds");
-                            Thread.sleep(5000);
+                            Thread.sleep(parent.recoverySleepTime);
                         }
                     }catch (InterruptedException ignore) {
                     }
@@ -479,5 +500,17 @@
                 running = false;
             }
         }//run
+    }
+
+    public void setRecoveryCounter(int recoveryCounter) {
+        this.recoveryCounter = recoveryCounter;
+    }
+
+    public void setRecoveryEnabled(boolean recoveryEnabled) {
+        this.recoveryEnabled = recoveryEnabled;
+    }
+
+    public void setRecoverySleepTime(long recoverySleepTime) {
+        this.recoverySleepTime = recoverySleepTime;
     }
 }



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


Mime
View raw message