Author: pferraro
Date: 2008-10-02 12:27:48 -0400 (Thu, 02 Oct 2008)
New Revision: 1926
Modified:
trunk/mod_cluster/src/main/java/org/jboss/modcluster/mcmp/MCMPRequest.java
trunk/mod_cluster/src/main/java/org/jboss/modcluster/mcmp/MCMPUtils.java
trunk/mod_cluster/src/main/java/org/jboss/modcluster/mcmp/impl/DefaultMCMPHandler.java
trunk/mod_cluster/src/test/java/org/jboss/modcluster/ClusterListenerTestCase.java
trunk/mod_cluster/src/test/java/org/jboss/modcluster/DefaultJBossWebEventHandlerTestCase.java
trunk/mod_cluster/src/test/java/org/jboss/modcluster/ModClusterServiceTestCase.java
trunk/mod_cluster/src/test/java/org/jboss/modcluster/ha/ClusteredMCMPHandlerTestCase.java
trunk/mod_cluster/src/test/java/org/jboss/modcluster/ha/HASingletonAwareResetRequestSourceTestCase.java
Log:
Expose JVMRoute from MCMPRequest. Adjust message creation accordingly.
Modified: trunk/mod_cluster/src/main/java/org/jboss/modcluster/mcmp/MCMPRequest.java
===================================================================
--- trunk/mod_cluster/src/main/java/org/jboss/modcluster/mcmp/MCMPRequest.java 2008-10-02
15:31:06 UTC (rev 1925)
+++ trunk/mod_cluster/src/main/java/org/jboss/modcluster/mcmp/MCMPRequest.java 2008-10-02
16:27:48 UTC (rev 1926)
@@ -24,7 +24,6 @@
import java.io.Serializable;
import java.util.Collections;
-import java.util.HashMap;
import java.util.Map;
import net.jcip.annotations.Immutable;
@@ -44,15 +43,17 @@
private final MCMPRequestType requestType;
private final boolean wildcard;
private final Map<String, String> parameters;
+ private final String jvmRoute;
/**
* Create a new ModClusterRequest.
*/
- public MCMPRequest(MCMPRequestType requestType, boolean wildcard, Map<String,
String> parameters)
+ public MCMPRequest(MCMPRequestType requestType, boolean wildcard, String jvmRoute,
Map<String, String> parameters)
{
this.requestType = requestType;
this.wildcard = wildcard;
- this.parameters = Collections.unmodifiableMap(new HashMap<String,
String>(parameters));
+ this.jvmRoute = jvmRoute;
+ this.parameters = Collections.unmodifiableMap(parameters);
}
public MCMPRequestType getRequestType()
@@ -65,6 +66,11 @@
return this.wildcard;
}
+ public String getJvmRoute()
+ {
+ return this.jvmRoute;
+ }
+
public Map<String, String> getParameters()
{
return this.parameters;
@@ -74,12 +80,10 @@
public String toString()
{
StringBuilder sb = new StringBuilder(getClass().getName());
- sb.append("{requestType=");
- sb.append(this.requestType);
- sb.append(",wildcard=");
- sb.append(this.wildcard);
- sb.append(",parameters=");
- sb.append(this.parameters);
+ sb.append("{requestType=").append(this.requestType);
+ sb.append(",wildcard=").append(this.wildcard);
+ sb.append(",jvmRoute=").append(this.jvmRoute);
+ sb.append(",parameters=").append(this.parameters);
sb.append("}");
return sb.toString();
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-02
15:31:06 UTC (rev 1925)
+++ trunk/mod_cluster/src/main/java/org/jboss/modcluster/mcmp/MCMPUtils.java 2008-10-02
16:27:48 UTC (rev 1926)
@@ -55,7 +55,9 @@
{
public static final int DEFAULT_PORT = 8000;
- private static final MCMPRequest INFO = new MCMPRequest(MCMPRequestType.INFO, false,
new HashMap<String, String>());
+ private static final Map<String, String> EMPTY_MAP = Collections.emptyMap();
+ public static final MCMPRequest INFO_REQUEST = new MCMPRequest(MCMPRequestType.INFO,
false, null, EMPTY_MAP);
+ public static final MCMPRequest DUMP_REQUEST = new MCMPRequest(MCMPRequestType.DUMP,
true, null, EMPTY_MAP);
private static final Logger log = Logger.getLogger(MCMPUtils.class);
@@ -68,7 +70,6 @@
{
Connector connector =
Utils.findProxyConnector(engine.getService().findConnectors());
Map<String, String> parameters = new HashMap<String, String>();
- parameters.put("JVMRoute", engine.getJvmRoute());
ProtocolHandler handler = connector.getProtocolHandler();
@@ -166,7 +167,7 @@
parameters.put("Maxattempts", "" + maxAttempts);
}
- return new MCMPRequest(MCMPRequestType.CONFIG, false, parameters);
+ return new MCMPRequest(MCMPRequestType.CONFIG, false, engine.getJvmRoute(),
parameters);
}
public static MCMPRequest createEnableAppRequest(Context context)
@@ -192,14 +193,13 @@
private static MCMPRequest createRequest(MCMPRequestType type, Context context)
{
Map<String, String> parameters = new HashMap<String, String>();
- parameters.put("JVMRoute", Utils.getJvmRoute(context));
String path = context.getPath();
parameters.put("Context", "".equals(path) ? "/" :
path);
parameters.put("Alias", Utils.getHost(context));
- return new MCMPRequest(type, false, parameters);
+ return new MCMPRequest(type, false, Utils.getJvmRoute(context), parameters);
}
public static MCMPRequest createStatusRequest(Engine engine, int lbf)
@@ -209,10 +209,7 @@
public static MCMPRequest createStatusRequest(String jvmRoute, int lbf)
{
- Map<String, String> parameters = new HashMap<String, String>();
- parameters.put("JVMRoute", jvmRoute);
- parameters.put("Load", String.valueOf(lbf));
- return new MCMPRequest(MCMPRequestType.STATUS, false, parameters);
+ return new MCMPRequest(MCMPRequestType.STATUS, false, jvmRoute,
Collections.singletonMap("Load", String.valueOf(lbf)));
}
public static MCMPRequest createEnableEngineRequest(Engine engine)
@@ -232,7 +229,7 @@
private static MCMPRequest createRequest(MCMPRequestType type, Engine engine)
{
- return new MCMPRequest(type, true, Collections.singletonMap("JVMRoute",
engine.getJvmRoute()));
+ return new MCMPRequest(type, true, engine.getJvmRoute(), EMPTY_MAP);
}
/**
@@ -268,11 +265,6 @@
return requests;
}
- public static MCMPRequest getInfoRequest()
- {
- return INFO;
- }
-
public static AddressPort parseAddressPort(String addressPort)
{
try
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-02
15:31:06 UTC (rev 1925)
+++
trunk/mod_cluster/src/main/java/org/jboss/modcluster/mcmp/impl/DefaultMCMPHandler.java 2008-10-02
16:27:48 UTC (rev 1926)
@@ -33,7 +33,6 @@
import java.net.Socket;
import java.util.ArrayList;
import java.util.Collections;
-import java.util.HashMap;
import java.util.Iterator;
import java.util.LinkedHashSet;
import java.util.List;
@@ -60,7 +59,6 @@
import org.jboss.modcluster.mcmp.AddressPort;
import org.jboss.modcluster.mcmp.MCMPHandler;
import org.jboss.modcluster.mcmp.MCMPRequest;
-import org.jboss.modcluster.mcmp.MCMPRequestType;
import org.jboss.modcluster.mcmp.MCMPServerState;
import org.jboss.modcluster.mcmp.MCMPUtils;
import org.jboss.modcluster.mcmp.ResetRequestSource;
@@ -319,39 +317,23 @@
*/
public String getProxyConfiguration()
{
- Map<String, String> parameters = new HashMap<String, String>();
// Send DUMP * request
- StringBuilder result = new StringBuilder();
-
- Lock lock = this.proxiesLock.readLock();
- lock.lock();
-
- try
- {
- for (int i = 0; i < this.proxies.size(); ++i)
- {
- Proxy proxy = this.proxies.get(i);
- result.append("Proxy[").append(i).append("]:
[").append(proxy.getAddress()).append(':').append(proxy.getPort()).append("]:
\r\n");
- result.append(this.sendRequest(new MCMPRequest(MCMPRequestType.DUMP, true,
parameters), proxy)).append("\r\n");
- }
- }
- finally
- {
- lock.unlock();
- }
- return result.toString();
+ return this.getProxyMessage(MCMPUtils.DUMP_REQUEST);
}
/**
* Retrieves the full proxy info message.
*
- *
* @return the proxy info confguration
*/
public String getProxyInfo()
{
- Map<String, String> parameters = new HashMap<String, String>();
// Send INFO * request
+ return this.getProxyMessage(MCMPUtils.INFO_REQUEST);
+ }
+
+ private String getProxyMessage(MCMPRequest request)
+ {
StringBuilder result = new StringBuilder();
Lock lock = this.proxiesLock.readLock();
@@ -363,7 +345,7 @@
{
Proxy proxy = this.proxies.get(i);
result.append("Proxy[").append(i).append("]:
[").append(proxy.getAddress()).append(':').append(proxy.getPort()).append("]:
\r\n");
- result.append(this.sendRequest(new MCMPRequest(MCMPRequestType.INFO, true,
parameters), proxy)).append("\r\n");
+ result.append(this.sendRequest(request, proxy)).append("\r\n");
}
}
finally
@@ -467,7 +449,7 @@
{
proxy.setState(Proxy.State.OK);
- this.sendRequest(MCMPUtils.getInfoRequest(), proxy);
+ this.sendRequest(MCMPUtils.INFO_REQUEST, proxy);
if (proxy.getState() == Proxy.State.OK)
{
@@ -594,6 +576,7 @@
String command = request.getRequestType().getCommand();
boolean wildcard = request.isWildcard();
+ String jvmRoute = request.getJvmRoute();
Map<String, String> parameters = request.getParameters();
UEncoder encoder = new UEncoder();
@@ -605,27 +588,18 @@
body = encoder.encodeURL("", 0, 0);
body.recycle();
+ if (jvmRoute != null)
+ {
+ body = this.encodeParameter(encoder, "JVMRoute", jvmRoute,
!parameters.isEmpty());
+ }
+
Iterator<Map.Entry<String, String>> entries =
parameters.entrySet().iterator();
while (entries.hasNext())
{
Map.Entry<String, String> entry = entries.next();
- String key = entry.getKey();
- String value = entry.getValue();
-
- if (value == null)
- {
- throw new
IllegalArgumentException(this.sm.getString("modcluster.error.nullAttribute",
key));
- }
- body = encoder.encodeURL(key, 0, key.length());
- body.append('=');
- body = encoder.encodeURL(value, 0, value.length());
-
- if (entries.hasNext())
- {
- body.append('&');
- }
+ body = this.encodeParameter(encoder, entry.getKey(), entry.getValue(),
entries.hasNext());
}
}
catch (IOException e)
@@ -813,6 +787,25 @@
return null;
}
+ private CharChunk encodeParameter(UEncoder encoder, String key, String value, boolean
hasNext) throws IOException
+ {
+ if (value == null)
+ {
+ throw new
IllegalArgumentException(this.sm.getString("modcluster.error.nullAttribute",
key));
+ }
+
+ encoder.encodeURL(key, 0, key.length()).append('=');
+
+ CharChunk body = encoder.encodeURL(value, 0, value.length());
+
+ if (hasNext)
+ {
+ body.append('&');
+ }
+
+ return body;
+ }
+
/**
* This class represents a front-end httpd server.
*/
Modified:
trunk/mod_cluster/src/test/java/org/jboss/modcluster/ClusterListenerTestCase.java
===================================================================
---
trunk/mod_cluster/src/test/java/org/jboss/modcluster/ClusterListenerTestCase.java 2008-10-02
15:31:06 UTC (rev 1925)
+++
trunk/mod_cluster/src/test/java/org/jboss/modcluster/ClusterListenerTestCase.java 2008-10-02
16:27:48 UTC (rev 1926)
@@ -105,13 +105,13 @@
EasyMock.expect(context.isStarted()).andReturn(true);
// create enable-app request
- EasyMock.expect(context.getParent()).andReturn(container);
- EasyMock.expect(container.getParent()).andReturn(engine);
- EasyMock.expect(engine.getJvmRoute()).andReturn("host1");
EasyMock.expect(context.getPath()).andReturn("/context");
EasyMock.expect(context.getParent()).andReturn(host);
EasyMock.expect(host.getName()).andReturn("host");
EasyMock.expect(host.findAliases()).andReturn(new String[] { "alias1",
"alias2" });
+ EasyMock.expect(context.getParent()).andReturn(container);
+ EasyMock.expect(container.getParent()).andReturn(engine);
+ EasyMock.expect(engine.getJvmRoute()).andReturn("host1");
EasyMock.replay(server, service, engine, container, context, host);
@@ -124,16 +124,15 @@
assertSame(MCMPRequestType.REMOVE_APP, request.getRequestType());
assertTrue(request.isWildcard());
- assertEquals(1, parameters.size());
- assertEquals("host1", parameters.get("JVMRoute"));
+ assertEquals("host1", request.getJvmRoute());
request = requests.get(1);
parameters = request.getParameters();
assertSame(MCMPRequestType.CONFIG, request.getRequestType());
assertFalse(request.isWildcard());
- assertEquals(17, parameters.size());
- assertEquals("host1", parameters.get("JVMRoute"));
+ assertEquals("host1", request.getJvmRoute());
+ assertEquals(16, parameters.size());
assertEquals("127.0.0.1", parameters.get("Host"));
assertEquals("0", parameters.get("Port"));
assertEquals("ajp", parameters.get("Type"));
@@ -156,8 +155,8 @@
assertSame(MCMPRequestType.ENABLE_APP, request.getRequestType());
assertFalse(request.isWildcard());
- assertEquals(3, parameters.size());
- assertEquals("host1", parameters.get("JVMRoute"));
+ assertEquals("host1", request.getJvmRoute());
+ assertEquals(2, parameters.size());
assertEquals("/context", parameters.get("Context"));
assertEquals("host,alias1,alias2", parameters.get("Alias"));
@@ -225,12 +224,11 @@
assertTrue(result);
MCMPRequest request = capturedRequest.getValue();
- Map<String, String> parameters = request.getParameters();
assertSame(MCMPRequestType.ENABLE_APP, request.getRequestType());
assertTrue(request.isWildcard());
- assertEquals(1, parameters.size());
- assertEquals("host1", parameters.get("JVMRoute"));
+ assertEquals("host1", request.getJvmRoute());
+ assertTrue(request.getParameters().isEmpty());
EasyMock.reset(this.mcmpHandler, server, service, engine);
}
@@ -257,12 +255,11 @@
assertTrue(result);
MCMPRequest request = capturedRequest.getValue();
- Map<String, String> parameters = request.getParameters();
assertSame(MCMPRequestType.DISABLE_APP, request.getRequestType());
assertTrue(request.isWildcard());
- assertEquals(1, parameters.size());
- assertEquals("host1", parameters.get("JVMRoute"));
+ assertEquals("host1", request.getJvmRoute());
+ assertTrue(request.getParameters().isEmpty());
EasyMock.reset(this.mcmpHandler, server, service, engine);
}
Modified:
trunk/mod_cluster/src/test/java/org/jboss/modcluster/DefaultJBossWebEventHandlerTestCase.java
===================================================================
---
trunk/mod_cluster/src/test/java/org/jboss/modcluster/DefaultJBossWebEventHandlerTestCase.java 2008-10-02
15:31:06 UTC (rev 1925)
+++
trunk/mod_cluster/src/test/java/org/jboss/modcluster/DefaultJBossWebEventHandlerTestCase.java 2008-10-02
16:27:48 UTC (rev 1926)
@@ -246,13 +246,13 @@
EasyMock.expect(context.isStarted()).andReturn(true);
// Building request
- EasyMock.expect(context.getParent()).andReturn(container);
- EasyMock.expect(container.getParent()).andReturn(engine);
- EasyMock.expect(engine.getJvmRoute()).andReturn("host1");
EasyMock.expect(context.getPath()).andReturn("/context");
EasyMock.expect(context.getParent()).andReturn(host);
EasyMock.expect(host.getName()).andReturn("host");
EasyMock.expect(host.findAliases()).andReturn(new String[] { "alias1",
"alias2" });
+ EasyMock.expect(context.getParent()).andReturn(container);
+ EasyMock.expect(container.getParent()).andReturn(engine);
+ EasyMock.expect(engine.getJvmRoute()).andReturn("host1");
this.mcmpHandler.sendRequest(EasyMock.capture(capturedRequest));
@@ -266,12 +266,12 @@
assertSame(MCMPRequestType.ENABLE_APP, request.getRequestType());
assertFalse(request.isWildcard());
+ assertEquals("host1", request.getJvmRoute());
Map<String, String> parameters = request.getParameters();
- assertEquals(3, parameters.size());
+ assertEquals(2, parameters.size());
- assertEquals("host1", parameters.get("JVMRoute"));
assertEquals("/context", parameters.get("Context"));
assertEquals("host,alias1,alias2", parameters.get("Alias"));
@@ -318,13 +318,13 @@
EasyMock.expect(container.getName()).andReturn("parent-container");
// Building request
- EasyMock.expect(context.getParent()).andReturn(container);
- EasyMock.expect(container.getParent()).andReturn(engine);
- EasyMock.expect(engine.getJvmRoute()).andReturn("host1");
EasyMock.expect(context.getPath()).andReturn("/context");
EasyMock.expect(context.getParent()).andReturn(host);
EasyMock.expect(host.getName()).andReturn("host");
EasyMock.expect(host.findAliases()).andReturn(new String[] { "alias1",
"alias2" });
+ EasyMock.expect(context.getParent()).andReturn(container);
+ EasyMock.expect(container.getParent()).andReturn(engine);
+ EasyMock.expect(engine.getJvmRoute()).andReturn("host1");
this.mcmpHandler.sendRequest(EasyMock.capture(capturedRequest));
@@ -338,12 +338,12 @@
assertSame(MCMPRequestType.ENABLE_APP, request.getRequestType());
assertFalse(request.isWildcard());
+ assertEquals("host1", request.getJvmRoute());
Map<String, String> parameters = request.getParameters();
- assertEquals(3, parameters.size());
+ assertEquals(2, parameters.size());
- assertEquals("host1", parameters.get("JVMRoute"));
assertEquals("/context", parameters.get("Context"));
assertEquals("host,alias1,alias2", parameters.get("Alias"));
@@ -380,13 +380,13 @@
EasyMock.expect(container.getName()).andReturn("parent-container");
// Building request
- EasyMock.expect(context.getParent()).andReturn(container);
- EasyMock.expect(container.getParent()).andReturn(engine);
- EasyMock.expect(engine.getJvmRoute()).andReturn("host1");
EasyMock.expect(context.getPath()).andReturn("/context");
EasyMock.expect(context.getParent()).andReturn(host);
EasyMock.expect(host.getName()).andReturn("host");
EasyMock.expect(host.findAliases()).andReturn(new String[] { "alias1",
"alias2" });
+ EasyMock.expect(context.getParent()).andReturn(container);
+ EasyMock.expect(container.getParent()).andReturn(engine);
+ EasyMock.expect(engine.getJvmRoute()).andReturn("host1");
this.mcmpHandler.sendRequest(EasyMock.capture(capturedRequest));
@@ -400,12 +400,12 @@
assertSame(MCMPRequestType.STOP_APP, request.getRequestType());
assertFalse(request.isWildcard());
+ assertEquals("host1", request.getJvmRoute());
Map<String, String> parameters = request.getParameters();
- assertEquals(3, parameters.size());
+ assertEquals(2, parameters.size());
- assertEquals("host1", parameters.get("JVMRoute"));
assertEquals("/context", parameters.get("Context"));
assertEquals("host,alias1,alias2", parameters.get("Alias"));
@@ -458,13 +458,13 @@
EasyMock.expect(engine.getJvmRoute()).andReturn("host1");
// Building request
- EasyMock.expect(context.getParent()).andReturn(container);
- EasyMock.expect(container.getParent()).andReturn(engine);
- EasyMock.expect(engine.getJvmRoute()).andReturn("host1");
EasyMock.expect(context.getPath()).andReturn("/context");
EasyMock.expect(context.getParent()).andReturn(host);
EasyMock.expect(host.getName()).andReturn("host");
EasyMock.expect(host.findAliases()).andReturn(new String[] { "alias1",
"alias2" });
+ EasyMock.expect(context.getParent()).andReturn(container);
+ EasyMock.expect(container.getParent()).andReturn(engine);
+ EasyMock.expect(engine.getJvmRoute()).andReturn("host1");
this.mcmpHandler.sendRequest(EasyMock.capture(capturedRequest));
@@ -478,12 +478,12 @@
assertSame(MCMPRequestType.REMOVE_APP, request.getRequestType());
assertFalse(request.isWildcard());
+ assertEquals("host1", request.getJvmRoute());
Map<String, String> parameters = request.getParameters();
- assertEquals(3, parameters.size());
+ assertEquals(2, parameters.size());
- assertEquals("host1", parameters.get("JVMRoute"));
assertEquals("/context", parameters.get("Context"));
assertEquals("host,alias1,alias2", parameters.get("Alias"));
@@ -543,11 +543,11 @@
assertSame(MCMPRequestType.STATUS, request.getRequestType());
assertFalse(request.isWildcard());
+ assertEquals("host1", request.getJvmRoute());
Map<String, String> parameters = request.getParameters();
- assertEquals(2, parameters.size());
- assertEquals("host1", parameters.get("JVMRoute"));
+ assertEquals(1, parameters.size());
assertEquals("10", parameters.get("Load"));
EasyMock.reset(this.mcmpHandler, this.provider, engine);
@@ -627,11 +627,11 @@
assertSame(MCMPRequestType.CONFIG, request.getRequestType());
assertFalse(request.isWildcard());
+ assertEquals("host1", request.getJvmRoute());
Map<String, String> parameters = request.getParameters();
- assertEquals(17, parameters.size());
- assertEquals("host1", parameters.get("JVMRoute"));
+ assertEquals(16, parameters.size());
assertEquals("127.0.0.1", parameters.get("Host"));
assertEquals("0", parameters.get("Port"));
assertEquals("ajp", parameters.get("Type"));
@@ -701,7 +701,8 @@
assertSame(MCMPRequestType.REMOVE_APP, request.getRequestType());
assertTrue(request.isWildcard());
- assertEquals(Collections.singletonMap("JVMRoute", "host1"),
request.getParameters());
+ assertEquals("host1", request.getJvmRoute());
+ assertTrue(request.getParameters().isEmpty());
EasyMock.reset(this.mcmpHandler, this.nodeConfig, this.balancerConfig, server,
service, engine, container, context);
}
Modified:
trunk/mod_cluster/src/test/java/org/jboss/modcluster/ModClusterServiceTestCase.java
===================================================================
---
trunk/mod_cluster/src/test/java/org/jboss/modcluster/ModClusterServiceTestCase.java 2008-10-02
15:31:06 UTC (rev 1925)
+++
trunk/mod_cluster/src/test/java/org/jboss/modcluster/ModClusterServiceTestCase.java 2008-10-02
16:27:48 UTC (rev 1926)
@@ -30,7 +30,6 @@
import java.util.List;
import java.util.Map;
import java.util.Set;
-import java.util.TreeMap;
import java.util.TreeSet;
import junit.framework.TestCase;
@@ -303,11 +302,10 @@
assertSame(MCMPRequestType.CONFIG, request.getRequestType());
assertFalse(request.isWildcard());
-
+ assertEquals("host1", request.getJvmRoute());
Map<String, String> parameters = request.getParameters();
- assertEquals(17, parameters.size());
- assertEquals("host1", parameters.get("JVMRoute"));
+ assertEquals(16, parameters.size());
assertEquals("127.0.0.1", parameters.get("Host"));
assertEquals("0", parameters.get("Port"));
assertEquals("ajp", parameters.get("Type"));
@@ -398,7 +396,8 @@
assertSame(MCMPRequestType.REMOVE_APP, request.getRequestType());
assertTrue(request.isWildcard());
- assertEquals(Collections.singletonMap("JVMRoute", "host1"),
request.getParameters());
+ assertEquals("host1", request.getJvmRoute());
+ assertTrue(request.getParameters().isEmpty());
assertTrue(this.modClusterService.drmEntry.getJvmRoutes().isEmpty());
@@ -460,13 +459,13 @@
EasyMock.expect(context.isStarted()).andReturn(true);
// Building request
- EasyMock.expect(context.getParent()).andReturn(container);
- EasyMock.expect(container.getParent()).andReturn(engine);
- EasyMock.expect(engine.getJvmRoute()).andReturn("host1");
EasyMock.expect(context.getPath()).andReturn("/context");
EasyMock.expect(context.getParent()).andReturn(host);
EasyMock.expect(host.getName()).andReturn("host");
EasyMock.expect(host.findAliases()).andReturn(new String[] { "alias1",
"alias2" });
+ EasyMock.expect(context.getParent()).andReturn(container);
+ EasyMock.expect(container.getParent()).andReturn(engine);
+ EasyMock.expect(engine.getJvmRoute()).andReturn("host1");
this.clusteredMCMPHandler.sendRequest(EasyMock.capture(capturedRequest));
@@ -480,12 +479,12 @@
assertSame(MCMPRequestType.ENABLE_APP, request.getRequestType());
assertFalse(request.isWildcard());
+ assertEquals("host1", request.getJvmRoute());
Map<String, String> parameters = request.getParameters();
- assertEquals(3, parameters.size());
+ assertEquals(2, parameters.size());
- assertEquals("host1", parameters.get("JVMRoute"));
assertEquals("/context", parameters.get("Context"));
assertEquals("host,alias1,alias2", parameters.get("Alias"));
@@ -522,13 +521,13 @@
EasyMock.expect(container.getName()).andReturn("parent-container");
// Building request
- EasyMock.expect(context.getParent()).andReturn(container);
- EasyMock.expect(container.getParent()).andReturn(engine);
- EasyMock.expect(engine.getJvmRoute()).andReturn("host1");
EasyMock.expect(context.getPath()).andReturn("/context");
EasyMock.expect(context.getParent()).andReturn(host);
EasyMock.expect(host.getName()).andReturn("host");
EasyMock.expect(host.findAliases()).andReturn(new String[] { "alias1",
"alias2" });
+ EasyMock.expect(context.getParent()).andReturn(container);
+ EasyMock.expect(container.getParent()).andReturn(engine);
+ EasyMock.expect(engine.getJvmRoute()).andReturn("host1");
this.clusteredMCMPHandler.sendRequest(EasyMock.capture(capturedRequest));
@@ -542,12 +541,12 @@
assertSame(MCMPRequestType.ENABLE_APP, request.getRequestType());
assertFalse(request.isWildcard());
+ assertEquals("host1", request.getJvmRoute());
Map<String, String> parameters = request.getParameters();
- assertEquals(3, parameters.size());
+ assertEquals(2, parameters.size());
- assertEquals("host1", parameters.get("JVMRoute"));
assertEquals("/context", parameters.get("Context"));
assertEquals("host,alias1,alias2", parameters.get("Alias"));
@@ -584,13 +583,13 @@
EasyMock.expect(container.getName()).andReturn("parent-container");
// Building request
- EasyMock.expect(context.getParent()).andReturn(container);
- EasyMock.expect(container.getParent()).andReturn(engine);
- EasyMock.expect(engine.getJvmRoute()).andReturn("host1");
EasyMock.expect(context.getPath()).andReturn("/context");
EasyMock.expect(context.getParent()).andReturn(host);
EasyMock.expect(host.getName()).andReturn("host");
EasyMock.expect(host.findAliases()).andReturn(new String[] { "alias1",
"alias2" });
+ EasyMock.expect(context.getParent()).andReturn(container);
+ EasyMock.expect(container.getParent()).andReturn(engine);
+ EasyMock.expect(engine.getJvmRoute()).andReturn("host1");
this.clusteredMCMPHandler.sendRequest(EasyMock.capture(capturedRequest));
@@ -604,12 +603,12 @@
assertSame(MCMPRequestType.STOP_APP, request.getRequestType());
assertFalse(request.isWildcard());
+ assertEquals("host1", request.getJvmRoute());
Map<String, String> parameters = request.getParameters();
- assertEquals(3, parameters.size());
+ assertEquals(2, parameters.size());
- assertEquals("host1", parameters.get("JVMRoute"));
assertEquals("/context", parameters.get("Context"));
assertEquals("host,alias1,alias2", parameters.get("Alias"));
@@ -662,13 +661,13 @@
EasyMock.expect(engine.getJvmRoute()).andReturn("host1");
// Building request
- EasyMock.expect(context.getParent()).andReturn(container);
- EasyMock.expect(container.getParent()).andReturn(engine);
- EasyMock.expect(engine.getJvmRoute()).andReturn("host1");
EasyMock.expect(context.getPath()).andReturn("/context");
EasyMock.expect(context.getParent()).andReturn(host);
EasyMock.expect(host.getName()).andReturn("host");
EasyMock.expect(host.findAliases()).andReturn(new String[] { "alias1",
"alias2" });
+ EasyMock.expect(context.getParent()).andReturn(container);
+ EasyMock.expect(container.getParent()).andReturn(engine);
+ EasyMock.expect(engine.getJvmRoute()).andReturn("host1");
this.clusteredMCMPHandler.sendRequest(EasyMock.capture(capturedRequest));
@@ -682,12 +681,12 @@
assertSame(MCMPRequestType.REMOVE_APP, request.getRequestType());
assertFalse(request.isWildcard());
+ assertEquals("host1", request.getJvmRoute());
Map<String, String> parameters = request.getParameters();
- assertEquals(3, parameters.size());
+ assertEquals(2, parameters.size());
- assertEquals("host1", parameters.get("JVMRoute"));
assertEquals("/context", parameters.get("Context"));
assertEquals("host,alias1,alias2", parameters.get("Alias"));
@@ -769,8 +768,9 @@
MCMPServerDiscoveryEvent event1 = new MCMPServerDiscoveryEvent(remoteNode1, new
AddressPort(address1, 1), true, 1);
MCMPServerDiscoveryEvent event2 = new MCMPServerDiscoveryEvent(remoteNode2, new
AddressPort(address2, 2), false, 2);
- MCMPRequest request1 = new MCMPRequest(MCMPRequestType.ENABLE_APP, false, new
TreeMap<String, String>());
- MCMPRequest request2 = new MCMPRequest(MCMPRequestType.DISABLE_APP, false, new
TreeMap<String, String>());
+ Map<String, String> emptyMap = Collections.emptyMap();
+ MCMPRequest request1 = new MCMPRequest(MCMPRequestType.ENABLE_APP, false,
"route", emptyMap);
+ MCMPRequest request2 = new MCMPRequest(MCMPRequestType.DISABLE_APP, false,
"route", emptyMap);
Capture<List<MCMPRequest>> capturedRequests = new
Capture<List<MCMPRequest>>();
Capture<ModClusterServiceDRMEntry> capturedEntry = new
Capture<ModClusterServiceDRMEntry>();
Capture<Object[]> capturedArgs = new Capture<Object[]>();
@@ -844,14 +844,14 @@
assertSame(MCMPRequestType.STATUS, requests.get(0).getRequestType());
assertFalse(requests.get(0).isWildcard());
- assertEquals(2, requests.get(0).getParameters().size());
- assertEquals("host2",
requests.get(0).getParameters().get("JVMRoute"));
+ assertEquals("host2", requests.get(0).getJvmRoute());
+ assertEquals(1, requests.get(0).getParameters().size());
assertEquals("20",
requests.get(0).getParameters().get("Load"));
assertSame(MCMPRequestType.STATUS, requests.get(1).getRequestType());
assertFalse(requests.get(1).isWildcard());
- assertEquals(2, requests.get(1).getParameters().size());
- assertEquals("host1",
requests.get(1).getParameters().get("JVMRoute"));
+ assertEquals("host1", requests.get(1).getJvmRoute());
+ assertEquals(1, requests.get(1).getParameters().size());
assertEquals("10",
requests.get(1).getParameters().get("Load"));
ModClusterServiceDRMEntry entry = capturedEntry.getValue();
Modified:
trunk/mod_cluster/src/test/java/org/jboss/modcluster/ha/ClusteredMCMPHandlerTestCase.java
===================================================================
---
trunk/mod_cluster/src/test/java/org/jboss/modcluster/ha/ClusteredMCMPHandlerTestCase.java 2008-10-02
15:31:06 UTC (rev 1925)
+++
trunk/mod_cluster/src/test/java/org/jboss/modcluster/ha/ClusteredMCMPHandlerTestCase.java 2008-10-02
16:27:48 UTC (rev 1926)
@@ -665,7 +665,7 @@
public void testSendRequest() throws Exception
{
- MCMPRequest request = new MCMPRequest(MCMPRequestType.INFO, false,
Collections.singletonMap("name", "value"));
+ MCMPRequest request = new MCMPRequest(MCMPRequestType.INFO, false,
"route", Collections.singletonMap("name", "value"));
// Test master use case
EasyMock.expect(this.singleton.isMasterNode()).andReturn(true);
Modified:
trunk/mod_cluster/src/test/java/org/jboss/modcluster/ha/HASingletonAwareResetRequestSourceTestCase.java
===================================================================
---
trunk/mod_cluster/src/test/java/org/jboss/modcluster/ha/HASingletonAwareResetRequestSourceTestCase.java 2008-10-02
15:31:06 UTC (rev 1925)
+++
trunk/mod_cluster/src/test/java/org/jboss/modcluster/ha/HASingletonAwareResetRequestSourceTestCase.java 2008-10-02
16:27:48 UTC (rev 1926)
@@ -63,8 +63,9 @@
public void testGetResetRequests() throws Exception
{
- MCMPRequest request1 = new MCMPRequest(MCMPRequestType.ENABLE_APP, false,
Collections.singletonMap("JVMRoute", "host1"));
- MCMPRequest request2 = new MCMPRequest(MCMPRequestType.REMOVE_APP, false,
Collections.singletonMap("JVMRoute", "host2"));
+ Map<String, String> emptyMap = Collections.emptyMap();
+ MCMPRequest request1 = new MCMPRequest(MCMPRequestType.ENABLE_APP, false,
"host1", emptyMap);
+ MCMPRequest request2 = new MCMPRequest(MCMPRequestType.REMOVE_APP, false,
"host2", emptyMap);
ResetRequestGroupRpcResponse response1 = new
ResetRequestGroupRpcResponse(EasyMock.createMock(ClusterNode.class),
Collections.singletonList(request1));
ResetRequestGroupRpcResponse response2 = new
ResetRequestGroupRpcResponse(EasyMock.createMock(ClusterNode.class),
Collections.singletonList(request2));
@@ -133,13 +134,13 @@
EasyMock.expect(container.findChildren()).andReturn(new Container[] { context });
EasyMock.expect(context.isStarted()).andReturn(true);
- EasyMock.expect(context.getParent()).andReturn(container);
- EasyMock.expect(container.getParent()).andReturn(engine);
- EasyMock.expect(engine.getJvmRoute()).andReturn("host1");
EasyMock.expect(context.getPath()).andReturn("/context");
EasyMock.expect(context.getParent()).andReturn(host);
EasyMock.expect(host.getName()).andReturn("host");
EasyMock.expect(host.findAliases()).andReturn(new String[] { "alias1",
"alias2" });
+ EasyMock.expect(context.getParent()).andReturn(container);
+ EasyMock.expect(container.getParent()).andReturn(engine);
+ EasyMock.expect(engine.getJvmRoute()).andReturn("host1");
EasyMock.replay(this.singleton, this.key, this.partition, server, service, engine,
container, context, host, this.nodeConfig, this.balancerConfig);
@@ -154,16 +155,16 @@
assertSame(MCMPRequestType.REMOVE_APP, request.getRequestType());
assertTrue(request.isWildcard());
- assertEquals(1, parameters.size());
- assertEquals("host", parameters.get("JVMRoute"));
+ assertEquals("host", request.getJvmRoute());
+ assertTrue(request.getParameters().isEmpty());
request = results.get(1);
parameters = request.getParameters();
assertSame(MCMPRequestType.CONFIG, request.getRequestType());
assertFalse(request.isWildcard());
- assertEquals(17, parameters.size());
- assertEquals("host1", parameters.get("JVMRoute"));
+ assertEquals("host1", request.getJvmRoute());
+ assertEquals(16, parameters.size());
assertEquals("127.0.0.1", parameters.get("Host"));
assertEquals("0", parameters.get("Port"));
assertEquals("ajp", parameters.get("Type"));
@@ -186,8 +187,8 @@
assertSame(MCMPRequestType.ENABLE_APP, request.getRequestType());
assertFalse(request.isWildcard());
- assertEquals(3, parameters.size());
- assertEquals("host1", parameters.get("JVMRoute"));
+ assertEquals("host1", request.getJvmRoute());
+ assertEquals(2, parameters.size());
assertEquals("/context", parameters.get("Context"));
assertEquals("host,alias1,alias2", parameters.get("Alias"));
@@ -249,13 +250,13 @@
EasyMock.expect(container.findChildren()).andReturn(new Container[] { context });
EasyMock.expect(context.isStarted()).andReturn(true);
- EasyMock.expect(context.getParent()).andReturn(container);
- EasyMock.expect(container.getParent()).andReturn(engine);
- EasyMock.expect(engine.getJvmRoute()).andReturn("host1");
EasyMock.expect(context.getPath()).andReturn("/context");
EasyMock.expect(context.getParent()).andReturn(host);
EasyMock.expect(host.getName()).andReturn("host");
EasyMock.expect(host.findAliases()).andReturn(new String[] { "alias1",
"alias2" });
+ EasyMock.expect(context.getParent()).andReturn(container);
+ EasyMock.expect(container.getParent()).andReturn(engine);
+ EasyMock.expect(engine.getJvmRoute()).andReturn("host1");
EasyMock.replay(this.singleton, this.key, this.partition, server, service, engine,
container, context, host, this.nodeConfig, this.balancerConfig);
@@ -266,20 +267,19 @@
assertEquals(3, results.size());
MCMPRequest request = results.get(0);
- Map<String, String> parameters = request.getParameters();
assertSame(MCMPRequestType.REMOVE_APP, request.getRequestType());
assertTrue(request.isWildcard());
- assertEquals(1, parameters.size());
- assertEquals("host", parameters.get("JVMRoute"));
+ assertEquals("host", request.getJvmRoute());
+ assertTrue(request.getParameters().isEmpty());
request = results.get(1);
- parameters = request.getParameters();
+ Map<String, String> parameters = request.getParameters();
assertSame(MCMPRequestType.CONFIG, request.getRequestType());
assertFalse(request.isWildcard());
- assertEquals(17, parameters.size());
- assertEquals("host1", parameters.get("JVMRoute"));
+ assertEquals("host1", request.getJvmRoute());
+ assertEquals(16, parameters.size());
assertEquals("127.0.0.1", parameters.get("Host"));
assertEquals("0", parameters.get("Port"));
assertEquals("ajp", parameters.get("Type"));
@@ -302,8 +302,8 @@
assertSame(MCMPRequestType.ENABLE_APP, request.getRequestType());
assertFalse(request.isWildcard());
- assertEquals(3, parameters.size());
- assertEquals("host1", parameters.get("JVMRoute"));
+ assertEquals("host1", request.getJvmRoute());
+ assertEquals(2, parameters.size());
assertEquals("/context", parameters.get("Context"));
assertEquals("host,alias1,alias2", parameters.get("Alias"));