Author: pferraro
Date: 2008-10-24 10:37:04 -0400 (Fri, 24 Oct 2008)
New Revision: 1995
Modified:
trunk/mod_cluster/src/main/java/org/jboss/modcluster/mcmp/MCMPUtils.java
Log:
Send REMOVE-APP requests before CONFIG
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-23
15:34:18 UTC (rev 1994)
+++ trunk/mod_cluster/src/main/java/org/jboss/modcluster/mcmp/MCMPUtils.java 2008-10-24
14:37:04 UTC (rev 1995)
@@ -29,6 +29,7 @@
import java.util.HashMap;
import java.util.HashSet;
import java.util.Iterator;
+import java.util.LinkedList;
import java.util.List;
import java.util.Map;
import java.util.Set;
@@ -265,16 +266,14 @@
public static List<MCMPRequest> getResetRequests(Map<String,
ResetRequestSource.EngineStatus> response, Server server, NodeConfiguration nodeConfig,
BalancerConfiguration balancerConfig)
{
List<MCMPRequest> requests = new ArrayList<MCMPRequest>();
- Set<String> jvmRoutes = new HashSet<String>(response.keySet());
+ List<MCMPRequest> engineRequests = new LinkedList<MCMPRequest>();
for (Service service: server.findServices())
{
Engine engine = (Engine) service.getContainer();
String jvmRoute = engine.getJvmRoute();
- jvmRoutes.remove(jvmRoute);
-
- requests.add(createConfigRequest(jvmRoute, service.findConnectors(), nodeConfig,
balancerConfig));
+ engineRequests.add(createConfigRequest(jvmRoute, service.findConnectors(),
nodeConfig, balancerConfig));
ResetRequestSource.EngineStatus engineStatus = response.get(jvmRoute);
Map<String, ResetRequestSource.Status> contexts = Collections.emptyMap();
@@ -300,36 +299,46 @@
{
if (status != ResetRequestSource.Status.ENABLED)
{
- requests.add(createContextRequest(MCMPRequestType.ENABLE_APP,
jvmRoute, Utils.getAliases(context), path));
+ engineRequests.add(createContextRequest(MCMPRequestType.ENABLE_APP,
jvmRoute, Utils.getAliases(context), path));
}
}
else
{
if (status == ResetRequestSource.Status.ENABLED)
{
- requests.add(createContextRequest(MCMPRequestType.STOP_APP,
jvmRoute, Utils.getAliases(context), path));
+ engineRequests.add(createContextRequest(MCMPRequestType.STOP_APP,
jvmRoute, Utils.getAliases(context), path));
}
}
}
}
- // Send REMOVE-APP requests for contexts that don't exist
if (engineStatus != null)
{
- if (oldContexts.size() == contexts.size())
+ if (!contexts.isEmpty())
{
- requests.add(createEngineRequest(MCMPRequestType.REMOVE_APP, jvmRoute));
- }
- else
- {
- Set<String> aliases = engineStatus.getAliases();
-
- for (String context: contexts.keySet())
+ // If all old contexts no longer exist - remove all
+ if (oldContexts.size() == contexts.size())
{
- requests.add(createContextRequest(MCMPRequestType.REMOVE_APP, jvmRoute,
aliases, context));
+ // Send REMOVE-APP * request first
+ engineRequests.add(0, createEngineRequest(MCMPRequestType.REMOVE_APP,
jvmRoute));
}
+ // otherwise only remove those that no longer exist
+ else
+ {
+ Set<String> aliases = engineStatus.getAliases();
+
+ for (String context: contexts.keySet())
+ {
+ // Send REMOVE-APP requests first
+ engineRequests.add(0,
createContextRequest(MCMPRequestType.REMOVE_APP, jvmRoute, aliases, context));
+ }
+ }
}
}
+
+ requests.addAll(engineRequests);
+
+ engineRequests.clear();
}
return requests;