Author: pferraro
Date: 2008-10-30 16:37:13 -0400 (Thu, 30 Oct 2008)
New Revision: 2032
Modified:
trunk/mod_cluster/src/main/java/org/jboss/modcluster/LocalStrings.properties
trunk/mod_cluster/src/main/java/org/jboss/modcluster/mcmp/impl/DefaultMCMPHandler.java
Log:
Correctly associate vhost and context with correct node ids in parseResponse()
Modified: trunk/mod_cluster/src/main/java/org/jboss/modcluster/LocalStrings.properties
===================================================================
---
trunk/mod_cluster/src/main/java/org/jboss/modcluster/LocalStrings.properties 2008-10-30
18:11:53 UTC (rev 2031)
+++
trunk/mod_cluster/src/main/java/org/jboss/modcluster/LocalStrings.properties 2008-10-30
20:37:13 UTC (rev 2032)
@@ -6,7 +6,7 @@
modcluster.engine.config=Sending configuration for engine [{0}]
modcluster.engine.status=Check status for engine [{0}]
modcluster.engine.stop=Stop all web applications for engine [{0}]
-modcluster.request=Sending command [{0}] wildcard [{1}] to proxy [{2}]
+modcluster.request=Sending command [{0}] to proxy [{1}]
modcluster.singleton.ignorestop=Ignoring call to stopOldMaster for domain [{0}] as we are
in domain [{1}]
modcluster.util.address=Detected local address [{0}]
modcluster.util.jvmRoute=Engine [{0}] will use jvmRoute [{1}]
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-30
18:11:53 UTC (rev 2031)
+++
trunk/mod_cluster/src/main/java/org/jboss/modcluster/mcmp/impl/DefaultMCMPHandler.java 2008-10-30
20:37:13 UTC (rev 2032)
@@ -481,8 +481,9 @@
log.trace(response);
+ // 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>();
- ResetRequestSource.EngineStatus engineStatus = null;
for (String line: response.split("\r\n|\r|\n"))
{
@@ -490,19 +491,24 @@
{
String[] entries = line.split(",");
+ 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)
{
- String entry = entries[i];
+ entry = entries[i];
int index = entry.indexOf(':');
if (index >= 0)
{
String key = entry.substring(0, index).trim();
+ String value = entry.substring(index + 1).trim();
if ("Name".equals(key))
{
- engineStatus = new EngineStatusImpl();
- result.put(entry.substring(index + 1).trim(), engineStatus);
+ nodeMap.put(nodeId, value);
+ result.put(value, new EngineStatusImpl());
break;
}
}
@@ -510,22 +516,33 @@
}
else if (line.startsWith("Vhost:"))
{
- if (engineStatus == null) throw new IllegalStateException();
-
String[] entries = line.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 (node == null)
+ {
+ throw new IllegalArgumentException();
+ }
+
+ Set<String> aliases = result.get(node).getAliases();
+
for (int i = 1; i < entries.length; ++i)
{
- String entry = entries[i];
+ entry = entries[i];
int index = entry.indexOf(':');
if (index >= 0)
{
String key = entry.substring(0, index).trim();
+ String value = entry.substring(index + 1).trim();
if ("Alias".equals(key))
{
- engineStatus.getAliases().add(entry.substring(index + 1).trim());
+ aliases.add(value);
break;
}
}
@@ -533,15 +550,24 @@
}
else if (line.startsWith("Context:"))
{
- if (engineStatus == null) throw new IllegalStateException();
+ String[] entries = line.split(",");
- String[] entries = line.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 (node == null)
+ {
+ throw new IllegalArgumentException();
+ }
+
String context = null;
ResetRequestSource.Status status = null;
for (int i = 1; i < entries.length; ++i)
{
- String entry = entries[i];
+ entry = entries[i];
int index = entry.indexOf(':');
if (index >= 0)
@@ -560,7 +586,7 @@
}
}
- engineStatus.getContexts().put(context, status);
+ result.get(node).getContexts().put(context, status);
}
}
@@ -664,6 +690,11 @@
// will be refreshed
if (proxy.getState() != Proxy.State.OK) return null;
+ if (log.isTraceEnabled())
+ {
+ log.trace(this.sm.getString("modcluster.request", request, proxy));
+ }
+
String command = request.getRequestType().getCommand();
boolean wildcard = request.isWildcard();
String jvmRoute = request.getJvmRoute();
@@ -694,11 +725,6 @@
throw new IllegalArgumentException(e);
}
- if (log.isTraceEnabled())
- {
- log.trace(this.sm.getString("modcluster.request", command,
Boolean.valueOf(wildcard), proxy));
- }
-
// Require exclusive access to proxy socket
synchronized (proxy)
{
Show replies by date