Author: pferraro
Date: 2009-01-26 16:05:35 -0500 (Mon, 26 Jan 2009)
New Revision: 2215
Modified:
trunk/mod_cluster/src/main/java/org/jboss/modcluster/DefaultJBossWebEventHandler.java
trunk/mod_cluster/src/main/resources/mod-cluster-jboss-beans.xml
Log:
Store excluded contexts in a map, keyed by host.
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-26
17:06:41 UTC (rev 2214)
+++
trunk/mod_cluster/src/main/java/org/jboss/modcluster/DefaultJBossWebEventHandler.java 2009-01-26
21:05:35 UTC (rev 2215)
@@ -24,8 +24,10 @@
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;
import org.apache.catalina.Container;
@@ -54,6 +56,10 @@
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
@@ -69,7 +75,7 @@
private final MCMPRequestFactory requestFactory;
private final AdvertiseListenerFactory listenerFactory;
private final LoadBalanceFactorProviderFactory loadBalanceFactorProviderFactory;
- private final Set<String> excludedContextPaths = new HashSet<String>();
+ private final Map<String, Set<String>> excludedContextPaths = new
HashMap<String, Set<String>>();
private volatile boolean init;
@@ -98,14 +104,43 @@
String contexts = this.mcmpConfig.getExcludedContexts();
- if ((contexts != null) && (contexts.length() > 0))
+ if (contexts != null)
{
- for (String context: contexts.split(","))
+ String trimmedContexts = contexts.trim();
+
+ if (trimmedContexts.length() > 0)
{
- String trimmedContext = context.trim();
- String path = trimmedContext.equals(ROOT_CONTEXT) ? "" :
"/" + trimmedContext;
-
- this.excludedContextPaths.add(path);
+ 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);
+ }
}
}
@@ -238,15 +273,14 @@
{
this.checkInit();
- String path = context.getPath();
-
- if (!this.excludedContextPaths.contains(path))
+ if (!this.exclude(context))
{
- log.debug(this.sm.getString("modcluster.context.enable", path,
context.getParent().getName()));
-
+ log.info(context.getParent().getName() + ":" + context.getPath() +
" is *not* exluded.");
// Send ENABLE-APP if state is started
if (Utils.isContextStarted(context))
{
+ log.debug(this.sm.getString("modcluster.context.enable",
context.getPath(), context.getParent().getName()));
+
MCMPRequest request = this.requestFactory.createEnableRequest(context);
this.mcmpHandler.sendRequest(request);
@@ -258,11 +292,9 @@
{
this.checkInit();
- String path = context.getPath();
-
- if (!this.excludedContextPaths.contains(path))
+ if (!this.exclude(context))
{
- log.debug(this.sm.getString("modcluster.context.start", path,
context.getParent().getName()));
+ log.debug(this.sm.getString("modcluster.context.start",
context.getPath(), context.getParent().getName()));
// Send ENABLE-APP
MCMPRequest request = this.requestFactory.createEnableRequest(context);
@@ -275,11 +307,9 @@
{
this.checkInit();
- String path = context.getPath();
-
- if (!this.excludedContextPaths.contains(path))
+ if (!this.exclude(context))
{
- log.debug(this.sm.getString("modcluster.context.stop", path,
context.getParent().getName()));
+ log.debug(this.sm.getString("modcluster.context.stop",
context.getPath(), context.getParent().getName()));
// Send STOP-APP
MCMPRequest request = this.requestFactory.createStopRequest(context);
@@ -292,15 +322,13 @@
{
this.checkInit();
- String path = context.getPath();
-
- if (!this.excludedContextPaths.contains(path))
+ if (!this.exclude(context))
{
- log.debug(this.sm.getString("modcluster.context.disable", path,
context.getParent().getName()));
-
// JVMRoute can be null here if nothing was ever initialized
if (Utils.getJvmRoute(context) != null)
{
+ log.debug(this.sm.getString("modcluster.context.disable",
context.getPath(), context.getParent().getName()));
+
MCMPRequest request = this.requestFactory.createRemoveRequest(context);
this.mcmpHandler.sendRequest(request);
@@ -310,11 +338,11 @@
protected void removeAll(Engine engine)
{
- log.debug(this.sm.getString("modcluster.engine.stop",
engine.getName()));
-
// JVMRoute can be null here if nothing was ever initialized
if (engine.getJvmRoute() != null)
{
+ log.debug(this.sm.getString("modcluster.engine.stop",
engine.getName()));
+
// Send REMOVE-APP * request
MCMPRequest request = this.requestFactory.createRemoveRequest(engine);
@@ -349,4 +377,11 @@
throw new
IllegalStateException(this.sm.getString("modcluster.error.uninitialized"));
}
}
+
+ private boolean exclude(Context context)
+ {
+ Set<String> excludedPaths =
this.excludedContextPaths.get(context.getParent().getName());
+
+ return (excludedPaths != null) ? excludedPaths.contains(context.getPath()) :
false;
+ }
}
Modified: trunk/mod_cluster/src/main/resources/mod-cluster-jboss-beans.xml
===================================================================
--- trunk/mod_cluster/src/main/resources/mod-cluster-jboss-beans.xml 2009-01-26 17:06:41
UTC (rev 2214)
+++ trunk/mod_cluster/src/main/resources/mod-cluster-jboss-beans.xml 2009-01-26 21:05:35
UTC (rev 2215)
@@ -114,7 +114,7 @@
<constructor>
<parameter><inject
bean="DynamicLoadBalanceFactorProvider"/></parameter>
</constructor>
- <!-- Comma separated list of address:port listing the httpd servers
+ <!-- Comma delimited list of address:port listing the httpd servers
where mod_cluster is running. -->
<property
name="proxyList">${jboss.modcluster.proxyList}</property>
<!-- URL prefix to send with commands to mod_cluster. Default is no prefix.
-->
@@ -122,8 +122,8 @@
<!-- mod_advertise is a small httpd module that advertises the
availability of httpd servers via multicast, allowing
- ModClusterService to discover the httpd front-end instead of/in
- addition to having them defined in proxyList. -->
+ ModClusterService to discover the httpd front-end instead of
+ (or in addition to) having them defined in proxyList. -->
<!-- Whether to listen for advertise messages -->
<property name="advertise">true</property>
<!-- Multicast address on which to listen for advertisements -->
@@ -131,8 +131,10 @@
<!-- Port to listen to for advertisements -->
<property
name="advertisePort">${jboss.modcluster.advertise.port:23364}</property>
- <!-- List of contexts that should not be auto-registered with httpd delimited by
commas. -->
+ <!-- Comma delimited list of contexts that should *not* be auto-registered with
httpd. -->
<!-- ROOT indicates the root context. -->
+ <!-- Context may be qualified by host using a colon, e.g. host1:context1 -->
+ <!-- If no host is defined, localhost is assumed. -->
<property
name="excludedContexts">${jboss.modcluster.excludedContexts:ROOT,invoker,jbossws,jmx-console,juddi,web-console}</property>
<!-- Security key the proxy is going to send with advertise messages.