You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@tomcat.apache.org by kf...@apache.org on 2013/07/02 11:37:08 UTC

svn commit: r1498855 - in /tomcat/tc7.0.x/trunk: java/org/apache/catalina/ha/session/ java/org/apache/catalina/tribes/tipis/ webapps/docs/ webapps/docs/config/

Author: kfujino
Date: Tue Jul  2 09:37:08 2013
New Revision: 1498855

URL: http://svn.apache.org/r1498855
Log:
Add new attribute terminateOnStartFailure in BackupManaber.

Modified:
    tomcat/tc7.0.x/trunk/java/org/apache/catalina/ha/session/BackupManager.java
    tomcat/tc7.0.x/trunk/java/org/apache/catalina/ha/session/mbeans-descriptors.xml
    tomcat/tc7.0.x/trunk/java/org/apache/catalina/tribes/tipis/AbstractReplicatedMap.java
    tomcat/tc7.0.x/trunk/java/org/apache/catalina/tribes/tipis/LazyReplicatedMap.java
    tomcat/tc7.0.x/trunk/java/org/apache/catalina/tribes/tipis/ReplicatedMap.java
    tomcat/tc7.0.x/trunk/webapps/docs/changelog.xml
    tomcat/tc7.0.x/trunk/webapps/docs/config/cluster-manager.xml

Modified: tomcat/tc7.0.x/trunk/java/org/apache/catalina/ha/session/BackupManager.java
URL: http://svn.apache.org/viewvc/tomcat/tc7.0.x/trunk/java/org/apache/catalina/ha/session/BackupManager.java?rev=1498855&r1=1498854&r2=1498855&view=diff
==============================================================================
--- tomcat/tc7.0.x/trunk/java/org/apache/catalina/ha/session/BackupManager.java (original)
+++ tomcat/tc7.0.x/trunk/java/org/apache/catalina/ha/session/BackupManager.java Tue Jul  2 09:37:08 2013
@@ -70,6 +70,11 @@ public class BackupManager extends Clust
     private long rpcTimeout = DEFAULT_REPL_TIMEOUT;
 
     /**
+     * Flag for whether to terminate this map that failed to start.
+     */
+    private boolean terminateOnStartFailure = false;
+
+    /**
      * Constructor, just calls super()
      *
      */
@@ -164,7 +169,8 @@ public class BackupManager extends Clust
                                                           cluster.getChannel(),
                                                           rpcTimeout,
                                                           getMapName(),
-                                                          getClassLoaders());
+                                                          getClassLoaders(),
+                                                          terminateOnStartFailure);
             map.setChannelSendOptions(mapSendOptions);
             this.sessions = map;
         }  catch ( Exception x ) {
@@ -234,6 +240,14 @@ public class BackupManager extends Clust
         return rpcTimeout;
     }
 
+    public void setTerminateOnStartFailure(boolean terminateOnStartFailure) {
+        this.terminateOnStartFailure = terminateOnStartFailure;
+    }
+
+    public boolean isTerminateOnStartFailure() {
+        return terminateOnStartFailure;
+    }
+
     @Override
     public String[] getInvalidatedSessions() {
         return new String[0];
@@ -246,6 +260,7 @@ public class BackupManager extends Clust
         result.mExpireSessionsOnShutdown = mExpireSessionsOnShutdown;
         result.mapSendOptions = mapSendOptions;
         result.rpcTimeout = rpcTimeout;
+        result.terminateOnStartFailure = terminateOnStartFailure;
         return result;
     }
 

Modified: tomcat/tc7.0.x/trunk/java/org/apache/catalina/ha/session/mbeans-descriptors.xml
URL: http://svn.apache.org/viewvc/tomcat/tc7.0.x/trunk/java/org/apache/catalina/ha/session/mbeans-descriptors.xml?rev=1498855&r1=1498854&r2=1498855&view=diff
==============================================================================
--- tomcat/tc7.0.x/trunk/java/org/apache/catalina/ha/session/mbeans-descriptors.xml (original)
+++ tomcat/tc7.0.x/trunk/java/org/apache/catalina/ha/session/mbeans-descriptors.xml Tue Jul  2 09:37:08 2013
@@ -542,6 +542,11 @@
       description="Timeout for RPC messages, how long we will wait for a reply"
       type="long"/>
     <attribute
+      name="terminateOnStartFailure"
+      description="Flag for whether to terminate this map that failed to start."
+      is="true"
+      type="boolean"/>
+    <attribute
       name="secureRandomAlgorithm"
       description="The secure random number generator algorithm name"
       type="java.lang.String"/>

Modified: tomcat/tc7.0.x/trunk/java/org/apache/catalina/tribes/tipis/AbstractReplicatedMap.java
URL: http://svn.apache.org/viewvc/tomcat/tc7.0.x/trunk/java/org/apache/catalina/tribes/tipis/AbstractReplicatedMap.java?rev=1498855&r1=1498854&r2=1498855&view=diff
==============================================================================
--- tomcat/tc7.0.x/trunk/java/org/apache/catalina/tribes/tipis/AbstractReplicatedMap.java (original)
+++ tomcat/tc7.0.x/trunk/java/org/apache/catalina/tribes/tipis/AbstractReplicatedMap.java Tue Jul  2 09:37:08 2013
@@ -171,9 +171,10 @@ public abstract class AbstractReplicated
                                  int initialCapacity,
                                  float loadFactor,
                                  int channelSendOptions,
-                                 ClassLoader[] cls) {
+                                 ClassLoader[] cls,
+                                 boolean terminate) {
         super(initialCapacity, loadFactor, 15);
-        init(owner, channel, mapContextName, timeout, channelSendOptions, cls);
+        init(owner, channel, mapContextName, timeout, channelSendOptions, cls, terminate);
 
     }
 
@@ -197,7 +198,8 @@ public abstract class AbstractReplicated
      * @param channelSendOptions int
      * @param cls ClassLoader[]
      */
-    protected void init(MapOwner owner, Channel channel, String mapContextName, long timeout, int channelSendOptions,ClassLoader[] cls) {
+    protected void init(MapOwner owner, Channel channel, String mapContextName,
+            long timeout, int channelSendOptions,ClassLoader[] cls, boolean terminate) {
         log.info("Initializing AbstractReplicatedMap with context name:"+mapContextName);
         this.mapOwner = owner;
         this.externalLoaders = cls;
@@ -227,11 +229,10 @@ public abstract class AbstractReplicated
             broadcast(MapMessage.MSG_START, true);
         } catch (ChannelException x) {
             log.warn("Unable to send map start message.");
-            // remove listener from channel
-            this.rpcChannel.breakdown();
-            this.channel.removeChannelListener(this);
-            this.channel.removeMembershipListener(this);
-            throw new RuntimeException("Unable to start replicated map.",x);
+            if (terminate) {
+                breakdown();
+                throw new RuntimeException("Unable to start replicated map.",x);
+            }
         }
     }
 

Modified: tomcat/tc7.0.x/trunk/java/org/apache/catalina/tribes/tipis/LazyReplicatedMap.java
URL: http://svn.apache.org/viewvc/tomcat/tc7.0.x/trunk/java/org/apache/catalina/tribes/tipis/LazyReplicatedMap.java?rev=1498855&r1=1498854&r2=1498855&view=diff
==============================================================================
--- tomcat/tc7.0.x/trunk/java/org/apache/catalina/tribes/tipis/LazyReplicatedMap.java (original)
+++ tomcat/tc7.0.x/trunk/java/org/apache/catalina/tribes/tipis/LazyReplicatedMap.java Tue Jul  2 09:37:08 2013
@@ -72,37 +72,49 @@ public class LazyReplicatedMap extends A
 //              CONSTRUCTORS / DESTRUCTORS
 //------------------------------------------------------------------------------   
     /**
-         * Creates a new map
-         * @param channel The channel to use for communication
-         * @param timeout long - timeout for RPC messags
-         * @param mapContextName String - unique name for this map, to allow multiple maps per channel
-         * @param initialCapacity int - the size of this map, see HashMap
-         * @param loadFactor float - load factor, see HashMap
-         */
-        public LazyReplicatedMap(MapOwner owner, Channel channel, long timeout, String mapContextName, int initialCapacity, float loadFactor, ClassLoader[] cls) {
-            super(owner,channel,timeout,mapContextName,initialCapacity,loadFactor, Channel.SEND_OPTIONS_DEFAULT,cls);
-        }
-
-        /**
-         * Creates a new map
-         * @param channel The channel to use for communication
-         * @param timeout long - timeout for RPC messags
-         * @param mapContextName String - unique name for this map, to allow multiple maps per channel
-         * @param initialCapacity int - the size of this map, see HashMap
-         */
-        public LazyReplicatedMap(MapOwner owner, Channel channel, long timeout, String mapContextName, int initialCapacity, ClassLoader[] cls) {
-            super(owner, channel,timeout,mapContextName,initialCapacity, AbstractReplicatedMap.DEFAULT_LOAD_FACTOR, Channel.SEND_OPTIONS_DEFAULT, cls);
-        }
-
-        /**
-         * Creates a new map
-         * @param channel The channel to use for communication
-         * @param timeout long - timeout for RPC messags
-         * @param mapContextName String - unique name for this map, to allow multiple maps per channel
-         */
-        public LazyReplicatedMap(MapOwner owner, Channel channel, long timeout, String mapContextName, ClassLoader[] cls) {
-            super(owner, channel,timeout,mapContextName, AbstractReplicatedMap.DEFAULT_INITIAL_CAPACITY,AbstractReplicatedMap.DEFAULT_LOAD_FACTOR,Channel.SEND_OPTIONS_DEFAULT, cls);
-        }
+     * Creates a new map
+     * @param channel The channel to use for communication
+     * @param timeout long - timeout for RPC messags
+     * @param mapContextName String - unique name for this map, to allow multiple maps per channel
+     * @param initialCapacity int - the size of this map, see HashMap
+     * @param loadFactor float - load factor, see HashMap
+     */
+    public LazyReplicatedMap(MapOwner owner, Channel channel, long timeout, String mapContextName, int initialCapacity, float loadFactor, ClassLoader[] cls) {
+        super(owner,channel,timeout,mapContextName,initialCapacity,loadFactor, Channel.SEND_OPTIONS_DEFAULT,cls, true);
+    }
+
+    /**
+     * Creates a new map
+     * @param channel The channel to use for communication
+     * @param timeout long - timeout for RPC messags
+     * @param mapContextName String - unique name for this map, to allow multiple maps per channel
+     * @param initialCapacity int - the size of this map, see HashMap
+     */
+    public LazyReplicatedMap(MapOwner owner, Channel channel, long timeout, String mapContextName, int initialCapacity, ClassLoader[] cls) {
+        super(owner, channel,timeout,mapContextName,initialCapacity, AbstractReplicatedMap.DEFAULT_LOAD_FACTOR, Channel.SEND_OPTIONS_DEFAULT, cls, true);
+    }
+
+    /**
+     * Creates a new map
+     * @param channel The channel to use for communication
+     * @param timeout long - timeout for RPC messags
+     * @param mapContextName String - unique name for this map, to allow multiple maps per channel
+     */
+    public LazyReplicatedMap(MapOwner owner, Channel channel, long timeout, String mapContextName, ClassLoader[] cls) {
+        super(owner, channel,timeout,mapContextName, AbstractReplicatedMap.DEFAULT_INITIAL_CAPACITY,AbstractReplicatedMap.DEFAULT_LOAD_FACTOR,Channel.SEND_OPTIONS_DEFAULT, cls, true);
+    }
+
+    /**
+     * Creates a new map
+     * @param channel The channel to use for communication
+     * @param timeout long - timeout for RPC messags
+     * @param mapContextName String - unique name for this map, to allow multiple maps per channel
+     * @param terminate boolean - Flag for whether to terminate this map that failed to start.
+     */
+    public LazyReplicatedMap(MapOwner owner, Channel channel, long timeout, String mapContextName, ClassLoader[] cls, boolean terminate) {
+        super(owner, channel,timeout,mapContextName, AbstractReplicatedMap.DEFAULT_INITIAL_CAPACITY,
+                AbstractReplicatedMap.DEFAULT_LOAD_FACTOR,Channel.SEND_OPTIONS_DEFAULT, cls, terminate);
+    }
 
 
 //------------------------------------------------------------------------------    

Modified: tomcat/tc7.0.x/trunk/java/org/apache/catalina/tribes/tipis/ReplicatedMap.java
URL: http://svn.apache.org/viewvc/tomcat/tc7.0.x/trunk/java/org/apache/catalina/tribes/tipis/ReplicatedMap.java?rev=1498855&r1=1498854&r2=1498855&view=diff
==============================================================================
--- tomcat/tc7.0.x/trunk/java/org/apache/catalina/tribes/tipis/ReplicatedMap.java (original)
+++ tomcat/tc7.0.x/trunk/java/org/apache/catalina/tribes/tipis/ReplicatedMap.java Tue Jul  2 09:37:08 2013
@@ -62,7 +62,7 @@ public class ReplicatedMap extends Abstr
      * @param loadFactor float - load factor, see HashMap
      */
     public ReplicatedMap(MapOwner owner, Channel channel, long timeout, String mapContextName, int initialCapacity,float loadFactor, ClassLoader[] cls) {
-        super(owner,channel, timeout, mapContextName, initialCapacity, loadFactor, Channel.SEND_OPTIONS_DEFAULT, cls);
+        super(owner,channel, timeout, mapContextName, initialCapacity, loadFactor, Channel.SEND_OPTIONS_DEFAULT, cls, true);
     }
 
     /**
@@ -73,7 +73,7 @@ public class ReplicatedMap extends Abstr
      * @param initialCapacity int - the size of this map, see HashMap
      */
     public ReplicatedMap(MapOwner owner, Channel channel, long timeout, String mapContextName, int initialCapacity, ClassLoader[] cls) {
-        super(owner,channel, timeout, mapContextName, initialCapacity, AbstractReplicatedMap.DEFAULT_LOAD_FACTOR,Channel.SEND_OPTIONS_DEFAULT, cls);
+        super(owner,channel, timeout, mapContextName, initialCapacity, AbstractReplicatedMap.DEFAULT_LOAD_FACTOR,Channel.SEND_OPTIONS_DEFAULT, cls, true);
     }
 
     /**
@@ -83,7 +83,19 @@ public class ReplicatedMap extends Abstr
      * @param mapContextName String - unique name for this map, to allow multiple maps per channel
      */
     public ReplicatedMap(MapOwner owner, Channel channel, long timeout, String mapContextName, ClassLoader[] cls) {
-        super(owner, channel, timeout, mapContextName,AbstractReplicatedMap.DEFAULT_INITIAL_CAPACITY, AbstractReplicatedMap.DEFAULT_LOAD_FACTOR, Channel.SEND_OPTIONS_DEFAULT, cls);
+        super(owner, channel, timeout, mapContextName,AbstractReplicatedMap.DEFAULT_INITIAL_CAPACITY, AbstractReplicatedMap.DEFAULT_LOAD_FACTOR, Channel.SEND_OPTIONS_DEFAULT, cls, true);
+    }
+
+    /**
+     * Creates a new map
+     * @param channel The channel to use for communication
+     * @param timeout long - timeout for RPC messags
+     * @param mapContextName String - unique name for this map, to allow multiple maps per channel
+     * @param terminate boolean - Flag for whether to terminate this map that failed to start.
+     */
+    public ReplicatedMap(MapOwner owner, Channel channel, long timeout, String mapContextName, ClassLoader[] cls, boolean terminate) {
+        super(owner, channel, timeout, mapContextName,AbstractReplicatedMap.DEFAULT_INITIAL_CAPACITY,
+                AbstractReplicatedMap.DEFAULT_LOAD_FACTOR, Channel.SEND_OPTIONS_DEFAULT, cls, terminate);
     }
 
 //------------------------------------------------------------------------------

Modified: tomcat/tc7.0.x/trunk/webapps/docs/changelog.xml
URL: http://svn.apache.org/viewvc/tomcat/tc7.0.x/trunk/webapps/docs/changelog.xml?rev=1498855&r1=1498854&r2=1498855&view=diff
==============================================================================
--- tomcat/tc7.0.x/trunk/webapps/docs/changelog.xml (original)
+++ tomcat/tc7.0.x/trunk/webapps/docs/changelog.xml Tue Jul  2 09:37:08 2013
@@ -55,6 +55,20 @@
   They eventually become mixed with the numbered issues. (I.e., numbered
   issues to not "pop up" wrt. others).
 -->
+<section name="Tomcat 7.0.43 (markt)">
+  <subsection name="Cluster">
+    <changelog>
+      <add>
+        Add new attribute terminateOnStartFailure. Set to true if you wish to
+        terminate replication map when replication map fails to start.
+        If replication map is terminated, associated context will fail to start.
+        If you set this attribute to false, replication map does not end.
+        It will try to join the map membership in the heartbeat. Default value
+        is false. (kfujino)
+      </add>
+    </changelog>
+  </subsection>
+</section>
 <section name="Tomcat 7.0.42 (markt)">
   <subsection name="Catalina">
     <changelog>

Modified: tomcat/tc7.0.x/trunk/webapps/docs/config/cluster-manager.xml
URL: http://svn.apache.org/viewvc/tomcat/tc7.0.x/trunk/webapps/docs/config/cluster-manager.xml?rev=1498855&r1=1498854&r2=1498855&view=diff
==============================================================================
--- tomcat/tc7.0.x/trunk/webapps/docs/config/cluster-manager.xml (original)
+++ tomcat/tc7.0.x/trunk/webapps/docs/config/cluster-manager.xml Tue Jul  2 09:37:08 2013
@@ -146,6 +146,13 @@
         another map.
         Default value is <code>15000</code> milliseconds.
       </attribute>
+      <attribute name="terminateOnStartFailure" required="false">
+        Set to true if you wish to terminate replication map when replication
+        map fails to start. If replication map is terminated, associated context
+        will fail to start. If you set this attribute to false, replication map
+        does not end. It will try to join the map membership in the heartbeat.
+        Default value is <code>false</code> .
+      </attribute>
     </attributes>
   </subsection>
 </section>



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