Author: pferraro
Date: 2009-01-27 09:57:49 -0500 (Tue, 27 Jan 2009)
New Revision: 2221
Modified:
trunk/mod_cluster/src/main/java/org/jboss/modcluster/AbstractModClusterService.java
trunk/mod_cluster/src/main/java/org/jboss/modcluster/DefaultJBossWebEventHandler.java
trunk/mod_cluster/src/main/java/org/jboss/modcluster/Utils.java
trunk/mod_cluster/src/main/java/org/jboss/modcluster/ha/HAModClusterService.java
trunk/mod_cluster/src/main/java/org/jboss/modcluster/mcmp/impl/ResetRequestSourceImpl.java
Log:
Ensure excluded contexts are not registered during node reset.
Modified:
trunk/mod_cluster/src/main/java/org/jboss/modcluster/AbstractModClusterService.java
===================================================================
---
trunk/mod_cluster/src/main/java/org/jboss/modcluster/AbstractModClusterService.java 2009-01-27
14:46:09 UTC (rev 2220)
+++
trunk/mod_cluster/src/main/java/org/jboss/modcluster/AbstractModClusterService.java 2009-01-27
14:57:49 UTC (rev 2221)
@@ -50,7 +50,7 @@
public AbstractModClusterService()
{
this.requestFactory = new DefaultMCMPRequestFactory();
- this.mcmpHandler = new DefaultMCMPHandler(this, new ResetRequestSourceImpl(this,
this, this.requestFactory), this.requestFactory);
+ this.mcmpHandler = new DefaultMCMPHandler(this, new ResetRequestSourceImpl(this,
this, this, this.requestFactory), this.requestFactory);
JBossWebEventHandler eventHandler = new DefaultJBossWebEventHandler(this, this,
this, this.mcmpHandler, this.requestFactory, this, new AdvertiseListenerFactoryImpl());
Modified:
trunk/mod_cluster/src/main/java/org/jboss/modcluster/DefaultJBossWebEventHandler.java
===================================================================
---
trunk/mod_cluster/src/main/java/org/jboss/modcluster/DefaultJBossWebEventHandler.java 2009-01-27
14:46:09 UTC (rev 2220)
+++
trunk/mod_cluster/src/main/java/org/jboss/modcluster/DefaultJBossWebEventHandler.java 2009-01-27
14:57:49 UTC (rev 2221)
@@ -24,8 +24,6 @@
import java.io.IOException;
import java.net.InetSocketAddress;
-import java.util.HashMap;
-import java.util.HashSet;
import java.util.List;
import java.util.Map;
import java.util.Set;
@@ -54,12 +52,7 @@
* @author Brian Stansberry
*/
public class DefaultJBossWebEventHandler implements JBossWebEventHandler
-{
- private static final String ROOT_CONTEXT = "ROOT";
- private static final String CONTEXT_DELIMITER = ",";
- private static final String HOST_CONTEXT_DELIMITER = ":";
- private static final String DEFAULT_HOST = "localhost";
-
+{
static final Logger log = Logger.getLogger(DefaultJBossWebEventHandler.class);
// ----------------------------------------------------------------- Fields
@@ -75,12 +68,12 @@
private final MCMPRequestFactory requestFactory;
private final AdvertiseListenerFactory listenerFactory;
private final LoadBalanceFactorProviderFactory loadBalanceFactorProviderFactory;
- private final Map<String, Set<String>> excludedContextPaths = new
HashMap<String, Set<String>>();
private volatile boolean init;
private LoadBalanceFactorProvider loadBalanceFactorProvider;
private AdvertiseListener advertiseListener;
+ private Map<String, Set<String>> excludedContextPaths;
public DefaultJBossWebEventHandler(NodeConfiguration nodeConfig, BalancerConfiguration
balancerConfig,
MCMPHandlerConfiguration mcmpConfig, MCMPHandler mcmpHandler, MCMPRequestFactory
requestFactory,
@@ -102,47 +95,7 @@
List<InetSocketAddress> initialProxies =
Utils.parseProxies(this.mcmpConfig.getProxyList());
this.mcmpHandler.init(initialProxies);
- String contexts = this.mcmpConfig.getExcludedContexts();
-
- if (contexts != null)
- {
- String trimmedContexts = contexts.trim();
-
- if (trimmedContexts.length() > 0)
- {
- for (String context: trimmedContexts.split(CONTEXT_DELIMITER))
- {
- String[] parts = context.trim().split(HOST_CONTEXT_DELIMITER);
-
- if (parts.length > 2)
- {
- throw new IllegalArgumentException(trimmedContexts + " is not a
valid value for excludedContexts");
- }
-
- String host = DEFAULT_HOST;
- String trimmedContext = parts[0].trim();
-
- if (parts.length == 2)
- {
- host = trimmedContext;
- trimmedContext = parts[1].trim();
- }
-
- String path = trimmedContext.equals(ROOT_CONTEXT) ? "" :
"/" + trimmedContext;
-
- Set<String> paths = this.excludedContextPaths.get(host);
-
- if (paths == null)
- {
- paths = new HashSet<String>();
-
- this.excludedContextPaths.put(host, paths);
- }
-
- paths.add(path);
- }
- }
- }
+ this.excludedContextPaths =
Utils.parseContexts(this.mcmpConfig.getExcludedContexts());
this.loadBalanceFactorProvider =
this.loadBalanceFactorProviderFactory.createLoadBalanceFactorProvider();
Modified: trunk/mod_cluster/src/main/java/org/jboss/modcluster/Utils.java
===================================================================
--- trunk/mod_cluster/src/main/java/org/jboss/modcluster/Utils.java 2009-01-27 14:46:09
UTC (rev 2220)
+++ trunk/mod_cluster/src/main/java/org/jboss/modcluster/Utils.java 2009-01-27 14:57:49
UTC (rev 2221)
@@ -8,8 +8,11 @@
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;
+import java.util.HashMap;
+import java.util.HashSet;
import java.util.LinkedHashSet;
import java.util.List;
+import java.util.Map;
import java.util.Set;
import org.apache.catalina.Context;
@@ -27,6 +30,10 @@
public class Utils
{
+ private static final String ROOT_CONTEXT = "ROOT";
+ private static final String CONTEXT_DELIMITER = ",";
+ private static final String HOST_CONTEXT_DELIMITER = ":";
+ private static final String DEFAULT_HOST = "localhost";
private static final int DEFAULT_PORT = 8000;
private static final Logger log = Logger.getLogger(Utils.class);
@@ -275,6 +282,51 @@
return new InetSocketAddress(inetAddress, port);
}
+ public static Map<String, Set<String>> parseContexts(String contexts)
+ {
+ if (contexts == null) return Collections.emptyMap();
+
+ String trimmedContexts = contexts.trim();
+
+ if (trimmedContexts.length() == 0) return Collections.emptyMap();
+
+ Map<String, Set<String>> map = new HashMap<String,
Set<String>>();
+
+ for (String context: trimmedContexts.split(CONTEXT_DELIMITER))
+ {
+ String[] parts = context.trim().split(HOST_CONTEXT_DELIMITER);
+
+ if (parts.length > 2)
+ {
+ throw new IllegalArgumentException(trimmedContexts + " is not a valid
value for excludedContexts");
+ }
+
+ String host = DEFAULT_HOST;
+ String trimmedContext = parts[0].trim();
+
+ if (parts.length == 2)
+ {
+ host = trimmedContext;
+ trimmedContext = parts[1].trim();
+ }
+
+ String path = trimmedContext.equals(ROOT_CONTEXT) ? "" : "/"
+ trimmedContext;
+
+ Set<String> paths = map.get(host);
+
+ if (paths == null)
+ {
+ paths = new HashSet<String>();
+
+ map.put(host, paths);
+ }
+
+ paths.add(path);
+ }
+
+ return map;
+ }
+
private Utils()
{
}
Modified:
trunk/mod_cluster/src/main/java/org/jboss/modcluster/ha/HAModClusterService.java
===================================================================
---
trunk/mod_cluster/src/main/java/org/jboss/modcluster/ha/HAModClusterService.java 2009-01-27
14:46:09 UTC (rev 2220)
+++
trunk/mod_cluster/src/main/java/org/jboss/modcluster/ha/HAModClusterService.java 2009-01-27
14:57:49 UTC (rev 2221)
@@ -159,7 +159,7 @@
this.loadBalanceFactorProvider = loadFactorProvider;
this.requestFactory = new DefaultMCMPRequestFactory();
- this.resetRequestSource = new HASingletonAwareResetRequestSourceImpl(config,
config, this.requestFactory, this, this);
+ this.resetRequestSource = new HASingletonAwareResetRequestSourceImpl(config,
config, config, this.requestFactory, this, this);
this.localHandler = new DefaultMCMPHandler(config, this.resetRequestSource,
this.requestFactory);
this.clusteredHandler = new ClusteredMCMPHandlerImpl(this.localHandler, this,
this);
Modified:
trunk/mod_cluster/src/main/java/org/jboss/modcluster/mcmp/impl/ResetRequestSourceImpl.java
===================================================================
---
trunk/mod_cluster/src/main/java/org/jboss/modcluster/mcmp/impl/ResetRequestSourceImpl.java 2009-01-27
14:46:09 UTC (rev 2220)
+++
trunk/mod_cluster/src/main/java/org/jboss/modcluster/mcmp/impl/ResetRequestSourceImpl.java 2009-01-27
14:57:49 UTC (rev 2221)
@@ -38,6 +38,7 @@
import org.apache.catalina.Service;
import org.jboss.modcluster.Utils;
import org.jboss.modcluster.config.BalancerConfiguration;
+import org.jboss.modcluster.config.MCMPHandlerConfiguration;
import org.jboss.modcluster.config.NodeConfiguration;
import org.jboss.modcluster.mcmp.MCMPRequest;
import org.jboss.modcluster.mcmp.MCMPRequestFactory;
@@ -52,12 +53,14 @@
{
private final NodeConfiguration nodeConfig;
private final BalancerConfiguration balancerConfig;
+ private final MCMPHandlerConfiguration mcmpConfig;
private final MCMPRequestFactory requestFactory;
- public ResetRequestSourceImpl(NodeConfiguration nodeConfig, BalancerConfiguration
balancerConfig, MCMPRequestFactory requestFactory)
+ public ResetRequestSourceImpl(NodeConfiguration nodeConfig, BalancerConfiguration
balancerConfig, MCMPHandlerConfiguration mcmpConfig, MCMPRequestFactory requestFactory)
{
this.nodeConfig = nodeConfig;
this.balancerConfig = balancerConfig;
+ this.mcmpConfig = mcmpConfig;
this.requestFactory = requestFactory;
}
@@ -72,6 +75,9 @@
protected List<MCMPRequest> getResetRequests(Map<String,
Set<VirtualHost>> response, Server server)
{
+ // TODO This is a hack - we shouldn't have to parse the exclusion list every
time
+ Map<String, Set<String>> excludedContexts =
Utils.parseContexts(this.mcmpConfig.getExcludedContexts());
+
List<MCMPRequest> requests = new ArrayList<MCMPRequest>();
List<MCMPRequest> engineRequests = new LinkedList<MCMPRequest>();
@@ -131,6 +137,13 @@
Context context = (Context) container;
String path = context.getPath();
+ Set<String> excludedPaths = excludedContexts.get(hostName);
+
+ if ((excludedPaths != null) && excludedPaths.contains(path))
+ {
+ continue;
+ }
+
obsoleteContexts.remove(path);
ResetRequestSource.Status status = responseContexts.get(path);