JBoss Native SVN: r2044 - trunk/mod_cluster/src/test/java/org/jboss/modcluster/ha.
by jbossnative-commits@lists.jboss.org
Author: pferraro
Date: 2008-10-31 17:34:10 -0400 (Fri, 31 Oct 2008)
New Revision: 2044
Modified:
trunk/mod_cluster/src/test/java/org/jboss/modcluster/ha/HASingletonAwareResetRequestSourceTestCase.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/test/java/org/jboss/modcluster/ha/HASingletonAwareResetRequestSourceTestCase.java
===================================================================
--- trunk/mod_cluster/src/test/java/org/jboss/modcluster/ha/HASingletonAwareResetRequestSourceTestCase.java 2008-10-31 20:56:32 UTC (rev 2043)
+++ trunk/mod_cluster/src/test/java/org/jboss/modcluster/ha/HASingletonAwareResetRequestSourceTestCase.java 2008-10-31 21:34:10 UTC (rev 2044)
@@ -99,7 +99,6 @@
Server server = EasyMock.createStrictMock(Server.class);
Service service = EasyMock.createStrictMock(Service.class);
Engine engine = EasyMock.createStrictMock(Engine.class);
- Container container = EasyMock.createStrictMock(Container.class);
Context context = EasyMock.createStrictMock(Context.class);
Host host = EasyMock.createStrictMock(Host.class);
Connector connector = new Connector("AJP/1.3");
@@ -132,19 +131,18 @@
EasyMock.expect(this.balancerConfig.getWorkerTimeout()).andReturn(6);
EasyMock.expect(this.balancerConfig.getMaxAttempts()).andReturn(7);
- EasyMock.expect(engine.findChildren()).andReturn(new Container[] { container });
- EasyMock.expect(container.findChildren()).andReturn(new Container[] { context });
- EasyMock.expect(context.getPath()).andReturn("/context");
- EasyMock.expect(context.isStarted()).andReturn(true);
- EasyMock.expect(context.getParent()).andReturn(host);
- EasyMock.expect(host.getName()).andReturn("host");
+ EasyMock.expect(engine.findChildren()).andReturn(new Container[] { host });
+ EasyMock.expect(host.getName()).andReturn("host").times(2);
EasyMock.expect(host.findAliases()).andReturn(new String[] { "alias1", "alias2" });
+ EasyMock.expect(host.findChildren()).andReturn(new Container[] { context });
+ EasyMock.expect(context.getPath()).andReturn("/context");
+ EasyMock.expect(context.isStarted()).andReturn(true);
- EasyMock.replay(this.singleton, this.key, this.partition, server, service, engine, container, context, host, this.nodeConfig, this.balancerConfig);
+ EasyMock.replay(this.singleton, this.key, this.partition, server, service, engine, context, host, this.nodeConfig, this.balancerConfig);
results = this.source.getResetRequests(emptyResponseMap);
- EasyMock.verify(this.singleton, this.key, this.partition, server, service, engine, container, context, host, this.nodeConfig, this.balancerConfig);
+ EasyMock.verify(this.singleton, this.key, this.partition, server, service, engine, context, host, this.nodeConfig, this.balancerConfig);
Assert.assertEquals(4, results.size());
@@ -185,9 +183,8 @@
Assert.assertSame(request1, results.get(2));
Assert.assertSame(request2, results.get(3));
- EasyMock.reset(this.singleton, this.key, this.partition, server, service, engine, container, context, host, this.nodeConfig, this.balancerConfig);
+ EasyMock.reset(this.singleton, this.key, this.partition, server, service, engine, context, host, this.nodeConfig, this.balancerConfig);
-
// Test non-master
results = this.source.getResetRequests(emptyResponseMap);
@@ -208,7 +205,6 @@
Server server = EasyMock.createStrictMock(Server.class);
Service service = EasyMock.createStrictMock(Service.class);
Engine engine = EasyMock.createStrictMock(Engine.class);
- Container container = EasyMock.createStrictMock(Container.class);
Context context = EasyMock.createStrictMock(Context.class);
Host host = EasyMock.createStrictMock(Host.class);
Connector connector = new Connector("AJP/1.3");
@@ -235,19 +231,18 @@
EasyMock.expect(this.balancerConfig.getWorkerTimeout()).andReturn(6);
EasyMock.expect(this.balancerConfig.getMaxAttempts()).andReturn(7);
- EasyMock.expect(engine.findChildren()).andReturn(new Container[] { container });
- EasyMock.expect(container.findChildren()).andReturn(new Container[] { context });
- EasyMock.expect(context.getPath()).andReturn("/context");
- EasyMock.expect(context.isStarted()).andReturn(true);
- EasyMock.expect(context.getParent()).andReturn(host);
- EasyMock.expect(host.getName()).andReturn("host");
+ EasyMock.expect(engine.findChildren()).andReturn(new Container[] { host });
+ EasyMock.expect(host.getName()).andReturn("host").times(2);
EasyMock.expect(host.findAliases()).andReturn(new String[] { "alias1", "alias2" });
+ EasyMock.expect(host.findChildren()).andReturn(new Container[] { context });
+ EasyMock.expect(context.getPath()).andReturn("/context");
+ EasyMock.expect(context.isStarted()).andReturn(true);
- EasyMock.replay(this.singleton, this.key, this.partition, server, service, engine, container, context, host, this.nodeConfig, this.balancerConfig);
+ EasyMock.replay(this.singleton, this.key, this.partition, server, service, engine, context, host, this.nodeConfig, this.balancerConfig);
results = this.source.getLocalResetRequests(emptyResponseMap);
- EasyMock.verify(this.singleton, this.key, this.partition, server, service, engine, container, context, host, this.nodeConfig, this.balancerConfig);
+ EasyMock.verify(this.singleton, this.key, this.partition, server, service, engine, context, host, this.nodeConfig, this.balancerConfig);
Assert.assertEquals(2, results.size());
@@ -285,6 +280,6 @@
Assert.assertEquals("/context", parameters.get("Context"));
Assert.assertEquals("host,alias1,alias2", parameters.get("Alias"));
- EasyMock.reset(this.singleton, this.key, this.partition, server, service, engine, container, context, host, this.nodeConfig, this.balancerConfig);
+ EasyMock.reset(this.singleton, this.key, this.partition, server, service, engine, context, host, this.nodeConfig, this.balancerConfig);
}
}
16 years, 2 months
JBoss Native SVN: r2043 - trunk/mod_cluster/src/main/java/org/jboss/modcluster/mcmp.
by jbossnative-commits@lists.jboss.org
Author: pferraro
Date: 2008-10-31 16:56:32 -0400 (Fri, 31 Oct 2008)
New Revision: 2043
Modified:
trunk/mod_cluster/src/main/java/org/jboss/modcluster/mcmp/MCMPUtils.java
Log:
ENABLE-APP requests should use aliases from host, not 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:34:30 UTC (rev 2042)
+++ trunk/mod_cluster/src/main/java/org/jboss/modcluster/mcmp/MCMPUtils.java 2008-10-31 20:56:32 UTC (rev 2043)
@@ -277,7 +277,11 @@
engineRequests.add(createConfigRequest(jvmRoute, service.findConnectors(), nodeConfig, balancerConfig));
- Set<ResetRequestSource.VirtualHost> virtualHosts = response.get(jvmRoute);
+ Set<ResetRequestSource.VirtualHost> responseHosts = Collections.emptySet();
+ if (response.containsKey(jvmRoute))
+ {
+ responseHosts = response.get(jvmRoute);
+ }
for (Container child: engine.findChildren())
{
@@ -287,15 +291,12 @@
VirtualHost responseHost = null;
- if (virtualHosts != null)
+ for (VirtualHost virtualHost: responseHosts)
{
- for (VirtualHost virtualHost: virtualHosts)
+ if (virtualHost.getAliases().contains(hostName))
{
- if (virtualHost.getAliases().contains(hostName))
- {
- responseHost = virtualHost;
- break;
- }
+ responseHost = virtualHost;
+ break;
}
}
@@ -332,14 +333,14 @@
{
if (status != ResetRequestSource.Status.ENABLED)
{
- engineRequests.add(createContextRequest(MCMPRequestType.ENABLE_APP, jvmRoute, responseAliases, path));
+ engineRequests.add(createContextRequest(MCMPRequestType.ENABLE_APP, jvmRoute, aliases, path));
}
}
else
{
if (status == ResetRequestSource.Status.ENABLED)
{
- engineRequests.add(createContextRequest(MCMPRequestType.STOP_APP, jvmRoute, responseAliases, path));
+ engineRequests.add(createContextRequest(MCMPRequestType.STOP_APP, jvmRoute, aliases, path));
}
}
}
16 years, 2 months
JBoss Native SVN: r2042 - trunk/mod_cluster/src/main/java/org/jboss/modcluster/mcmp.
by jbossnative-commits@lists.jboss.org
Author: pferraro
Date: 2008-10-31 16:34:30 -0400 (Fri, 31 Oct 2008)
New Revision: 2042
Modified:
trunk/mod_cluster/src/main/java/org/jboss/modcluster/mcmp/MCMPUtils.java
Log:
Fixed NullPointerException in getResetRequests()
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:19:04 UTC (rev 2041)
+++ trunk/mod_cluster/src/main/java/org/jboss/modcluster/mcmp/MCMPUtils.java 2008-10-31 20:34:30 UTC (rev 2042)
@@ -287,12 +287,15 @@
VirtualHost responseHost = null;
- for (VirtualHost virtualHost: virtualHosts)
+ if (virtualHosts != null)
{
- if (virtualHost.getAliases().contains(hostName))
+ for (VirtualHost virtualHost: virtualHosts)
{
- responseHost = virtualHost;
- break;
+ if (virtualHost.getAliases().contains(hostName))
+ {
+ responseHost = virtualHost;
+ break;
+ }
}
}
16 years, 2 months
JBoss Native SVN: r2041 - trunk/mod_cluster/src/test/java/org/jboss/modcluster/ha.
by jbossnative-commits@lists.jboss.org
Author: pferraro
Date: 2008-10-31 16:19:04 -0400 (Fri, 31 Oct 2008)
New Revision: 2041
Modified:
trunk/mod_cluster/src/test/java/org/jboss/modcluster/ha/HASingletonAwareResetRequestSourceTestCase.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/test/java/org/jboss/modcluster/ha/HASingletonAwareResetRequestSourceTestCase.java
===================================================================
--- trunk/mod_cluster/src/test/java/org/jboss/modcluster/ha/HASingletonAwareResetRequestSourceTestCase.java 2008-10-31 20:18:49 UTC (rev 2040)
+++ trunk/mod_cluster/src/test/java/org/jboss/modcluster/ha/HASingletonAwareResetRequestSourceTestCase.java 2008-10-31 20:19:04 UTC (rev 2041)
@@ -26,6 +26,7 @@
import java.util.Collections;
import java.util.List;
import java.util.Map;
+import java.util.Set;
import org.apache.catalina.Container;
import org.apache.catalina.Context;
@@ -67,7 +68,7 @@
public void getResetRequests() throws Exception
{
Map<String, String> emptyMap = Collections.emptyMap();
- Map<String, ResetRequestSource.EngineStatus> emptyResponseMap = Collections.emptyMap();
+ Map<String, Set<ResetRequestSource.VirtualHost>> emptyResponseMap = Collections.emptyMap();
MCMPRequest request1 = new MCMPRequest(MCMPRequestType.ENABLE_APP, false, "host1", emptyMap);
MCMPRequest request2 = new MCMPRequest(MCMPRequestType.REMOVE_APP, false, "host2", emptyMap);
@@ -196,7 +197,7 @@
@Test
public void getLocalResetRequests() throws Exception
{
- Map<String, ResetRequestSource.EngineStatus> emptyResponseMap = Collections.emptyMap();
+ Map<String, Set<ResetRequestSource.VirtualHost>> emptyResponseMap = Collections.emptyMap();
// Test w/out server
List<MCMPRequest> results = this.source.getLocalResetRequests(emptyResponseMap);
16 years, 2 months
JBoss Native SVN: r2040 - trunk/mod_cluster/src/test/java/org/jboss/modcluster.
by jbossnative-commits@lists.jboss.org
Author: pferraro
Date: 2008-10-31 16:18:49 -0400 (Fri, 31 Oct 2008)
New Revision: 2040
Modified:
trunk/mod_cluster/src/test/java/org/jboss/modcluster/ClusterListenerTestCase.java
Log:
Cluster listener no longer implements ResetRequestSource.
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-31 20:17:03 UTC (rev 2039)
+++ trunk/mod_cluster/src/test/java/org/jboss/modcluster/ClusterListenerTestCase.java 2008-10-31 20:18:49 UTC (rev 2040)
@@ -21,33 +21,25 @@
*/
package org.jboss.modcluster;
-import java.util.Collections;
-import java.util.List;
-import java.util.Map;
-
import javax.management.MalformedObjectNameException;
import javax.management.ObjectName;
import org.apache.catalina.Container;
import org.apache.catalina.ContainerEvent;
import org.apache.catalina.ContainerListener;
-import org.apache.catalina.Context;
import org.apache.catalina.Engine;
-import org.apache.catalina.Host;
import org.apache.catalina.Lifecycle;
import org.apache.catalina.LifecycleEvent;
import org.apache.catalina.LifecycleListener;
import org.apache.catalina.Server;
import org.apache.catalina.ServerFactory;
import org.apache.catalina.Service;
-import org.apache.catalina.connector.Connector;
import org.apache.tomcat.util.modeler.Registry;
import org.easymock.Capture;
import org.easymock.EasyMock;
import org.jboss.modcluster.mcmp.MCMPHandler;
import org.jboss.modcluster.mcmp.MCMPRequest;
import org.jboss.modcluster.mcmp.MCMPRequestType;
-import org.jboss.modcluster.mcmp.ResetRequestSource;
import org.junit.Assert;
import org.junit.Test;
@@ -68,92 +60,6 @@
private final ContainerListener containerListener = EasyMock.createStrictMock(ContainerListener.class);
private final ClusterListener listener = new ClusterListener(this.mcmpHandler, this.lifecycleListener, this.containerListener);
-
- @Test
- public void getResetRequests() throws Exception
- {
- Service service = EasyMock.createStrictMock(Service.class);
- Engine engine = EasyMock.createStrictMock(Engine.class);
- Container container = EasyMock.createStrictMock(Container.class);
- Context context = EasyMock.createStrictMock(Context.class);
- Host host = EasyMock.createStrictMock(Host.class);
- Connector connector = new Connector("AJP/1.3");
-
- this.listener.setDomain("domain");
- this.listener.setFlushPackets(true);
- this.listener.setFlushWait(1);
- this.listener.setPing(2);
- this.listener.setSmax(3);
- this.listener.setTtl(4);
- this.listener.setNodeTimeout(5);
- this.listener.setBalancer("S");
- this.listener.setStickySession(false);
- this.listener.setStickySessionRemove(true);
- this.listener.setStickySessionForce(false);
- this.listener.setWorkerTimeout(6);
- this.listener.setMaxAttempts(7);
-
- EasyMock.expect(server.findServices()).andReturn(new Service[] { service });
- EasyMock.expect(service.getContainer()).andReturn(engine);
- EasyMock.expect(engine.getJvmRoute()).andReturn("host1");
- EasyMock.expect(service.findConnectors()).andReturn(new Connector[] { connector });
-
- EasyMock.expect(engine.findChildren()).andReturn(new Container[] { container });
- EasyMock.expect(container.findChildren()).andReturn(new Container[] { context });
- EasyMock.expect(context.getPath()).andReturn("/context");
- EasyMock.expect(context.isStarted()).andReturn(true);
- EasyMock.expect(context.getParent()).andReturn(host);
- EasyMock.expect(host.getName()).andReturn("host");
- EasyMock.expect(host.findAliases()).andReturn(new String[] { "alias1", "alias2" });
-
- EasyMock.replay(server, service, engine, container, context, host);
-
- Map<String, ResetRequestSource.EngineStatus> emptyResponseMap = Collections.emptyMap();
- List<MCMPRequest> requests = this.listener.getResetRequests(emptyResponseMap);
-
- EasyMock.verify(server, service, engine, container, context, host);
-
- Assert.assertEquals(2, requests.size());
-
- MCMPRequest request = requests.get(0);
- Map<String, String> parameters = request.getParameters();
-
- request = requests.get(0);
- parameters = request.getParameters();
-
- Assert.assertSame(MCMPRequestType.CONFIG, request.getRequestType());
- Assert.assertFalse(request.isWildcard());
- Assert.assertEquals("host1", request.getJvmRoute());
- Assert.assertEquals(16, parameters.size());
- Assert.assertEquals("127.0.0.1", parameters.get("Host"));
- Assert.assertEquals("0", parameters.get("Port"));
- Assert.assertEquals("ajp", parameters.get("Type"));
- Assert.assertEquals("domain", parameters.get("Domain"));
- Assert.assertEquals("On", parameters.get("flushpackets"));
- Assert.assertEquals("1", parameters.get("flushwait"));
- Assert.assertEquals("2", parameters.get("ping"));
- Assert.assertEquals("3", parameters.get("smax"));
- Assert.assertEquals("4", parameters.get("ttl"));
- Assert.assertEquals("5", parameters.get("Timeout"));
- Assert.assertEquals("S", parameters.get("Balancer"));
- Assert.assertEquals("No", parameters.get("StickySession"));
- Assert.assertEquals("Yes", parameters.get("StickySessionRemove"));
- Assert.assertEquals("No", parameters.get("StickySessionForce"));
- Assert.assertEquals("6", parameters.get("WaitWorker"));
- Assert.assertEquals("7", parameters.get("Maxattempts"));
-
- request = requests.get(1);
- parameters = request.getParameters();
-
- Assert.assertSame(MCMPRequestType.ENABLE_APP, request.getRequestType());
- Assert.assertFalse(request.isWildcard());
- Assert.assertEquals("host1", request.getJvmRoute());
- Assert.assertEquals(2, parameters.size());
- Assert.assertEquals("/context", parameters.get("Context"));
- Assert.assertEquals("host,alias1,alias2", parameters.get("Alias"));
-
- EasyMock.reset(server, service, engine, container, context, host);
- }
@Test
public void getProxyConfiguration()
16 years, 2 months
JBoss Native SVN: r2039 - trunk/mod_cluster/src/main/java/org/jboss/modcluster.
by jbossnative-commits@lists.jboss.org
Author: pferraro
Date: 2008-10-31 16:17:03 -0400 (Fri, 31 Oct 2008)
New Revision: 2039
Modified:
trunk/mod_cluster/src/main/java/org/jboss/modcluster/ClusterListener.java
Log:
Add constructor to allow JBoss AS to define a non-clustered listener.
Modified: trunk/mod_cluster/src/main/java/org/jboss/modcluster/ClusterListener.java
===================================================================
--- trunk/mod_cluster/src/main/java/org/jboss/modcluster/ClusterListener.java 2008-10-31 20:16:19 UTC (rev 2038)
+++ trunk/mod_cluster/src/main/java/org/jboss/modcluster/ClusterListener.java 2008-10-31 20:17:03 UTC (rev 2039)
@@ -22,9 +22,6 @@
package org.jboss.modcluster;
-import java.util.List;
-import java.util.Map;
-
import javax.management.MalformedObjectNameException;
import javax.management.ObjectName;
@@ -42,11 +39,12 @@
import org.apache.tomcat.util.modeler.Registry;
import org.jboss.logging.Logger;
import org.jboss.modcluster.config.ModClusterConfig;
+import org.jboss.modcluster.load.LoadBalanceFactorProvider;
import org.jboss.modcluster.mcmp.MCMPHandler;
import org.jboss.modcluster.mcmp.MCMPRequest;
import org.jboss.modcluster.mcmp.MCMPUtils;
-import org.jboss.modcluster.mcmp.ResetRequestSource;
import org.jboss.modcluster.mcmp.impl.DefaultMCMPHandler;
+import org.jboss.modcluster.mcmp.impl.ResetRequestSourceImpl;
/**
* This listener communicates with a front end mod_cluster enabled proxy to
@@ -54,7 +52,7 @@
* deployed.
*/
public class ClusterListener extends ModClusterConfig
- implements LifecycleListener, ContainerListener, ResetRequestSource
+ implements LifecycleListener, ContainerListener
{
static
{
@@ -92,16 +90,21 @@
public ClusterListener()
{
- this.mcmpHandler = new DefaultMCMPHandler(this, this);
+ this(null);
+ }
+
+ public ClusterListener(LoadBalanceFactorProvider loadBalanceFactorProvider)
+ {
+ this.mcmpHandler = new DefaultMCMPHandler(this, new ResetRequestSourceImpl(this, this));
- JBossWebEventHandler eventHandler = new DefaultJBossWebEventHandler(this, this, this, this.mcmpHandler, this);
+ JBossWebEventHandler eventHandler = new DefaultJBossWebEventHandler(this, this, this, this.mcmpHandler, (loadBalanceFactorProvider != null) ? loadBalanceFactorProvider : this);
BasicClusterListener listener = new BasicClusterListener(eventHandler);
this.lifecycleListener = listener;
this.containerListener = listener;
}
-
+
protected ClusterListener(MCMPHandler mcmpHandler, LifecycleListener lifecycleListener, ContainerListener containerListener)
{
this.mcmpHandler = mcmpHandler;
@@ -109,16 +112,6 @@
this.containerListener = containerListener;
}
- // ---------------------------------------------------- ResetRequestSource
-
- /**
- * Reset configuration for a particular proxy following an error.
- */
- public List<MCMPRequest> getResetRequests(Map<String, ResetRequestSource.EngineStatus> response)
- {
- return MCMPUtils.getResetRequests(response, ServerFactory.getServer(), this, this);
- }
-
//----------------------------------------------------------------- Public
/**
@@ -140,6 +133,7 @@
{
return this.mcmpHandler.getProxyConfiguration();
}
+
/**
* Retrieves the full proxy info message.
*
@@ -151,7 +145,6 @@
return this.mcmpHandler.getProxyInfo();
}
-
/**
* Reset a DOWN connection to the proxy up to ERROR, where the configuration will
* be refreshed. To be used through JMX or similar.
16 years, 2 months
JBoss Native SVN: r2038 - in trunk/mod_cluster/src/main/java/org/jboss/modcluster: ha and 3 other directories.
by jbossnative-commits@lists.jboss.org
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);
+ }
+}
16 years, 2 months
JBoss Native SVN: r2037 - trunk/mod_cluster/src/main/java/org/jboss/modcluster.
by jbossnative-commits@lists.jboss.org
Author: pferraro
Date: 2008-10-31 16:14:18 -0400 (Fri, 31 Oct 2008)
New Revision: 2037
Modified:
trunk/mod_cluster/src/main/java/org/jboss/modcluster/Utils.java
Log:
Add getAliases(Host)
Modified: trunk/mod_cluster/src/main/java/org/jboss/modcluster/Utils.java
===================================================================
--- trunk/mod_cluster/src/main/java/org/jboss/modcluster/Utils.java 2008-10-31 04:18:51 UTC (rev 2036)
+++ trunk/mod_cluster/src/main/java/org/jboss/modcluster/Utils.java 2008-10-31 20:14:18 UTC (rev 2037)
@@ -95,13 +95,10 @@
public static String getAddress(Connector connector)
{
Object address = IntrospectionUtils.getProperty(connector.getProtocolHandler(), "address");
- InetAddress inetAddress = null;
- if (address instanceof String)
- return (String) address;
- else
- inetAddress = (InetAddress) address;
-
- return (inetAddress != null) ? inetAddress.getHostAddress() : "127.0.0.1";
+
+ if (address == null) return "127.0.0.1";
+
+ return (address instanceof InetAddress) ? ((InetAddress) address).getHostAddress() : (String) address;
}
/**
@@ -114,16 +111,26 @@
{
return ((Engine) context.getParent().getParent()).getJvmRoute();
}
-
+
/**
- * Return the host and its alias list with which the context is associated.
+ * Returns the aliases of the host of the specified context, including its host name
*
* @param context
- * @return
+ * @return a set of aliases, including the host name
*/
public static Set<String> getAliases(Context context)
{
- Host host = (Host) context.getParent();
+ return getAliases((Host) context.getParent());
+ }
+
+ /**
+ * Returns the aliases of the specified host, including its name
+ *
+ * @param host
+ * @return a set of aliases, including the host name
+ */
+ public static Set<String> getAliases(Host host)
+ {
String name = host.getName();
String[] aliases = host.findAliases();
16 years, 2 months
JBoss Native SVN: r2036 - trunk/mod_cluster/src/main/java/org/jboss/modcluster/mcmp/impl.
by jbossnative-commits@lists.jboss.org
Author: pferraro
Date: 2008-10-31 00:18:51 -0400 (Fri, 31 Oct 2008)
New Revision: 2036
Modified:
trunk/mod_cluster/src/main/java/org/jboss/modcluster/mcmp/impl/DefaultMCMPHandler.java
Log:
Add custom serialization for EngineStatusImpl
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 04:18:33 UTC (rev 2035)
+++ trunk/mod_cluster/src/main/java/org/jboss/modcluster/mcmp/impl/DefaultMCMPHandler.java 2008-10-31 04:18:51 UTC (rev 2036)
@@ -24,8 +24,11 @@
import java.io.BufferedReader;
import java.io.BufferedWriter;
+import java.io.Externalizable;
import java.io.IOException;
import java.io.InputStreamReader;
+import java.io.ObjectInput;
+import java.io.ObjectOutput;
import java.io.OutputStreamWriter;
import java.io.Serializable;
import java.io.Writer;
@@ -1194,11 +1197,16 @@
}
}
- class EngineStatusImpl implements ResetRequestSource.EngineStatus
+ static class EngineStatusImpl implements ResetRequestSource.EngineStatus, Externalizable
{
- private Set<String> aliases = new LinkedHashSet<String>();
- private Map<String, ResetRequestSource.Status> contexts = new HashMap<String, ResetRequestSource.Status>();
+ private final Set<String> aliases = new LinkedHashSet<String>();
+ private final Map<String, ResetRequestSource.Status> contexts = new HashMap<String, ResetRequestSource.Status>();
+ public EngineStatusImpl()
+ {
+ // Expose for deserialization
+ }
+
/**
* @{inheritDoc}
* @see org.jboss.modcluster.mcmp.ResetRequestSource.EngineStatus#getAliases()
@@ -1216,5 +1224,48 @@
{
return this.contexts;
}
+
+ /**
+ * @{inheritDoc}
+ * @see java.io.Externalizable#readExternal(java.io.ObjectInput)
+ */
+ public void readExternal(ObjectInput input) throws IOException
+ {
+ int aliases = input.readInt();
+ for (int i = 0; i < aliases; ++i)
+ {
+ this.aliases.add(input.readUTF());
+ }
+
+ ResetRequestSource.Status[] stati = ResetRequestSource.Status.values();
+ int contexts = input.readInt();
+
+ for (int i = 0; i < contexts; ++i)
+ {
+ this.contexts.put(input.readUTF(), stati[input.readInt()]);
+ }
+ }
+
+ /**
+ * @{inheritDoc}
+ * @see java.io.Externalizable#writeExternal(java.io.ObjectOutput)
+ */
+ public void writeExternal(ObjectOutput output) throws IOException
+ {
+ output.writeInt(this.aliases.size());
+
+ for (String alias: this.aliases)
+ {
+ output.writeUTF(alias);
+ }
+
+ output.writeInt(this.contexts.size());
+
+ for (Map.Entry<String, ResetRequestSource.Status> context: this.contexts.entrySet())
+ {
+ output.writeUTF(context.getKey());
+ output.writeInt(context.getValue().ordinal());
+ }
+ }
}
}
16 years, 2 months
JBoss Native SVN: r2035 - trunk/mod_cluster/src/main/java/org/jboss/modcluster/mcmp.
by jbossnative-commits@lists.jboss.org
Author: pferraro
Date: 2008-10-31 00:18:33 -0400 (Fri, 31 Oct 2008)
New Revision: 2035
Modified:
trunk/mod_cluster/src/main/java/org/jboss/modcluster/mcmp/ResetRequestSource.java
Log:
Make EngineStatus serializable.
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-30 23:36:22 UTC (rev 2034)
+++ trunk/mod_cluster/src/main/java/org/jboss/modcluster/mcmp/ResetRequestSource.java 2008-10-31 04:18:33 UTC (rev 2035)
@@ -22,6 +22,7 @@
package org.jboss.modcluster.mcmp;
+import java.io.Serializable;
import java.util.List;
import java.util.Map;
import java.util.Set;
@@ -41,7 +42,7 @@
ENABLED, DISABLED, STOPPED
}
- interface EngineStatus
+ interface EngineStatus extends Serializable
{
Set<String> getAliases();
Map<String, Status> getContexts();
16 years, 2 months