tomcat-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From kfuj...@apache.org
Subject svn commit: r1498820 - in /tomcat/trunk/java/org/apache/catalina/tribes/tipis: AbstractReplicatedMap.java LazyReplicatedMap.java ReplicatedMap.java
Date Tue, 02 Jul 2013 08:11:52 GMT
Author: kfujino
Date: Tue Jul  2 08:11:52 2013
New Revision: 1498820

URL: http://svn.apache.org/r1498820
Log:
Ensure the application will start even if replication map fails to start.

Modified:
    tomcat/trunk/java/org/apache/catalina/tribes/tipis/AbstractReplicatedMap.java
    tomcat/trunk/java/org/apache/catalina/tribes/tipis/LazyReplicatedMap.java
    tomcat/trunk/java/org/apache/catalina/tribes/tipis/ReplicatedMap.java

Modified: tomcat/trunk/java/org/apache/catalina/tribes/tipis/AbstractReplicatedMap.java
URL: http://svn.apache.org/viewvc/tomcat/trunk/java/org/apache/catalina/tribes/tipis/AbstractReplicatedMap.java?rev=1498820&r1=1498819&r2=1498820&view=diff
==============================================================================
--- tomcat/trunk/java/org/apache/catalina/tribes/tipis/AbstractReplicatedMap.java (original)
+++ tomcat/trunk/java/org/apache/catalina/tribes/tipis/AbstractReplicatedMap.java Tue Jul
 2 08:11:52 2013
@@ -172,9 +172,10 @@ public abstract class AbstractReplicated
                                  int initialCapacity,
                                  float loadFactor,
                                  int channelSendOptions,
-                                 ClassLoader[] cls) {
+                                 ClassLoader[] cls,
+                                 boolean terminate) {
         innerMap = new ConcurrentHashMap<>(initialCapacity, loadFactor, 15);
-        init(owner, channel, mapContextName, timeout, channelSendOptions, cls);
+        init(owner, channel, mapContextName, timeout, channelSendOptions, cls, terminate);
 
     }
 
@@ -198,7 +199,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;
@@ -228,11 +230,13 @@ 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) {
+                // remove listener from channel
+                this.rpcChannel.breakdown();
+                this.channel.removeChannelListener(this);
+                this.channel.removeMembershipListener(this);
+                throw new RuntimeException("Unable to start replicated map.",x);
+            }
         }
     }
 

Modified: tomcat/trunk/java/org/apache/catalina/tribes/tipis/LazyReplicatedMap.java
URL: http://svn.apache.org/viewvc/tomcat/trunk/java/org/apache/catalina/tribes/tipis/LazyReplicatedMap.java?rev=1498820&r1=1498819&r2=1498820&view=diff
==============================================================================
--- tomcat/trunk/java/org/apache/catalina/tribes/tipis/LazyReplicatedMap.java (original)
+++ tomcat/trunk/java/org/apache/catalina/tribes/tipis/LazyReplicatedMap.java Tue Jul  2 08:11:52
2013
@@ -80,7 +80,7 @@ public class LazyReplicatedMap<K,V> exte
          * @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);
+            super(owner,channel,timeout,mapContextName,initialCapacity,loadFactor, Channel.SEND_OPTIONS_DEFAULT,cls,
true);
         }
 
         /**
@@ -91,7 +91,7 @@ public class LazyReplicatedMap<K,V> exte
          * @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);
+            super(owner, channel,timeout,mapContextName,initialCapacity, AbstractReplicatedMap.DEFAULT_LOAD_FACTOR,
Channel.SEND_OPTIONS_DEFAULT, cls, true);
         }
 
         /**
@@ -101,7 +101,19 @@ public class LazyReplicatedMap<K,V> exte
          * @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);
+            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/trunk/java/org/apache/catalina/tribes/tipis/ReplicatedMap.java
URL: http://svn.apache.org/viewvc/tomcat/trunk/java/org/apache/catalina/tribes/tipis/ReplicatedMap.java?rev=1498820&r1=1498819&r2=1498820&view=diff
==============================================================================
--- tomcat/trunk/java/org/apache/catalina/tribes/tipis/ReplicatedMap.java (original)
+++ tomcat/trunk/java/org/apache/catalina/tribes/tipis/ReplicatedMap.java Tue Jul  2 08:11:52
2013
@@ -62,7 +62,7 @@ public class ReplicatedMap<K,V> extends 
      * @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<K,V> extends 
      * @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<K,V> extends 
      * @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);
     }
 
 //------------------------------------------------------------------------------



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


Mime
View raw message