Author: pferraro
Date: 2008-10-31 16:16:19 -0400 (Fri, 31 Oct 2008)
New Revision: 2038
Added:
trunk/mod_cluster/src/main/java/org/jboss/modcluster/mcmp/impl/ResetRequestSourceImpl.java
Modified:
trunk/mod_cluster/src/main/java/org/jboss/modcluster/ModClusterService.java
trunk/mod_cluster/src/main/java/org/jboss/modcluster/ha/HASingletonAwareResetRequestSource.java
trunk/mod_cluster/src/main/java/org/jboss/modcluster/ha/HASingletonAwareResetRequestSourceImpl.java
trunk/mod_cluster/src/main/java/org/jboss/modcluster/ha/rpc/ResetRequestSourceRpcHandler.java
trunk/mod_cluster/src/main/java/org/jboss/modcluster/mcmp/MCMPUtils.java
trunk/mod_cluster/src/main/java/org/jboss/modcluster/mcmp/ResetRequestSource.java
trunk/mod_cluster/src/main/java/org/jboss/modcluster/mcmp/impl/DefaultMCMPHandler.java
Log:
Refactored reset request source logic to support multiple virtual hosts
Reset request logic will now handle missing vhosts.
Modified: trunk/mod_cluster/src/main/java/org/jboss/modcluster/ModClusterService.java
===================================================================
--- trunk/mod_cluster/src/main/java/org/jboss/modcluster/ModClusterService.java 2008-10-31
20:14:18 UTC (rev 2037)
+++ trunk/mod_cluster/src/main/java/org/jboss/modcluster/ModClusterService.java 2008-10-31
20:16:19 UTC (rev 2038)
@@ -522,7 +522,7 @@
boolean needReset = this.coord.clusteredHandler.getNeedsResetTransmission();
- Map<String, ResetRequestSource.EngineStatus> map =
Collections.emptyMap();
+ Map<String, Set<ResetRequestSource.VirtualHost>> map =
Collections.emptyMap();
List<MCMPRequest> resetRequests = needReset ?
this.coord.resetRequestSource.getLocalResetRequests(map) : null;
ClusterNode node = ModClusterService.this.getHAPartition().getClusterNode();
@@ -661,7 +661,7 @@
/**
* @see
org.jboss.modcluster.ha.rpc.ResetRequestSourceRpcHandler#getResetRequests()
*/
- public GroupRpcResponse getResetRequests(Map<String,
ResetRequestSource.EngineStatus> response)
+ public GroupRpcResponse getResetRequests(Map<String,
Set<ResetRequestSource.VirtualHost>> response)
{
ClusterNode node = ModClusterService.this.getHAPartition().getClusterNode();
List<MCMPRequest> requests =
this.coord.resetRequestSource.getLocalResetRequests(response);
Modified:
trunk/mod_cluster/src/main/java/org/jboss/modcluster/ha/HASingletonAwareResetRequestSource.java
===================================================================
---
trunk/mod_cluster/src/main/java/org/jboss/modcluster/ha/HASingletonAwareResetRequestSource.java 2008-10-31
20:14:18 UTC (rev 2037)
+++
trunk/mod_cluster/src/main/java/org/jboss/modcluster/ha/HASingletonAwareResetRequestSource.java 2008-10-31
20:16:19 UTC (rev 2038)
@@ -23,6 +23,7 @@
import java.util.List;
import java.util.Map;
+import java.util.Set;
import org.apache.catalina.Server;
import org.jboss.modcluster.mcmp.MCMPRequest;
@@ -34,7 +35,7 @@
*/
public interface HASingletonAwareResetRequestSource extends ResetRequestSource
{
- List<MCMPRequest> getLocalResetRequests(Map<String,
ResetRequestSource.EngineStatus> response);
+ List<MCMPRequest> getLocalResetRequests(Map<String,
Set<ResetRequestSource.VirtualHost>> response);
void setJbossWebServer(Server jbossWebServer);
}
\ No newline at end of file
Modified:
trunk/mod_cluster/src/main/java/org/jboss/modcluster/ha/HASingletonAwareResetRequestSourceImpl.java
===================================================================
---
trunk/mod_cluster/src/main/java/org/jboss/modcluster/ha/HASingletonAwareResetRequestSourceImpl.java 2008-10-31
20:14:18 UTC (rev 2037)
+++
trunk/mod_cluster/src/main/java/org/jboss/modcluster/ha/HASingletonAwareResetRequestSourceImpl.java 2008-10-31
20:16:19 UTC (rev 2038)
@@ -26,6 +26,7 @@
import java.util.Collections;
import java.util.List;
import java.util.Map;
+import java.util.Set;
import org.apache.catalina.Server;
import org.apache.catalina.util.StringManager;
@@ -40,8 +41,8 @@
import org.jboss.modcluster.ha.rpc.ResetRequestSourceRpcHandler;
import org.jboss.modcluster.ha.rpc.ThrowableGroupRpcResponse;
import org.jboss.modcluster.mcmp.MCMPRequest;
-import org.jboss.modcluster.mcmp.MCMPUtils;
import org.jboss.modcluster.mcmp.ResetRequestSource;
+import org.jboss.modcluster.mcmp.impl.ResetRequestSourceImpl;
/**
* {@link ResetRequestSource} that provides different reset requests
@@ -50,7 +51,7 @@
*
* @author Brian Stansberry
*/
-public class HASingletonAwareResetRequestSourceImpl implements
HASingletonAwareResetRequestSource
+public class HASingletonAwareResetRequestSourceImpl extends ResetRequestSourceImpl
implements HASingletonAwareResetRequestSource
{
static final String METHOD_NAME = "getResetRequests";
static final Class<?>[] TYPES = new Class[] { Map.class };
@@ -62,21 +63,19 @@
*/
private final StringManager sm = StringManager.getManager(Constants.Package);
- private final NodeConfiguration nodeConfig;
- private final BalancerConfiguration balancerConfig;
private final HASingletonMBean singleton;
private final ResetRequestSourceRpcHandler<List<?>> rpcStub;
private volatile Server jbossWebServer;
public HASingletonAwareResetRequestSourceImpl(NodeConfiguration nodeConfig,
BalancerConfiguration balancerConfig, HASingletonMBean singleton, HAServiceKeyProvider
serviceKeyProvider)
{
- this.nodeConfig = nodeConfig;
- this.balancerConfig = balancerConfig;
+ super(nodeConfig, balancerConfig);
this.singleton = singleton;
this.rpcStub = new RpcStub(serviceKeyProvider);
}
- public List<MCMPRequest> getResetRequests(Map<String,
ResetRequestSource.EngineStatus> response)
+ @Override
+ public List<MCMPRequest> getResetRequests(Map<String,
Set<VirtualHost>> response)
{
if (this.singleton.isMasterNode())
{
@@ -92,14 +91,14 @@
* @{inheritDoc}
* @see
org.jboss.modcluster.ha.HASingletonAwareResetRequestSource#getLocalResetRequests()
*/
- public List<MCMPRequest> getLocalResetRequests(Map<String,
ResetRequestSource.EngineStatus> response)
+ public List<MCMPRequest> getLocalResetRequests(Map<String,
Set<VirtualHost>> response)
{
if (this.jbossWebServer == null)
{
return new ArrayList<MCMPRequest>();
}
- return MCMPUtils.getResetRequests(response, this.jbossWebServer, this.nodeConfig,
this.balancerConfig);
+ return super.getResetRequests(response, this.jbossWebServer);
}
/**
@@ -111,7 +110,7 @@
this.jbossWebServer = jbossWebServer;
}
- private void addRemoteRequests(List<MCMPRequest> resets, Map<String,
ResetRequestSource.EngineStatus> resp)
+ private void addRemoteRequests(List<MCMPRequest> resets, Map<String,
Set<VirtualHost>> resp)
{
List<?> responses = this.rpcStub.getResetRequests(resp);
@@ -151,7 +150,7 @@
/**
* @see
org.jboss.modcluster.ha.rpc.ResetRequestSourceRpcHandler#getResetRequests()
*/
- public List<?> getResetRequests(Map<String,
ResetRequestSource.EngineStatus> response)
+ public List<?> getResetRequests(Map<String,
Set<ResetRequestSource.VirtualHost>> response)
{
try
{
Modified:
trunk/mod_cluster/src/main/java/org/jboss/modcluster/ha/rpc/ResetRequestSourceRpcHandler.java
===================================================================
---
trunk/mod_cluster/src/main/java/org/jboss/modcluster/ha/rpc/ResetRequestSourceRpcHandler.java 2008-10-31
20:14:18 UTC (rev 2037)
+++
trunk/mod_cluster/src/main/java/org/jboss/modcluster/ha/rpc/ResetRequestSourceRpcHandler.java 2008-10-31
20:16:19 UTC (rev 2038)
@@ -22,6 +22,7 @@
package org.jboss.modcluster.ha.rpc;
import java.util.Map;
+import java.util.Set;
import org.jboss.modcluster.mcmp.ResetRequestSource;
@@ -32,5 +33,5 @@
*/
public interface ResetRequestSourceRpcHandler<T>
{
- T getResetRequests(Map<String, ResetRequestSource.EngineStatus> response);
+ T getResetRequests(Map<String, Set<ResetRequestSource.VirtualHost>>
response);
}
Modified: trunk/mod_cluster/src/main/java/org/jboss/modcluster/mcmp/MCMPUtils.java
===================================================================
--- trunk/mod_cluster/src/main/java/org/jboss/modcluster/mcmp/MCMPUtils.java 2008-10-31
20:14:18 UTC (rev 2037)
+++ trunk/mod_cluster/src/main/java/org/jboss/modcluster/mcmp/MCMPUtils.java 2008-10-31
20:16:19 UTC (rev 2038)
@@ -37,6 +37,7 @@
import org.apache.catalina.Container;
import org.apache.catalina.Context;
import org.apache.catalina.Engine;
+import org.apache.catalina.Host;
import org.apache.catalina.Server;
import org.apache.catalina.Service;
import org.apache.catalina.connector.Connector;
@@ -48,6 +49,7 @@
import org.jboss.modcluster.Utils;
import org.jboss.modcluster.config.BalancerConfiguration;
import org.jboss.modcluster.config.NodeConfiguration;
+import org.jboss.modcluster.mcmp.ResetRequestSource.VirtualHost;
/**
* Utility methods related to the Mod-Cluster Management Protocol.
@@ -263,7 +265,7 @@
/**
* Reset configuration for a particular proxy following an error.
*/
- public static List<MCMPRequest> getResetRequests(Map<String,
ResetRequestSource.EngineStatus> response, Server server, NodeConfiguration nodeConfig,
BalancerConfiguration balancerConfig)
+ public static List<MCMPRequest> getResetRequests(Map<String,
Set<ResetRequestSource.VirtualHost>> response, Server server, NodeConfiguration
nodeConfig, BalancerConfiguration balancerConfig)
{
List<MCMPRequest> requests = new ArrayList<MCMPRequest>();
List<MCMPRequest> engineRequests = new LinkedList<MCMPRequest>();
@@ -275,49 +277,74 @@
engineRequests.add(createConfigRequest(jvmRoute, service.findConnectors(),
nodeConfig, balancerConfig));
- ResetRequestSource.EngineStatus engineStatus = response.get(jvmRoute);
- Map<String, ResetRequestSource.Status> contexts = Collections.emptyMap();
- if (engineStatus != null)
- {
- contexts = engineStatus.getContexts();
- }
+ Set<ResetRequestSource.VirtualHost> virtualHosts =
response.get(jvmRoute);
- Set<String> oldContexts = new HashSet<String>(contexts.keySet());
-
for (Container child: engine.findChildren())
{
- for (Container container: child.findChildren())
+ Host host = (Host) child;
+ String hostName = host.getName();
+ Set<String> aliases = Utils.getAliases(host);
+
+ VirtualHost responseHost = null;
+
+ for (VirtualHost virtualHost: virtualHosts)
{
+ if (virtualHost.getAliases().contains(hostName))
+ {
+ responseHost = virtualHost;
+ break;
+ }
+ }
+
+ Set<String> responseAliases = Collections.emptySet();
+ Map<String, ResetRequestSource.Status> responseContexts =
Collections.emptyMap();
+
+ if (responseHost != null)
+ {
+ responseAliases = responseHost.getAliases();
+
+ // If the host(or aliases) is missing - force full reset
+ if (!aliases.equals(responseAliases))
+ {
+ engineRequests.add(0, createEngineRequest(MCMPRequestType.REMOVE_APP,
jvmRoute));
+ }
+ else
+ {
+ responseContexts = responseHost.getContexts();
+ }
+ }
+
+ Set<String> obsoleteContexts = new
HashSet<String>(responseContexts.keySet());
+
+ for (Container container: host.findChildren())
+ {
Context context = (Context) container;
String path = context.getPath();
- oldContexts.remove(path);
+ obsoleteContexts.remove(path);
- ResetRequestSource.Status status = contexts.get(path);
+ ResetRequestSource.Status status = responseContexts.get(path);
if (Utils.isContextStarted(context))
{
if (status != ResetRequestSource.Status.ENABLED)
{
- engineRequests.add(createContextRequest(MCMPRequestType.ENABLE_APP,
jvmRoute, Utils.getAliases(context), path));
+ engineRequests.add(createContextRequest(MCMPRequestType.ENABLE_APP,
jvmRoute, responseAliases, path));
}
}
else
{
if (status == ResetRequestSource.Status.ENABLED)
{
- engineRequests.add(createContextRequest(MCMPRequestType.STOP_APP,
jvmRoute, Utils.getAliases(context), path));
+ engineRequests.add(createContextRequest(MCMPRequestType.STOP_APP,
jvmRoute, responseAliases, path));
}
}
}
- }
-
- if (engineStatus != null)
- {
- if (!contexts.isEmpty())
+
+ if (!obsoleteContexts.isEmpty())
{
- // If all old contexts no longer exist - remove all
- if (oldContexts.size() == contexts.size())
+ // If all contexts from response no longer exist - remove all
+ if (obsoleteContexts.size() == responseContexts.size())
{
// Send REMOVE-APP * request first
engineRequests.add(0, createEngineRequest(MCMPRequestType.REMOVE_APP,
jvmRoute));
@@ -325,12 +352,9 @@
// otherwise only remove those that no longer exist
else
{
- Set<String> aliases = engineStatus.getAliases();
-
- for (String context: contexts.keySet())
+ for (String context: obsoleteContexts)
{
- // Send REMOVE-APP requests first
- engineRequests.add(0,
createContextRequest(MCMPRequestType.REMOVE_APP, jvmRoute, aliases, context));
+ engineRequests.add(createContextRequest(MCMPRequestType.REMOVE_APP,
jvmRoute, responseAliases, context));
}
}
}
Modified:
trunk/mod_cluster/src/main/java/org/jboss/modcluster/mcmp/ResetRequestSource.java
===================================================================
---
trunk/mod_cluster/src/main/java/org/jboss/modcluster/mcmp/ResetRequestSource.java 2008-10-31
20:14:18 UTC (rev 2037)
+++
trunk/mod_cluster/src/main/java/org/jboss/modcluster/mcmp/ResetRequestSource.java 2008-10-31
20:16:19 UTC (rev 2038)
@@ -42,7 +42,7 @@
ENABLED, DISABLED, STOPPED
}
- interface EngineStatus extends Serializable
+ interface VirtualHost extends Serializable
{
Set<String> getAliases();
Map<String, Status> getContexts();
@@ -53,8 +53,8 @@
* mod_cluster instance when an {@link MCMPHandler} determines that
* its state needs to be reset.
*
- * @param response a parsed INFO-RSP, expressed as the context status per context
path, per jvmRoute
+ * @param response a parsed INFO-RSP, expressed as a map of virtual hosts per
jvmRoute
* @return a list of requests. Will not return <code>null</code>.
*/
- List<MCMPRequest> getResetRequests(Map<String, EngineStatus> response);
+ List<MCMPRequest> getResetRequests(Map<String, Set<VirtualHost>>
response);
}
Modified:
trunk/mod_cluster/src/main/java/org/jboss/modcluster/mcmp/impl/DefaultMCMPHandler.java
===================================================================
---
trunk/mod_cluster/src/main/java/org/jboss/modcluster/mcmp/impl/DefaultMCMPHandler.java 2008-10-31
20:14:18 UTC (rev 2037)
+++
trunk/mod_cluster/src/main/java/org/jboss/modcluster/mcmp/impl/DefaultMCMPHandler.java 2008-10-31
20:16:19 UTC (rev 2038)
@@ -37,6 +37,7 @@
import java.util.ArrayList;
import java.util.Collections;
import java.util.HashMap;
+import java.util.HashSet;
import java.util.Iterator;
import java.util.LinkedHashSet;
import java.util.List;
@@ -460,7 +461,7 @@
if (sendResetRequests)
{
- Map<String, ResetRequestSource.EngineStatus> parsedResponse =
this.parseInfoResponse(response);
+ Map<String, Set<ResetRequestSource.VirtualHost>>
parsedResponse = this.parseInfoResponse(response);
List<MCMPRequest> requests =
this.resetRequestSource.getResetRequests(parsedResponse);
@@ -478,7 +479,7 @@
}
}
- private Map<String, ResetRequestSource.EngineStatus> parseInfoResponse(String
response)
+ private Map<String, Set<ResetRequestSource.VirtualHost>>
parseInfoResponse(String response)
{
if (response == null) return Collections.emptyMap();
@@ -486,117 +487,173 @@
// Map node id -> node name (i.e. jvm route)
Map<String, String> nodeMap = new HashMap<String, String>();
- Map<String, ResetRequestSource.EngineStatus> result = new HashMap<String,
ResetRequestSource.EngineStatus>();
+ // Map node name -> vhost id -> virtual host
+ Map<String, Map<String, ResetRequestSource.VirtualHost>> virtualHostMap
= new HashMap<String, Map<String, ResetRequestSource.VirtualHost>>();
for (String line: response.split("\r\n|\r|\n"))
{
if (line.startsWith("Node:"))
{
String[] entries = line.split(",");
+ String nodeId = this.parseId(entries[0]);
- String entry = entries[0];
- String nodeId = entry.substring(entry.indexOf('[') + 1,
entry.indexOf(']'));
-
// We can skip the first entry
for (int i = 1; i < entries.length; ++i)
{
- entry = entries[i];
+ String entry = entries[i];
int index = entry.indexOf(':');
- if (index >= 0)
+ if (index < 0)
{
- String key = entry.substring(0, index).trim();
- String value = entry.substring(index + 1).trim();
-
- if ("Name".equals(key))
- {
- nodeMap.put(nodeId, value);
- result.put(value, new EngineStatusImpl());
- break;
- }
+ throw new IllegalArgumentException(response);
}
+
+ String key = entry.substring(0, index).trim();
+ String value = entry.substring(index + 1).trim();
+
+ if ("Name".equals(key))
+ {
+ nodeMap.put(nodeId, value);
+ virtualHostMap.put(value, new HashMap<String,
ResetRequestSource.VirtualHost>());
+ break;
+ }
}
}
else if (line.startsWith("Vhost:"))
{
String[] entries = line.split(",");
+ String[] ids = this.parseId(entries[0]).split(":");
- String entry = entries[0];
- String ids = entry.substring(entry.indexOf('[') + 1,
entry.indexOf(']'));
- String nodeId = ids.substring(0, ids.indexOf(':'));
- String node = nodeMap.get(nodeId);
+ if (ids.length != 3)
+ {
+ throw new IllegalArgumentException(response);
+ }
+ String node = nodeMap.get(ids[0]);
+
if (node == null)
{
- throw new IllegalArgumentException();
+ throw new IllegalArgumentException(response);
}
- Set<String> aliases = result.get(node).getAliases();
+ Map<String, ResetRequestSource.VirtualHost> hostMap =
virtualHostMap.get(node);
+ String hostId = ids[1];
+
+ ResetRequestSource.VirtualHost host = hostMap.get(hostId);
+
+ if (host == null)
+ {
+ host = new VirtualHostImpl();
+ hostMap.put(hostId, host);
+ }
for (int i = 1; i < entries.length; ++i)
{
- entry = entries[i];
+ String entry = entries[i];
int index = entry.indexOf(':');
- if (index >= 0)
+ if (index < 0)
{
- String key = entry.substring(0, index).trim();
- String value = entry.substring(index + 1).trim();
-
- if ("Alias".equals(key))
- {
- aliases.add(value);
- break;
- }
+ throw new IllegalArgumentException(response);
}
+
+ String key = entry.substring(0, index).trim();
+ String value = entry.substring(index + 1).trim();
+
+ if ("Alias".equals(key))
+ {
+ host.getAliases().add(value);
+ break;
+ }
}
}
else if (line.startsWith("Context:"))
{
String[] entries = line.split(",");
+ String[] ids = this.parseId(entries[0]).split(":");
- String entry = entries[0];
- String ids = entry.substring(entry.indexOf('[') + 1,
entry.indexOf(']'));
- String nodeId = ids.substring(0, ids.indexOf(':'));
+ if (ids.length != 3)
+ {
+ throw new IllegalArgumentException(response);
+ }
+
+ String nodeId = ids[0];
String node = nodeMap.get(nodeId);
if (node == null)
{
- throw new IllegalArgumentException();
+ throw new IllegalArgumentException(response);
}
+ Map<String, ResetRequestSource.VirtualHost> hostMap =
virtualHostMap.get(node);
+ String hostId = ids[1];
+
+ ResetRequestSource.VirtualHost host = hostMap.get(hostId);
+
+ if (host == null)
+ {
+ throw new IllegalArgumentException(response);
+ }
+
String context = null;
ResetRequestSource.Status status = null;
for (int i = 1; i < entries.length; ++i)
{
- entry = entries[i];
+ String entry = entries[i];
int index = entry.indexOf(':');
- if (index >= 0)
+ if (index < 0)
{
- String key = entry.substring(0, index).trim();
- String value = entry.substring(index + 1).trim();
-
- if ("Context".equals(key))
- {
- context = value;
- }
- else if ("Status".equals(key))
- {
- status = ResetRequestSource.Status.valueOf(value);
- }
+ throw new IllegalArgumentException(response);
}
+
+ String key = entry.substring(0, index).trim();
+ String value = entry.substring(index + 1).trim();
+
+ if ("Context".equals(key))
+ {
+ context = value;
+ }
+ else if ("Status".equals(key))
+ {
+ status = ResetRequestSource.Status.valueOf(value);
+ }
}
- result.get(node).getContexts().put(context, status);
+ if ((context == null) || (status == null))
+ {
+ throw new IllegalArgumentException(response);
+ }
+
+ host.getContexts().put(context, status);
}
}
+ Map<String, Set<ResetRequestSource.VirtualHost>> result = new
HashMap<String, Set<ResetRequestSource.VirtualHost>>();
+
+ for (Map.Entry<String, Map<String, ResetRequestSource.VirtualHost>>
entry: virtualHostMap.entrySet())
+ {
+ result.put(entry.getKey(), new
HashSet<ResetRequestSource.VirtualHost>(entry.getValue().values()));
+ }
+
log.trace(result);
return result;
}
+
+ private String parseId(String entry)
+ {
+ int start = entry.indexOf('[') + 1;
+ int end = entry.indexOf(']');
+
+ if (start >= end)
+ {
+ throw new IllegalArgumentException(entry);
+ }
+
+ return entry.substring(start, end);
+ }
/**
* Send HTTP request, with the specified list of parameters. If an IO error occurs,
the error state will
@@ -1197,19 +1254,19 @@
}
}
- static class EngineStatusImpl implements ResetRequestSource.EngineStatus,
Externalizable
+ static class VirtualHostImpl implements ResetRequestSource.VirtualHost,
Externalizable
{
private final Set<String> aliases = new LinkedHashSet<String>();
private final Map<String, ResetRequestSource.Status> contexts = new
HashMap<String, ResetRequestSource.Status>();
- public EngineStatusImpl()
+ public VirtualHostImpl()
{
// Expose for deserialization
}
/**
* @{inheritDoc}
- * @see org.jboss.modcluster.mcmp.ResetRequestSource.EngineStatus#getAliases()
+ * @see org.jboss.modcluster.mcmp.ResetRequestSource.VirtualHost#getAliases()
*/
public Set<String> getAliases()
{
@@ -1218,7 +1275,7 @@
/**
* @{inheritDoc}
- * @see org.jboss.modcluster.mcmp.ResetRequestSource.EngineStatus#getContexts()
+ * @see org.jboss.modcluster.mcmp.ResetRequestSource.VirtualHost#getContexts()
*/
public Map<String, ResetRequestSource.Status> getContexts()
{
Added:
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
(rev 0)
+++
trunk/mod_cluster/src/main/java/org/jboss/modcluster/mcmp/impl/ResetRequestSourceImpl.java 2008-10-31
20:16:19 UTC (rev 2038)
@@ -0,0 +1,64 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2008, Red Hat Middleware LLC, and individual contributors
+ * as indicated by the @author tags. See the copyright.txt file in the
+ * distribution for a full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site:
http://www.fsf.org.
+ */
+package org.jboss.modcluster.mcmp.impl;
+
+import java.util.List;
+import java.util.Map;
+import java.util.Set;
+
+import org.apache.catalina.Server;
+import org.apache.catalina.ServerFactory;
+import org.jboss.modcluster.config.BalancerConfiguration;
+import org.jboss.modcluster.config.NodeConfiguration;
+import org.jboss.modcluster.mcmp.MCMPRequest;
+import org.jboss.modcluster.mcmp.MCMPUtils;
+import org.jboss.modcluster.mcmp.ResetRequestSource;
+
+/**
+ * @author Paul Ferraro
+ *
+ */
+public class ResetRequestSourceImpl implements ResetRequestSource
+{
+ private final NodeConfiguration nodeConfig;
+ private final BalancerConfiguration balancerConfig;
+
+ public ResetRequestSourceImpl(NodeConfiguration nodeConfig, BalancerConfiguration
balancerConfig)
+ {
+ this.nodeConfig = nodeConfig;
+ this.balancerConfig = balancerConfig;
+ }
+
+ /**
+ * @{inheritDoc}
+ * @see org.jboss.modcluster.mcmp.ResetRequestSource#getResetRequests(java.util.Map)
+ */
+ public List<MCMPRequest> getResetRequests(Map<String,
Set<VirtualHost>> response)
+ {
+ return this.getResetRequests(response, ServerFactory.getServer());
+ }
+
+ protected List<MCMPRequest> getResetRequests(Map<String,
Set<VirtualHost>> response, Server server)
+ {
+ return MCMPUtils.getResetRequests(response, server, this.nodeConfig,
this.balancerConfig);
+ }
+}