JBoss Native SVN: r2228 - trunk/mod_cluster/test/java/org/jboss/mod_cluster.
by jbossnative-commits@lists.jboss.org
Author: jfrederic.clere(a)jboss.com
Date: 2009-01-27 16:32:36 -0500 (Tue, 27 Jan 2009)
New Revision: 2228
Modified:
trunk/mod_cluster/test/java/org/jboss/mod_cluster/ClientBasicAuthen.java
trunk/mod_cluster/test/java/org/jboss/mod_cluster/Maintest.java
trunk/mod_cluster/test/java/org/jboss/mod_cluster/TestAddDel.java
trunk/mod_cluster/test/java/org/jboss/mod_cluster/TestBase.java
trunk/mod_cluster/test/java/org/jboss/mod_cluster/TestFailover.java
trunk/mod_cluster/test/java/org/jboss/mod_cluster/TestStickyForce.java
trunk/mod_cluster/test/java/org/jboss/mod_cluster/TestStickyRemove.java
Log:
Arrange the traces and tests...
Modified: trunk/mod_cluster/test/java/org/jboss/mod_cluster/ClientBasicAuthen.java
===================================================================
--- trunk/mod_cluster/test/java/org/jboss/mod_cluster/ClientBasicAuthen.java 2009-01-27 21:18:44 UTC (rev 2227)
+++ trunk/mod_cluster/test/java/org/jboss/mod_cluster/ClientBasicAuthen.java 2009-01-27 21:32:36 UTC (rev 2228)
@@ -85,7 +85,7 @@
}
// Debug Stuff
- Maintest.listServices();
+ // Maintest.listServices();
} catch(IOException ex) {
ex.printStackTrace();
Modified: trunk/mod_cluster/test/java/org/jboss/mod_cluster/Maintest.java
===================================================================
--- trunk/mod_cluster/test/java/org/jboss/mod_cluster/Maintest.java 2009-01-27 21:18:44 UTC (rev 2227)
+++ trunk/mod_cluster/test/java/org/jboss/mod_cluster/Maintest.java 2009-01-27 21:32:36 UTC (rev 2228)
@@ -33,6 +33,7 @@
import junit.textui.TestRunner;
import java.lang.Exception;
+import java.net.Socket;
import org.apache.catalina.ServerFactory;
import org.apache.catalina.Service;
@@ -211,4 +212,37 @@
}
return true;
}
+ public static void testPort(int port) {
+ Socket s = null;
+ try {
+ s = new Socket("localhost", port);
+ s.setSoLinger(true, 0);
+ } catch (Exception e) {
+ System.out.println("Can't connect to " + port);
+ } finally {
+ if (s != null) {
+ System.out.println("Was connected to " + port);
+ try {
+ s.close();
+ } catch (Exception e) {
+ }
+ }
+ }
+ }
+ static boolean TestForNodes(LifecycleListener lifecycle, String [] nodes) {
+ int countinfo = 0;
+ while ((!Maintest.checkProxyInfo(lifecycle, nodes)) && countinfo < 20) {
+ try {
+ Thread.sleep(3000);
+ } catch (InterruptedException ex) {
+ ex.printStackTrace();
+ }
+ countinfo++;
+ }
+ if (countinfo == 20)
+ return false;
+ else
+ return true;
+ }
+
}
Modified: trunk/mod_cluster/test/java/org/jboss/mod_cluster/TestAddDel.java
===================================================================
--- trunk/mod_cluster/test/java/org/jboss/mod_cluster/TestAddDel.java 2009-01-27 21:18:44 UTC (rev 2227)
+++ trunk/mod_cluster/test/java/org/jboss/mod_cluster/TestAddDel.java 2009-01-27 21:32:36 UTC (rev 2228)
@@ -52,6 +52,7 @@
JBossWeb [] service = new JBossWeb[numbnodes];
LifecycleListener lifecycle = null;
+ System.out.println("TestAddDel Started");
StandardServer server = Maintest.getServer();
for (int i=0; i<numbnodes; i++) {
try {
@@ -73,7 +74,7 @@
server.addLifecycleListener(lifecycle);
// Debug Stuff
- Maintest.listServices();
+ // Maintest.listServices();
// start the server thread.
ServerThread wait = new ServerThread(3000, server);
@@ -158,6 +159,7 @@
if (clienterror)
fail("Client error");
+ System.out.println("TestAddDel Done");
}
}
Modified: trunk/mod_cluster/test/java/org/jboss/mod_cluster/TestBase.java
===================================================================
--- trunk/mod_cluster/test/java/org/jboss/mod_cluster/TestBase.java 2009-01-27 21:18:44 UTC (rev 2227)
+++ trunk/mod_cluster/test/java/org/jboss/mod_cluster/TestBase.java 2009-01-27 21:32:36 UTC (rev 2228)
@@ -49,6 +49,8 @@
JBossWeb service = null;
JBossWeb service2 = null;
LifecycleListener cluster = null;
+
+ System.out.println("TestBase Started");
try {
// server = (StandardServer) ServerFactory.getServer();
@@ -64,7 +66,7 @@
server.addLifecycleListener(cluster);
// Debug Stuff
- Maintest.listServices();
+ // Maintest.listServices();
} catch(IOException ex) {
ex.printStackTrace();
@@ -125,6 +127,7 @@
// Wait until httpd as received the stop messages.
countinfo = 0;
+ nodes = null;
while ((!Maintest.checkProxyInfo(cluster, nodes)) && countinfo < 20) {
try {
Thread.sleep(3000);
@@ -134,5 +137,6 @@
countinfo++;
}
System.gc();
+ System.out.println("TestBase Done");
}
}
Modified: trunk/mod_cluster/test/java/org/jboss/mod_cluster/TestFailover.java
===================================================================
--- trunk/mod_cluster/test/java/org/jboss/mod_cluster/TestFailover.java 2009-01-27 21:18:44 UTC (rev 2227)
+++ trunk/mod_cluster/test/java/org/jboss/mod_cluster/TestFailover.java 2009-01-27 21:32:36 UTC (rev 2228)
@@ -53,6 +53,7 @@
Connector connector = null;
Connector connector2 = null;
LifecycleListener cluster = null;
+ System.out.println("TestFailover Started");
try {
// server = (StandardServer) ServerFactory.getServer();
@@ -66,7 +67,7 @@
cluster = Maintest.createClusterListener("232.0.0.2", 23364, false, "dom1");
server.addLifecycleListener(cluster);
- Maintest.listServices();
+ // Maintest.listServices();
} catch(IOException ex) {
ex.printStackTrace();
@@ -143,14 +144,14 @@
}
// Wait until httpd as received the stop messages.
- try {
- Thread.sleep(5000);
- } catch (InterruptedException ex) {
- ex.printStackTrace();
- }
+ Maintest.TestForNodes(cluster, null);
// Test client result.
if (clienterror)
fail("Client test failed");
+
+ Maintest.testPort(8009);
+ Maintest.testPort(8010);
+ System.out.println("TestFailover Done");
}
}
Modified: trunk/mod_cluster/test/java/org/jboss/mod_cluster/TestStickyForce.java
===================================================================
--- trunk/mod_cluster/test/java/org/jboss/mod_cluster/TestStickyForce.java 2009-01-27 21:18:44 UTC (rev 2227)
+++ trunk/mod_cluster/test/java/org/jboss/mod_cluster/TestStickyForce.java 2009-01-27 21:32:36 UTC (rev 2228)
@@ -53,6 +53,7 @@
Connector connector = null;
Connector connector2 = null;
LifecycleListener cluster = null;
+ System.out.println("TestStickyForce Started");
try {
// server = (StandardServer) ServerFactory.getServer();
@@ -66,7 +67,7 @@
cluster = Maintest.createClusterListener("232.0.0.2", 23364, false);
server.addLifecycleListener(cluster);
- Maintest.listServices();
+ // Maintest.listServices();
} catch(IOException ex) {
ex.printStackTrace();
@@ -105,11 +106,14 @@
// Stop the connector that has received the request...
String node = client.getnode();
+ int port;
if ("sticky4".equals(node)) {
connector = connector2;
node = "sticky3";
+ port = 8010;
} else {
node = "sticky4";
+ port = 8009;
}
if (connector != null) {
try {
@@ -161,9 +165,16 @@
}
countinfo++;
}
+ if (countinfo == 30) {
+ System.out.println("Can't stop...");
+ }
+ Maintest.testPort(8009);
+ Maintest.testPort(8010);
+
// Test client result.
if ( !clienterror && client.httpResponseCode != 503 )
fail("Client test should have failed");
+ System.out.println("TestStickyForce Done");
}
}
Modified: trunk/mod_cluster/test/java/org/jboss/mod_cluster/TestStickyRemove.java
===================================================================
--- trunk/mod_cluster/test/java/org/jboss/mod_cluster/TestStickyRemove.java 2009-01-27 21:18:44 UTC (rev 2227)
+++ trunk/mod_cluster/test/java/org/jboss/mod_cluster/TestStickyRemove.java 2009-01-27 21:32:36 UTC (rev 2228)
@@ -53,6 +53,7 @@
Connector connector = null;
Connector connector2 = null;
LifecycleListener cluster = null;
+ System.out.println("TestStickyRemove Started");
try {
// server = (StandardServer) ServerFactory.getServer();
@@ -66,7 +67,7 @@
cluster = Maintest.createClusterListener("232.0.0.2", 23364, false, null, true, true, false);
server.addLifecycleListener(cluster);
- Maintest.listServices();
+ // Maintest.listServices();
} catch(IOException ex) {
ex.printStackTrace();
@@ -155,5 +156,6 @@
fail("Client test failed");
if (client.requestedSessionId != null)
fail("Client client received a sessionid");
+ System.out.println("TestStickyRemove Done");
}
}
15 years, 11 months
JBoss Native SVN: r2227 - trunk/mod_cluster/test/java/org/jboss/mod_cluster.
by jbossnative-commits@lists.jboss.org
Author: jfrederic.clere(a)jboss.com
Date: 2009-01-27 16:18:44 -0500 (Tue, 27 Jan 2009)
New Revision: 2227
Modified:
trunk/mod_cluster/test/java/org/jboss/mod_cluster/NodeInfo.java
Log:
Arrange trace message.
Modified: trunk/mod_cluster/test/java/org/jboss/mod_cluster/NodeInfo.java
===================================================================
--- trunk/mod_cluster/test/java/org/jboss/mod_cluster/NodeInfo.java 2009-01-27 21:13:18 UTC (rev 2226)
+++ trunk/mod_cluster/test/java/org/jboss/mod_cluster/NodeInfo.java 2009-01-27 21:18:44 UTC (rev 2227)
@@ -67,7 +67,7 @@
}
}
if (!hasit) {
- System.out.println("Name " + nodenames[i] + "not found!!!");
+ System.out.println("Name " + nodenames[i] + " not found!!!");
return false; // not found.
}
}
15 years, 11 months
JBoss Native SVN: r2226 - trunk/mod_cluster/native/mod_manager.
by jbossnative-commits@lists.jboss.org
Author: jfrederic.clere(a)jboss.com
Date: 2009-01-27 16:13:18 -0500 (Tue, 27 Jan 2009)
New Revision: 2226
Modified:
trunk/mod_cluster/native/mod_manager/mod_manager.c
Log:
Fix the remove node logic: remove context and vhost too.
Modified: trunk/mod_cluster/native/mod_manager/mod_manager.c
===================================================================
--- trunk/mod_cluster/native/mod_manager/mod_manager.c 2009-01-27 18:15:24 UTC (rev 2225)
+++ trunk/mod_cluster/native/mod_manager/mod_manager.c 2009-01-27 21:13:18 UTC (rev 2226)
@@ -52,7 +52,7 @@
#include "sessionid.h"
#define DEFMAXCONTEXT 100
-#define DEFMAXNODE 10
+#define DEFMAXNODE 20
#define DEFMAXHOST 20
#define DEFMAXSESSIONID 512
#define MAXMESSSIZE 1024
@@ -525,7 +525,44 @@
/* All other fields can be modified without causing problems */
return -1;
}
+/*
+ * Remove host and context belonging to the node
+ */
+static void remove_host_context(request_rec *r, int node)
+{
+ /* for read the hosts */
+ int i,j;
+ int size = get_max_size_host(hoststatsmem);
+ int *id = apr_palloc(r->pool, sizeof(int) * size);
+ int sizecontext = get_max_size_context(contextstatsmem);
+ int *idcontext = apr_palloc(r->pool, sizeof(int) * sizecontext);
+
+ ap_log_error(APLOG_MARK, APLOG_DEBUG, 0, r->server,
+ "remove_host_context processing node: %d", node);
+
+ size = get_ids_used_host(hoststatsmem, id);
+ for (i=0; i<size; i++) {
+ hostinfo_t *ou;
+ int sizecontext;
+ int *idcontext;
+
+ if (get_host(hoststatsmem, &ou, id[i]) != APR_SUCCESS)
+ continue;
+ if (ou->node == node)
+ remove_host(hoststatsmem, ou);
+ }
+
+ sizecontext = get_ids_used_context(contextstatsmem, idcontext);
+ for (i=0; i<sizecontext; i++) {
+ contextinfo_t *context;
+ if (get_context(contextstatsmem, &context, idcontext[i]) != APR_SUCCESS)
+ continue;
+ if (context->node == node)
+ remove_context(contextstatsmem, context);
+ }
+}
+
/*
* Process a CONFIG message
* Balancer: <Balancer name>
@@ -757,6 +794,7 @@
strcpy(node->mess.JVMRoute, "REMOVED");
node->mess.remove = 1;
insert_update_node(nodestatsmem, node, &id);
+ remove_host_context(r, node->mess.id);
*errtype = TYPEMEM;
return MNODERM;
}
15 years, 11 months
JBoss Native SVN: r2225 - in trunk/mod_cluster/src: main/java/org/jboss/modcluster/ha and 5 other directories.
by jbossnative-commits@lists.jboss.org
Author: pferraro
Date: 2009-01-27 13:15:24 -0500 (Tue, 27 Jan 2009)
New Revision: 2225
Modified:
trunk/mod_cluster/src/main/java/org/jboss/modcluster/AbstractModClusterService.java
trunk/mod_cluster/src/main/java/org/jboss/modcluster/DefaultJBossWebEventHandler.java
trunk/mod_cluster/src/main/java/org/jboss/modcluster/JBossWebEventHandler.java
trunk/mod_cluster/src/main/java/org/jboss/modcluster/JBossWebEventHandlerAdapter.java
trunk/mod_cluster/src/main/java/org/jboss/modcluster/ha/HAModClusterService.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/mcmp/ResetRequestSource.java
trunk/mod_cluster/src/main/java/org/jboss/modcluster/mcmp/impl/ResetRequestSourceImpl.java
trunk/mod_cluster/src/test/java/org/jboss/modcluster/DefaultJBossWebEventHandlerTestCase.java
trunk/mod_cluster/src/test/java/org/jboss/modcluster/JBossWebEventHandlerAdapterTestCase.java
trunk/mod_cluster/src/test/java/org/jboss/modcluster/ha/HASingletonAwareResetRequestSourceTestCase.java
trunk/mod_cluster/src/test/java/org/jboss/modcluster/mcmp/ResetRequestSourceTestCase.java
Log:
Added init(...) to ResetRequestSource - eliminating need for HASingletonAwareResetRequestSource.setServer(...)
ResetRequestSource inits with server and context exclusion map - so this is only parsed once.
Unit tests all pass now.
Modified: trunk/mod_cluster/src/main/java/org/jboss/modcluster/AbstractModClusterService.java
===================================================================
--- trunk/mod_cluster/src/main/java/org/jboss/modcluster/AbstractModClusterService.java 2009-01-27 16:17:30 UTC (rev 2224)
+++ trunk/mod_cluster/src/main/java/org/jboss/modcluster/AbstractModClusterService.java 2009-01-27 18:15:24 UTC (rev 2225)
@@ -32,6 +32,7 @@
import org.jboss.modcluster.mcmp.MCMPHandler;
import org.jboss.modcluster.mcmp.MCMPRequest;
import org.jboss.modcluster.mcmp.MCMPRequestFactory;
+import org.jboss.modcluster.mcmp.ResetRequestSource;
import org.jboss.modcluster.mcmp.impl.DefaultMCMPHandler;
import org.jboss.modcluster.mcmp.impl.DefaultMCMPRequestFactory;
import org.jboss.modcluster.mcmp.impl.ResetRequestSourceImpl;
@@ -50,10 +51,13 @@
public AbstractModClusterService()
{
this.requestFactory = new DefaultMCMPRequestFactory();
- this.mcmpHandler = new DefaultMCMPHandler(this, new ResetRequestSourceImpl(this, this, this, this.requestFactory), this.requestFactory);
- JBossWebEventHandler eventHandler = new DefaultJBossWebEventHandler(this, this, this, this.mcmpHandler, this.requestFactory, this, new AdvertiseListenerFactoryImpl());
+ ResetRequestSource source = new ResetRequestSourceImpl(this, this, this.requestFactory);
+ this.mcmpHandler = new DefaultMCMPHandler(this, source, this.requestFactory);
+
+ JBossWebEventHandler eventHandler = new DefaultJBossWebEventHandler(this, this, this, this.mcmpHandler, source, this.requestFactory, this, new AdvertiseListenerFactoryImpl());
+
this.lifecycleListener = new JBossWebEventHandlerAdapter(eventHandler);
}
Modified: trunk/mod_cluster/src/main/java/org/jboss/modcluster/DefaultJBossWebEventHandler.java
===================================================================
--- trunk/mod_cluster/src/main/java/org/jboss/modcluster/DefaultJBossWebEventHandler.java 2009-01-27 16:17:30 UTC (rev 2224)
+++ trunk/mod_cluster/src/main/java/org/jboss/modcluster/DefaultJBossWebEventHandler.java 2009-01-27 18:15:24 UTC (rev 2225)
@@ -45,6 +45,7 @@
import org.jboss.modcluster.mcmp.MCMPHandler;
import org.jboss.modcluster.mcmp.MCMPRequest;
import org.jboss.modcluster.mcmp.MCMPRequestFactory;
+import org.jboss.modcluster.mcmp.ResetRequestSource;
/**
* Default implementation of {@link JBossWebEventHandler}.
@@ -65,24 +66,27 @@
private final BalancerConfiguration balancerConfig;
private final MCMPHandlerConfiguration mcmpConfig;
private final MCMPHandler mcmpHandler;
+ private final ResetRequestSource source;
private final MCMPRequestFactory requestFactory;
private final AdvertiseListenerFactory listenerFactory;
private final LoadBalanceFactorProviderFactory loadBalanceFactorProviderFactory;
private volatile boolean init;
- private LoadBalanceFactorProvider loadBalanceFactorProvider;
- private AdvertiseListener advertiseListener;
- private Map<String, Set<String>> excludedContextPaths;
+ private volatile LoadBalanceFactorProvider loadBalanceFactorProvider;
+ private volatile AdvertiseListener advertiseListener;
+ private volatile Map<String, Set<String>> excludedContextPaths;
public DefaultJBossWebEventHandler(NodeConfiguration nodeConfig, BalancerConfiguration balancerConfig,
- MCMPHandlerConfiguration mcmpConfig, MCMPHandler mcmpHandler, MCMPRequestFactory requestFactory,
- LoadBalanceFactorProviderFactory loadBalanceFactorProviderFactory, AdvertiseListenerFactory listenerFactory)
+ MCMPHandlerConfiguration mcmpConfig, MCMPHandler mcmpHandler, ResetRequestSource source,
+ MCMPRequestFactory requestFactory, LoadBalanceFactorProviderFactory loadBalanceFactorProviderFactory,
+ AdvertiseListenerFactory listenerFactory)
{
this.nodeConfig = nodeConfig;
this.balancerConfig = balancerConfig;
this.mcmpConfig = mcmpConfig;
this.mcmpHandler = mcmpHandler;
+ this.source = source;
this.requestFactory = requestFactory;
this.loadBalanceFactorProviderFactory = loadBalanceFactorProviderFactory;
this.listenerFactory = listenerFactory;
@@ -90,13 +94,16 @@
// ---------------------------------------------------- JBossWebEventHandler
- public synchronized void init()
+ public synchronized void init(Server server)
{
List<InetSocketAddress> initialProxies = Utils.parseProxies(this.mcmpConfig.getProxyList());
+
this.mcmpHandler.init(initialProxies);
this.excludedContextPaths = Utils.parseContexts(this.mcmpConfig.getExcludedContexts());
+ this.source.init(server, this.excludedContextPaths);
+
this.loadBalanceFactorProvider = this.loadBalanceFactorProviderFactory.createLoadBalanceFactorProvider();
Boolean advertise = this.mcmpConfig.getAdvertise();
@@ -138,7 +145,6 @@
}
this.mcmpHandler.shutdown();
- this.excludedContextPaths.clear();
}
/**
@@ -228,7 +234,6 @@
if (!this.exclude(context))
{
- log.info(context.getParent().getName() + ":" + context.getPath() + " is *not* exluded.");
// Send ENABLE-APP if state is started
if (Utils.isContextStarted(context))
{
Modified: trunk/mod_cluster/src/main/java/org/jboss/modcluster/JBossWebEventHandler.java
===================================================================
--- trunk/mod_cluster/src/main/java/org/jboss/modcluster/JBossWebEventHandler.java 2009-01-27 16:17:30 UTC (rev 2224)
+++ trunk/mod_cluster/src/main/java/org/jboss/modcluster/JBossWebEventHandler.java 2009-01-27 18:15:24 UTC (rev 2225)
@@ -32,7 +32,8 @@
*/
public interface JBossWebEventHandler
{
- void init();
+ void init(Server server);
+
void shutdown();
void addContext(Context context);
Modified: trunk/mod_cluster/src/main/java/org/jboss/modcluster/JBossWebEventHandlerAdapter.java
===================================================================
--- trunk/mod_cluster/src/main/java/org/jboss/modcluster/JBossWebEventHandlerAdapter.java 2009-01-27 16:17:30 UTC (rev 2224)
+++ trunk/mod_cluster/src/main/java/org/jboss/modcluster/JBossWebEventHandlerAdapter.java 2009-01-27 18:15:24 UTC (rev 2225)
@@ -119,10 +119,10 @@
{
if (source instanceof Server)
{
- this.eventHandler.init();
-
Server server = (Server) source;
+ this.eventHandler.init(server);
+
this.addListeners(server);
this.eventHandler.startServer(server);
Modified: trunk/mod_cluster/src/main/java/org/jboss/modcluster/ha/HAModClusterService.java
===================================================================
--- trunk/mod_cluster/src/main/java/org/jboss/modcluster/ha/HAModClusterService.java 2009-01-27 16:17:30 UTC (rev 2224)
+++ trunk/mod_cluster/src/main/java/org/jboss/modcluster/ha/HAModClusterService.java 2009-01-27 18:15:24 UTC (rev 2225)
@@ -36,7 +36,6 @@
import org.apache.catalina.Engine;
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.util.StringManager;
@@ -159,11 +158,11 @@
this.loadBalanceFactorProvider = loadFactorProvider;
this.requestFactory = new DefaultMCMPRequestFactory();
- this.resetRequestSource = new HASingletonAwareResetRequestSourceImpl(config, config, config, this.requestFactory, this, this);
+ this.resetRequestSource = new HASingletonAwareResetRequestSourceImpl(config, config, this.requestFactory, this, this);
this.localHandler = new DefaultMCMPHandler(config, this.resetRequestSource, this.requestFactory);
this.clusteredHandler = new ClusteredMCMPHandlerImpl(this.localHandler, this, this);
- JBossWebEventHandler eventHandler = new ClusteredJBossWebEventHandler(config, config, config, this.clusteredHandler, this.requestFactory, this, new AdvertiseListenerFactoryImpl());
+ JBossWebEventHandler eventHandler = new ClusteredJBossWebEventHandler(config, config, config, this.clusteredHandler, this.resetRequestSource, this.requestFactory, this, new AdvertiseListenerFactoryImpl());
this.lifecycleListener = new JBossWebEventHandlerAdapter(eventHandler);
@@ -728,21 +727,13 @@
* @param loadFactorProvider
*/
public ClusteredJBossWebEventHandler(NodeConfiguration nodeConfig, BalancerConfiguration balancerConfig,
- MCMPHandlerConfiguration mcmpConfig, MCMPHandler clusteredHandler, MCMPRequestFactory requestFactory,
- LoadBalanceFactorProviderFactory loadFactorProviderFactory, AdvertiseListenerFactory listenerFactory)
+ MCMPHandlerConfiguration mcmpConfig, MCMPHandler clusteredHandler, ResetRequestSource source,
+ MCMPRequestFactory requestFactory, LoadBalanceFactorProviderFactory loadFactorProviderFactory,
+ AdvertiseListenerFactory listenerFactory)
{
- super(nodeConfig, balancerConfig, mcmpConfig, clusteredHandler, requestFactory, loadFactorProviderFactory, listenerFactory);
+ super(nodeConfig, balancerConfig, mcmpConfig, clusteredHandler, source, requestFactory, loadFactorProviderFactory, listenerFactory);
}
-
- @Override
- public void startServer(Server server)
- {
- // Pass on ref to our server
- this.coord.resetRequestSource.setJbossWebServer(server);
- super.startServer(server);
- }
-
@Override
protected void config(Engine engine)
{
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 2009-01-27 16:17:30 UTC (rev 2224)
+++ trunk/mod_cluster/src/main/java/org/jboss/modcluster/ha/HASingletonAwareResetRequestSource.java 2009-01-27 18:15:24 UTC (rev 2225)
@@ -25,7 +25,6 @@
import java.util.Map;
import java.util.Set;
-import org.apache.catalina.Server;
import org.jboss.modcluster.mcmp.MCMPRequest;
import org.jboss.modcluster.mcmp.ResetRequestSource;
@@ -36,6 +35,4 @@
public interface HASingletonAwareResetRequestSource extends ResetRequestSource
{
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 2009-01-27 16:17:30 UTC (rev 2224)
+++ trunk/mod_cluster/src/main/java/org/jboss/modcluster/ha/HASingletonAwareResetRequestSourceImpl.java 2009-01-27 18:15:24 UTC (rev 2225)
@@ -22,13 +22,11 @@
package org.jboss.modcluster.ha;
-import java.util.ArrayList;
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;
import org.jboss.ha.framework.interfaces.HAServiceKeyProvider;
import org.jboss.ha.framework.interfaces.HASingletonMBean;
@@ -36,7 +34,6 @@
import org.jboss.modcluster.Constants;
import org.jboss.modcluster.Utils;
import org.jboss.modcluster.config.BalancerConfiguration;
-import org.jboss.modcluster.config.MCMPHandlerConfiguration;
import org.jboss.modcluster.config.NodeConfiguration;
import org.jboss.modcluster.ha.rpc.ResetRequestGroupRpcResponse;
import org.jboss.modcluster.ha.rpc.ResetRequestSourceRpcHandler;
@@ -68,11 +65,9 @@
private final HASingletonMBean singleton;
private final ResetRequestSourceRpcHandler<List<?>> rpcStub;
- private volatile Server server;
-
- public HASingletonAwareResetRequestSourceImpl(NodeConfiguration nodeConfig, BalancerConfiguration balancerConfig, MCMPHandlerConfiguration mcmpConfig, MCMPRequestFactory requestFactory, HASingletonMBean singleton, HAServiceKeyProvider serviceKeyProvider)
+ public HASingletonAwareResetRequestSourceImpl(NodeConfiguration nodeConfig, BalancerConfiguration balancerConfig, MCMPRequestFactory requestFactory, HASingletonMBean singleton, HAServiceKeyProvider serviceKeyProvider)
{
- super(nodeConfig, balancerConfig, mcmpConfig, requestFactory);
+ super(nodeConfig, balancerConfig, requestFactory);
this.singleton = singleton;
this.rpcStub = new RpcStub(serviceKeyProvider);
@@ -97,22 +92,8 @@
*/
public List<MCMPRequest> getLocalResetRequests(Map<String, Set<VirtualHost>> response)
{
- if (this.server == null)
- {
- return new ArrayList<MCMPRequest>();
- }
-
- return super.getResetRequests(response, this.server);
+ return super.getResetRequests(response);
}
-
- /**
- * @{inheritDoc}
- * @see org.jboss.modcluster.ha.HASingletonAwareResetRequestSource#setJbossWebServer(org.apache.catalina.Server)
- */
- public void setJbossWebServer(Server server)
- {
- this.server = server;
- }
private void addRemoteRequests(List<MCMPRequest> resets, Map<String, Set<VirtualHost>> resp)
{
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 2009-01-27 16:17:30 UTC (rev 2224)
+++ trunk/mod_cluster/src/main/java/org/jboss/modcluster/mcmp/ResetRequestSource.java 2009-01-27 18:15:24 UTC (rev 2225)
@@ -27,6 +27,8 @@
import java.util.Map;
import java.util.Set;
+import org.apache.catalina.Server;
+
/**
* Source for a list of requests that should be sent to an httpd-side
* mod_cluster instance when an {@link MCMPHandler} determines that
@@ -48,6 +50,8 @@
Map<String, Status> getContexts();
}
+ void init(Server server, Map<String, Set<String>> excludedContexts);
+
/**
* Gets a list of requests that should be sent to an httpd-side
* mod_cluster instance when an {@link MCMPHandler} determines that
Modified: 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 2009-01-27 16:17:30 UTC (rev 2224)
+++ trunk/mod_cluster/src/main/java/org/jboss/modcluster/mcmp/impl/ResetRequestSourceImpl.java 2009-01-27 18:15:24 UTC (rev 2225)
@@ -34,11 +34,9 @@
import org.apache.catalina.Engine;
import org.apache.catalina.Host;
import org.apache.catalina.Server;
-import org.apache.catalina.ServerFactory;
import org.apache.catalina.Service;
import org.jboss.modcluster.Utils;
import org.jboss.modcluster.config.BalancerConfiguration;
-import org.jboss.modcluster.config.MCMPHandlerConfiguration;
import org.jboss.modcluster.config.NodeConfiguration;
import org.jboss.modcluster.mcmp.MCMPRequest;
import org.jboss.modcluster.mcmp.MCMPRequestFactory;
@@ -53,35 +51,41 @@
{
private final NodeConfiguration nodeConfig;
private final BalancerConfiguration balancerConfig;
- private final MCMPHandlerConfiguration mcmpConfig;
private final MCMPRequestFactory requestFactory;
- public ResetRequestSourceImpl(NodeConfiguration nodeConfig, BalancerConfiguration balancerConfig, MCMPHandlerConfiguration mcmpConfig, MCMPRequestFactory requestFactory)
+ private volatile Server server;
+ private volatile Map<String, Set<String>> excludedContexts;
+
+ public ResetRequestSourceImpl(NodeConfiguration nodeConfig, BalancerConfiguration balancerConfig, MCMPRequestFactory requestFactory)
{
this.nodeConfig = nodeConfig;
this.balancerConfig = balancerConfig;
- this.mcmpConfig = mcmpConfig;
this.requestFactory = requestFactory;
}
/**
* @{inheritDoc}
+ * @see org.jboss.modcluster.mcmp.ResetRequestSource#init(java.util.Map)
+ */
+ public void init(Server server, Map<String, Set<String>> excludedContexts)
+ {
+ this.server = server;
+ this.excludedContexts = excludedContexts;
+ }
+
+ /**
+ * @{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)
- {
- // TODO This is a hack - we shouldn't have to parse the exclusion list every time
- Map<String, Set<String>> excludedContexts = Utils.parseContexts(this.mcmpConfig.getExcludedContexts());
+ List<MCMPRequest> requests = new ArrayList<MCMPRequest>();
- List<MCMPRequest> requests = new ArrayList<MCMPRequest>();
+ if (this.server == null) return requests;
+
List<MCMPRequest> engineRequests = new LinkedList<MCMPRequest>();
- for (Service service: server.findServices())
+ for (Service service: this.server.findServices())
{
Engine engine = (Engine) service.getContainer();
@@ -137,7 +141,7 @@
Context context = (Context) container;
String path = context.getPath();
- Set<String> excludedPaths = excludedContexts.get(hostName);
+ Set<String> excludedPaths = this.excludedContexts.get(hostName);
if ((excludedPaths != null) && excludedPaths.contains(path))
{
Modified: trunk/mod_cluster/src/test/java/org/jboss/modcluster/DefaultJBossWebEventHandlerTestCase.java
===================================================================
--- trunk/mod_cluster/src/test/java/org/jboss/modcluster/DefaultJBossWebEventHandlerTestCase.java 2009-01-27 16:17:30 UTC (rev 2224)
+++ trunk/mod_cluster/src/test/java/org/jboss/modcluster/DefaultJBossWebEventHandlerTestCase.java 2009-01-27 18:15:24 UTC (rev 2225)
@@ -26,6 +26,7 @@
import java.net.InetSocketAddress;
import java.util.Collections;
import java.util.List;
+import java.util.Map;
import java.util.Set;
import org.apache.catalina.Container;
@@ -35,6 +36,7 @@
import org.apache.catalina.Server;
import org.apache.catalina.Service;
import org.apache.catalina.connector.Connector;
+import org.easymock.Capture;
import org.easymock.EasyMock;
import org.jboss.modcluster.advertise.AdvertiseListener;
import org.jboss.modcluster.advertise.AdvertiseListenerFactory;
@@ -47,6 +49,7 @@
import org.jboss.modcluster.mcmp.MCMPRequest;
import org.jboss.modcluster.mcmp.MCMPRequestFactory;
import org.jboss.modcluster.mcmp.MCMPServerState;
+import org.jboss.modcluster.mcmp.ResetRequestSource;
import org.junit.Assert;
import org.junit.Before;
import org.junit.Test;
@@ -62,6 +65,7 @@
private final BalancerConfiguration balancerConfig = EasyMock.createStrictMock(BalancerConfiguration.class);
private final MCMPHandlerConfiguration mcmpConfig = EasyMock.createStrictMock(MCMPHandlerConfiguration.class);
private final MCMPHandler mcmpHandler = EasyMock.createStrictMock(MCMPHandler.class);
+ private final ResetRequestSource source = EasyMock.createStrictMock(ResetRequestSource.class);
private final MCMPRequestFactory requestFactory = EasyMock.createStrictMock(MCMPRequestFactory.class);
private final LoadBalanceFactorProviderFactory lbfProviderFactory = EasyMock.createStrictMock(LoadBalanceFactorProviderFactory.class);
private final LoadBalanceFactorProvider lbfProvider = EasyMock.createStrictMock(LoadBalanceFactorProvider.class);
@@ -73,14 +77,16 @@
@Before
public void construct() throws Exception
{
- this.handler = new DefaultJBossWebEventHandler(this.nodeConfig, this.balancerConfig, this.mcmpConfig, this.mcmpHandler, this.requestFactory, this.lbfProviderFactory, this.listenerFactory);
+ this.handler = new DefaultJBossWebEventHandler(this.nodeConfig, this.balancerConfig, this.mcmpConfig, this.mcmpHandler, this.source, this.requestFactory, this.lbfProviderFactory, this.listenerFactory);
}
@Test
public void initNoAdvertise() throws IOException
{
+ Server server = EasyMock.createStrictMock(Server.class);
InetAddress localAddress = InetAddress.getLocalHost();
String localHostName = localAddress.getHostName();
+ Map<String, Set<String>> emptyContextMap = Collections.emptyMap();
// Test advertise = false
EasyMock.expect(this.mcmpConfig.getProxyList()).andReturn(localHostName);
@@ -89,23 +95,27 @@
EasyMock.expect(this.mcmpConfig.getExcludedContexts()).andReturn(null);
+ this.source.init(server, emptyContextMap);
+
EasyMock.expect(this.lbfProviderFactory.createLoadBalanceFactorProvider()).andReturn(this.lbfProvider);
EasyMock.expect(this.mcmpConfig.getAdvertise()).andReturn(Boolean.FALSE);
- EasyMock.replay(this.mcmpHandler, this.mcmpConfig, this.lbfProviderFactory);
+ EasyMock.replay(this.mcmpHandler, this.mcmpConfig, this.lbfProviderFactory, this.source);
- this.handler.init();
+ this.handler.init(server);
- EasyMock.verify(this.mcmpHandler, this.mcmpConfig, this.lbfProviderFactory);
- EasyMock.reset(this.mcmpHandler, this.mcmpConfig, this.lbfProviderFactory);
+ EasyMock.verify(this.mcmpHandler, this.mcmpConfig, this.lbfProviderFactory, this.source);
+ EasyMock.reset(this.mcmpHandler, this.mcmpConfig, this.lbfProviderFactory, this.source);
}
@Test
public void initAdvertise() throws IOException
{
+ Server server = EasyMock.createStrictMock(Server.class);
InetAddress localAddress = InetAddress.getLocalHost();
String localHostName = localAddress.getHostName();
+ Map<String, Set<String>> emptyContextMap = Collections.emptyMap();
// Test advertise = true
EasyMock.expect(this.mcmpConfig.getProxyList()).andReturn(localHostName);
@@ -114,6 +124,8 @@
EasyMock.expect(this.mcmpConfig.getExcludedContexts()).andReturn("");
+ this.source.init(server, emptyContextMap);
+
EasyMock.expect(this.lbfProviderFactory.createLoadBalanceFactorProvider()).andReturn(this.lbfProvider);
EasyMock.expect(this.mcmpConfig.getAdvertise()).andReturn(Boolean.TRUE);
@@ -122,17 +134,18 @@
this.listener.start();
- EasyMock.replay(this.mcmpHandler, this.listenerFactory, this.mcmpConfig, this.lbfProviderFactory, this.listener);
+ EasyMock.replay(this.mcmpHandler, this.listenerFactory, this.mcmpConfig, this.lbfProviderFactory, this.listener, this.source);
- this.handler.init();
+ this.handler.init(server);
- EasyMock.verify(this.mcmpHandler, this.listenerFactory, this.mcmpConfig, this.lbfProviderFactory, this.listener);
- EasyMock.reset(this.mcmpHandler, this.listenerFactory, this.mcmpConfig, this.lbfProviderFactory, this.listener);
+ EasyMock.verify(this.mcmpHandler, this.listenerFactory, this.mcmpConfig, this.lbfProviderFactory, this.listener, this.source);
+ EasyMock.reset(this.mcmpHandler, this.listenerFactory, this.mcmpConfig, this.lbfProviderFactory, this.listener, this.source);
}
@Test
public void init() throws IOException
{
+ Server server = EasyMock.createStrictMock(Server.class);
InetAddress localAddress = InetAddress.getLocalHost();
String localHostName = localAddress.getHostName();
@@ -143,13 +156,15 @@
EasyMock.expect(this.mcmpConfig.getExcludedContexts()).andReturn("ignored");
+ this.source.init(server, Collections.singletonMap("localhost", Collections.singleton("/ignored")));
+
EasyMock.expect(this.lbfProviderFactory.createLoadBalanceFactorProvider()).andReturn(this.lbfProvider);
EasyMock.expect(this.mcmpConfig.getAdvertise()).andReturn(null);
EasyMock.replay(this.mcmpHandler, this.mcmpConfig, this.lbfProviderFactory);
- this.handler.init();
+ this.handler.init(server);
EasyMock.verify(this.mcmpHandler, this.mcmpConfig, this.lbfProviderFactory);
EasyMock.reset(this.mcmpHandler, this.mcmpConfig, this.lbfProviderFactory);
@@ -158,15 +173,19 @@
@Test
public void initNoProxies() throws IOException
{
+ Server server = EasyMock.createStrictMock(Server.class);
// Test advertise = null, no proxies configured
EasyMock.expect(this.mcmpConfig.getProxyList()).andReturn(null);
+ Capture<Map<String, Set<String>>> capturedMap = new Capture<Map<String, Set<String>>>();
List<InetSocketAddress> emptyList = Collections.emptyList();
this.mcmpHandler.init(emptyList);
- EasyMock.expect(this.mcmpConfig.getExcludedContexts()).andReturn("ignored,ROOT");
+ EasyMock.expect(this.mcmpConfig.getExcludedContexts()).andReturn("host1:ignored,ROOT");
+ this.source.init(EasyMock.same(server), EasyMock.capture(capturedMap));
+
EasyMock.expect(this.lbfProviderFactory.createLoadBalanceFactorProvider()).andReturn(this.lbfProvider);
EasyMock.expect(this.mcmpConfig.getAdvertise()).andReturn(null);
@@ -175,12 +194,19 @@
this.listener.start();
- EasyMock.replay(this.mcmpHandler, this.listenerFactory, this.mcmpConfig, this.lbfProviderFactory, this.listener);
+ EasyMock.replay(this.mcmpHandler, this.listenerFactory, this.mcmpConfig, this.lbfProviderFactory, this.listener, this.source);
- this.handler.init();
+ this.handler.init(server);
- EasyMock.verify(this.mcmpHandler, this.listenerFactory, this.mcmpConfig, this.lbfProviderFactory, this.listener);
- EasyMock.reset(this.mcmpHandler, this.listenerFactory, this.mcmpConfig, this.lbfProviderFactory, this.listener);
+ EasyMock.verify(this.mcmpHandler, this.listenerFactory, this.mcmpConfig, this.lbfProviderFactory, this.listener, this.source);
+
+ Map<String, Set<String>> contexts = capturedMap.getValue();
+
+ Assert.assertEquals(2, contexts.size());
+ Assert.assertEquals(Collections.singleton("/ignored"), contexts.get("host1"));
+ Assert.assertEquals(Collections.singleton(""), contexts.get("localhost"));
+
+ EasyMock.reset(this.mcmpHandler, this.listenerFactory, this.mcmpConfig, this.lbfProviderFactory, this.listener, this.source);
}
@Test
@@ -244,17 +270,21 @@
public void addContextIgnored() throws IOException
{
Context context = EasyMock.createStrictMock(Context.class);
+ Host host = EasyMock.createStrictMock(Host.class);
init();
+ // Exclusion check
+ EasyMock.expect(context.getParent()).andReturn(host);
+ EasyMock.expect(host.getName()).andReturn("localhost");
EasyMock.expect(context.getPath()).andReturn("/ignored");
- EasyMock.replay(context);
+ EasyMock.replay(context, host);
this.handler.addContext(context);
- EasyMock.verify(context);
- EasyMock.reset(context);
+ EasyMock.verify(context, host);
+ EasyMock.reset(context, host);
}
@Test
@@ -264,11 +294,10 @@
Host host = EasyMock.createStrictMock(Host.class);
init();
-
- // Test context not started
- EasyMock.expect(context.getPath()).andReturn("/context");
+
+ // Exclusion check
EasyMock.expect(context.getParent()).andReturn(host);
- EasyMock.expect(host.getName()).andReturn("host");
+ EasyMock.expect(host.getName()).andReturn("host1");
EasyMock.expect(context.isStarted()).andReturn(false);
@@ -289,13 +318,18 @@
init();
+ // Exclusion check
+ EasyMock.expect(context.getParent()).andReturn(host);
+ EasyMock.expect(host.getName()).andReturn("localhost");
+ EasyMock.expect(context.getPath()).andReturn("/context");
+
+ EasyMock.expect(context.isStarted()).andReturn(true);
+
// Expect log message
EasyMock.expect(context.getPath()).andReturn("/context");
EasyMock.expect(context.getParent()).andReturn(host);
EasyMock.expect(host.getName()).andReturn("host");
- EasyMock.expect(context.isStarted()).andReturn(true);
-
EasyMock.expect(this.requestFactory.createEnableRequest(context)).andReturn(request);
this.mcmpHandler.sendRequest(request);
@@ -327,25 +361,26 @@
}
EasyMock.verify(context);
- EasyMock.reset(context);
}
@Test
public void startContextIgnored() throws IOException
{
Context context = EasyMock.createStrictMock(Context.class);
+ Host host = EasyMock.createStrictMock(Host.class);
init();
- // Test ignored context
+ // Exclusion check
+ EasyMock.expect(context.getParent()).andReturn(host);
+ EasyMock.expect(host.getName()).andReturn("localhost");
EasyMock.expect(context.getPath()).andReturn("/ignored");
- EasyMock.replay(context);
+ EasyMock.replay(context, host);
this.handler.startContext(context);
- EasyMock.verify(context);
- EasyMock.reset(context);
+ EasyMock.verify(context, host);
}
@Test
@@ -357,6 +392,11 @@
init();
+ // Exclusion check
+ EasyMock.expect(context.getParent()).andReturn(host);
+ EasyMock.expect(host.getName()).andReturn("localhost");
+ EasyMock.expect(context.getPath()).andReturn("/context");
+
// Expect log message
EasyMock.expect(context.getPath()).andReturn("/context");
EasyMock.expect(context.getParent()).andReturn(host);
@@ -393,25 +433,26 @@
}
EasyMock.verify(context);
- EasyMock.reset(context);
}
@Test
public void stopContextIgnored() throws IOException
{
Context context = EasyMock.createStrictMock(Context.class);
+ Host host = EasyMock.createStrictMock(Host.class);
init();
- // Test ignored context
+ // Exclusion check
+ EasyMock.expect(context.getParent()).andReturn(host);
+ EasyMock.expect(host.getName()).andReturn("localhost");
EasyMock.expect(context.getPath()).andReturn("/ignored");
- EasyMock.replay(context);
+ EasyMock.replay(context, host);
this.handler.stopContext(context);
- EasyMock.verify(context);
- EasyMock.reset(context);
+ EasyMock.verify(context, host);
}
@Test
@@ -423,10 +464,15 @@
init();
+ // Exclusion check
+ EasyMock.expect(context.getParent()).andReturn(host);
+ EasyMock.expect(host.getName()).andReturn("localhost");
+ EasyMock.expect(context.getPath()).andReturn("/context");
+
// Expect log message
EasyMock.expect(context.getPath()).andReturn("/context");
EasyMock.expect(context.getParent()).andReturn(host);
- EasyMock.expect(host.getName()).andReturn("host");
+ EasyMock.expect(host.getName()).andReturn("localhost");
EasyMock.expect(this.requestFactory.createStopRequest(context)).andReturn(request);
@@ -459,25 +505,26 @@
}
EasyMock.verify(context);
- EasyMock.reset(context);
}
@Test
public void removeContextIgnored() throws IOException
{
Context context = EasyMock.createStrictMock(Context.class);
+ Host host = EasyMock.createStrictMock(Host.class);
init();
- // Test ignored context
+ // Exclusion check
+ EasyMock.expect(context.getParent()).andReturn(host);
+ EasyMock.expect(host.getName()).andReturn("localhost");
EasyMock.expect(context.getPath()).andReturn("/ignored");
- EasyMock.replay(context);
+ EasyMock.replay(context, host);
this.handler.removeContext(context);
- EasyMock.verify(context);
- EasyMock.reset(context);
+ EasyMock.verify(context, host);
}
@Test
@@ -489,11 +536,10 @@
init();
- // Test initialized - no jvm route
-
+ // Exclusion check
+ EasyMock.expect(context.getParent()).andReturn(host);
+ EasyMock.expect(host.getName()).andReturn("localhost");
EasyMock.expect(context.getPath()).andReturn("/context");
- EasyMock.expect(context.getParent()).andReturn(host);
- EasyMock.expect(host.getName()).andReturn("parent-container");
EasyMock.expect(context.getParent()).andReturn(host);
EasyMock.expect(host.getParent()).andReturn(engine);
@@ -504,7 +550,6 @@
this.handler.removeContext(context);
EasyMock.verify(context, host, engine);
- EasyMock.reset(context, host, engine);
}
@Test
@@ -516,17 +561,22 @@
MCMPRequest request = EasyMock.createStrictMock(MCMPRequest.class);
init();
-
- // Expect log message
+
+ // Exclusion check
+ EasyMock.expect(context.getParent()).andReturn(host);
+ EasyMock.expect(host.getName()).andReturn("localhost");
EasyMock.expect(context.getPath()).andReturn("/context");
- EasyMock.expect(context.getParent()).andReturn(host);
- EasyMock.expect(host.getName()).andReturn("host");
// jvm route null check
EasyMock.expect(context.getParent()).andReturn(host);
EasyMock.expect(host.getParent()).andReturn(engine);
EasyMock.expect(engine.getJvmRoute()).andReturn("host1");
+ // Expect log message
+ EasyMock.expect(context.getPath()).andReturn("/context");
+ EasyMock.expect(context.getParent()).andReturn(host);
+ EasyMock.expect(host.getName()).andReturn("host");
+
EasyMock.expect(this.requestFactory.createRemoveRequest(context)).andReturn(request);
this.mcmpHandler.sendRequest(request);
@@ -643,10 +693,11 @@
EasyMock.expect(engine.findChildren()).andReturn(new Container[] { host });
EasyMock.expect(host.findChildren()).andReturn(new Container[] { context });
-
+
+ // Exclusion check
+ EasyMock.expect(context.getParent()).andReturn(host);
+ EasyMock.expect(host.getName()).andReturn("localhost");
EasyMock.expect(context.getPath()).andReturn("/context");
- EasyMock.expect(context.getParent()).andReturn(host);
- EasyMock.expect(host.getName()).andReturn("host");
EasyMock.expect(context.isStarted()).andReturn(false);
@@ -698,26 +749,31 @@
EasyMock.expect(engine.findChildren()).andReturn(new Container[] { host });
EasyMock.expect(host.findChildren()).andReturn(new Container[] { context });
-
- // Expect log message
+
+ // Exclusion check
+ EasyMock.expect(context.getParent()).andReturn(host);
+ EasyMock.expect(host.getName()).andReturn("localhost");
EasyMock.expect(context.getPath()).andReturn("/context");
- EasyMock.expect(context.getParent()).andReturn(host);
- EasyMock.expect(host.getName()).andReturn("host");
// jvm route null check
EasyMock.expect(context.getParent()).andReturn(host);
EasyMock.expect(host.getParent()).andReturn(engine);
EasyMock.expect(engine.getJvmRoute()).andReturn("host1");
+ // Expect log message
+ EasyMock.expect(context.getPath()).andReturn("/context");
+ EasyMock.expect(context.getParent()).andReturn(host);
+ EasyMock.expect(host.getName()).andReturn("host");
+
EasyMock.expect(this.requestFactory.createRemoveRequest(context)).andReturn(contextRequest);
this.mcmpHandler.sendRequest(contextRequest);
+ EasyMock.expect(engine.getJvmRoute()).andReturn("host1");
+
// Expect log message
EasyMock.expect(engine.getName()).andReturn("engine");
- EasyMock.expect(engine.getJvmRoute()).andReturn("host1");
-
EasyMock.expect(this.requestFactory.createRemoveRequest(engine)).andReturn(engineRequest);
this.mcmpHandler.sendRequest(engineRequest);
Modified: trunk/mod_cluster/src/test/java/org/jboss/modcluster/JBossWebEventHandlerAdapterTestCase.java
===================================================================
--- trunk/mod_cluster/src/test/java/org/jboss/modcluster/JBossWebEventHandlerAdapterTestCase.java 2009-01-27 16:17:30 UTC (rev 2224)
+++ trunk/mod_cluster/src/test/java/org/jboss/modcluster/JBossWebEventHandlerAdapterTestCase.java 2009-01-27 18:15:24 UTC (rev 2225)
@@ -143,7 +143,7 @@
LifecycleEvent event = new LifecycleEvent(server, Lifecycle.AFTER_START_EVENT);
- this.eventHandler.init();
+ this.eventHandler.init(server);
EasyMock.expect(server.findServices()).andReturn(new Service[] { service });
EasyMock.expect(service.getContainer()).andReturn(engine);
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 2009-01-27 16:17:30 UTC (rev 2224)
+++ trunk/mod_cluster/src/test/java/org/jboss/modcluster/ha/HASingletonAwareResetRequestSourceTestCase.java 2009-01-27 18:15:24 UTC (rev 2225)
@@ -40,7 +40,6 @@
import org.jboss.ha.framework.interfaces.HAServiceKeyProvider;
import org.jboss.ha.framework.interfaces.HASingletonMBean;
import org.jboss.modcluster.config.BalancerConfiguration;
-import org.jboss.modcluster.config.MCMPHandlerConfiguration;
import org.jboss.modcluster.config.NodeConfiguration;
import org.jboss.modcluster.ha.rpc.ResetRequestGroupRpcResponse;
import org.jboss.modcluster.mcmp.MCMPRequest;
@@ -58,7 +57,6 @@
{
private NodeConfiguration nodeConfig = EasyMock.createStrictMock(NodeConfiguration.class);
private BalancerConfiguration balancerConfig = EasyMock.createStrictMock(BalancerConfiguration.class);
- private MCMPHandlerConfiguration mcmpConfig = EasyMock.createStrictMock(MCMPHandlerConfiguration.class);
private HAServiceKeyProvider key = EasyMock.createStrictMock(HAServiceKeyProvider.class);
private HASingletonMBean singleton = EasyMock.createStrictMock(HASingletonMBean.class);
private HAPartition partition = EasyMock.createStrictMock(HAPartition.class);
@@ -67,7 +65,7 @@
@Test
public void getResetRequestsNonMaster()
{
- HASingletonAwareResetRequestSource source = new HASingletonAwareResetRequestSourceImpl(this.nodeConfig, this.balancerConfig, this.mcmpConfig, this.requestFactory, this.singleton, this.key);
+ HASingletonAwareResetRequestSource source = new HASingletonAwareResetRequestSourceImpl(this.nodeConfig, this.balancerConfig, this.requestFactory, this.singleton, this.key);
EasyMock.expect(this.singleton.isMasterNode()).andReturn(false);
@@ -85,9 +83,9 @@
}
@Test
- public void getResetRequestsNoServer() throws Exception
+ public void getResetRequestsNoInit() throws Exception
{
- HASingletonAwareResetRequestSource source = new HASingletonAwareResetRequestSourceImpl(this.nodeConfig, this.balancerConfig, this.mcmpConfig, this.requestFactory, this.singleton, this.key);
+ HASingletonAwareResetRequestSource source = new HASingletonAwareResetRequestSourceImpl(this.nodeConfig, this.balancerConfig, this.requestFactory, this.singleton, this.key);
Map<String, Set<ResetRequestSource.VirtualHost>> emptyResponseMap = Collections.emptyMap();
@@ -118,9 +116,10 @@
@Test
public void getResetRequests() throws Exception
{
- HASingletonAwareResetRequestSource source = new HASingletonAwareResetRequestSourceImpl(this.nodeConfig, this.balancerConfig, this.mcmpConfig, this.requestFactory, this.singleton, this.key);
+ HASingletonAwareResetRequestSource source = new HASingletonAwareResetRequestSourceImpl(this.nodeConfig, this.balancerConfig, this.requestFactory, this.singleton, this.key);
Map<String, Set<ResetRequestSource.VirtualHost>> emptyResponseMap = Collections.emptyMap();
+ Map<String, Set<String>> emptyContextMap = Collections.emptyMap();
MCMPRequest request1 = EasyMock.createMock(MCMPRequest.class);
MCMPRequest request2 = EasyMock.createMock(MCMPRequest.class);
@@ -135,7 +134,7 @@
MCMPRequest configRequest = EasyMock.createStrictMock(MCMPRequest.class);
MCMPRequest contextRequest = EasyMock.createStrictMock(MCMPRequest.class);
- source.setJbossWebServer(server);
+ source.init(server, emptyContextMap);
EasyMock.expect(this.singleton.isMasterNode()).andReturn(true);
@@ -176,9 +175,9 @@
}
@Test
- public void getLocalResetRequestsNoServer() throws Exception
+ public void getLocalResetRequestsNoInit() throws Exception
{
- HASingletonAwareResetRequestSource source = new HASingletonAwareResetRequestSourceImpl(this.nodeConfig, this.balancerConfig, this.mcmpConfig, this.requestFactory, this.singleton, this.key);
+ HASingletonAwareResetRequestSource source = new HASingletonAwareResetRequestSourceImpl(this.nodeConfig, this.balancerConfig, this.requestFactory, this.singleton, this.key);
Map<String, Set<ResetRequestSource.VirtualHost>> emptyResponseMap = Collections.emptyMap();
@@ -196,9 +195,10 @@
@Test
public void getLocalResetRequests() throws Exception
{
- HASingletonAwareResetRequestSource source = new HASingletonAwareResetRequestSourceImpl(this.nodeConfig, this.balancerConfig, this.mcmpConfig, this.requestFactory, this.singleton, this.key);
+ HASingletonAwareResetRequestSource source = new HASingletonAwareResetRequestSourceImpl(this.nodeConfig, this.balancerConfig, this.requestFactory, this.singleton, this.key);
Map<String, Set<ResetRequestSource.VirtualHost>> emptyResponseMap = Collections.emptyMap();
+ Map<String, Set<String>> emptyContextMap = Collections.emptyMap();
// Test w/server
Server server = EasyMock.createStrictMock(Server.class);
@@ -208,9 +208,9 @@
Host host = EasyMock.createStrictMock(Host.class);
MCMPRequest configRequest = EasyMock.createStrictMock(MCMPRequest.class);
MCMPRequest contextRequest = EasyMock.createStrictMock(MCMPRequest.class);
+
+ source.init(server, emptyContextMap);
- source.setJbossWebServer(server);
-
EasyMock.expect(server.findServices()).andReturn(new Service[] { service });
EasyMock.expect(service.getContainer()).andReturn(engine);
Modified: trunk/mod_cluster/src/test/java/org/jboss/modcluster/mcmp/ResetRequestSourceTestCase.java
===================================================================
--- trunk/mod_cluster/src/test/java/org/jboss/modcluster/mcmp/ResetRequestSourceTestCase.java 2009-01-27 16:17:30 UTC (rev 2224)
+++ trunk/mod_cluster/src/test/java/org/jboss/modcluster/mcmp/ResetRequestSourceTestCase.java 2009-01-27 18:15:24 UTC (rev 2225)
@@ -30,11 +30,10 @@
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.easymock.EasyMock;
-import org.jboss.modcluster.ModClusterServiceTestCase;
import org.jboss.modcluster.config.BalancerConfiguration;
-import org.jboss.modcluster.config.MCMPHandlerConfiguration;
import org.jboss.modcluster.config.NodeConfiguration;
import org.jboss.modcluster.mcmp.impl.ResetRequestSourceImpl;
import org.junit.Assert;
@@ -46,25 +45,38 @@
*/
public class ResetRequestSourceTestCase
{
- private static final ModClusterServiceTestCase.LifecycleServer server = ModClusterServiceTestCase.server;
-
private final NodeConfiguration nodeConfig = EasyMock.createStrictMock(NodeConfiguration.class);
private final BalancerConfiguration balancerConfig = EasyMock.createStrictMock(BalancerConfiguration.class);
- private final MCMPHandlerConfiguration mcmpConfig = EasyMock.createStrictMock(MCMPHandlerConfiguration.class);
private final MCMPRequestFactory requestFactory = EasyMock.createStrictMock(MCMPRequestFactory.class);
- private final ResetRequestSource source = new ResetRequestSourceImpl(this.nodeConfig, this.balancerConfig, this.mcmpConfig, this.requestFactory);
+ @Test
+ public void testGetResetRequestsNoInit()
+ {
+ ResetRequestSource source = new ResetRequestSourceImpl(this.nodeConfig, this.balancerConfig, this.requestFactory);
+
+ Map<String, Set<ResetRequestSource.VirtualHost>> emptyResponseMap = Collections.emptyMap();
+
+ List<MCMPRequest> requests = source.getResetRequests(emptyResponseMap);
+
+ Assert.assertTrue(requests.isEmpty());
+ }
@Test
public void testGetResetRequests() throws Exception
{
+ ResetRequestSource source = new ResetRequestSourceImpl(this.nodeConfig, this.balancerConfig, this.requestFactory);
+
+ Server server = EasyMock.createStrictMock(Server.class);
Service service = EasyMock.createStrictMock(Service.class);
Engine engine = EasyMock.createStrictMock(Engine.class);
Host host = EasyMock.createStrictMock(Host.class);
Context context = EasyMock.createStrictMock(Context.class);
MCMPRequest configRequest = EasyMock.createStrictMock(MCMPRequest.class);
MCMPRequest contextRequest = EasyMock.createStrictMock(MCMPRequest.class);
+ Map<String, Set<String>> emptyContextMap = Collections.emptyMap();
+ source.init(server, emptyContextMap);
+
EasyMock.expect(server.findServices()).andReturn(new Service[] { service });
EasyMock.expect(service.getContainer()).andReturn(engine);
@@ -85,7 +97,7 @@
Map<String, Set<ResetRequestSource.VirtualHost>> emptyResponseMap = Collections.emptyMap();
- List<MCMPRequest> requests = this.source.getResetRequests(emptyResponseMap);
+ List<MCMPRequest> requests = source.getResetRequests(emptyResponseMap);
EasyMock.verify(server, this.requestFactory, service, engine, host, context, this.nodeConfig, this.balancerConfig);
15 years, 11 months
JBoss Native SVN: r2224 - trunk/mod_cluster/src/main/resources.
by jbossnative-commits@lists.jboss.org
Author: pferraro
Date: 2009-01-27 11:17:30 -0500 (Tue, 27 Jan 2009)
New Revision: 2224
Modified:
trunk/mod_cluster/src/main/resources/mod-cluster-jboss-beans.xml
Log:
${jboss.modcluster.proxyList} expansion requires empty default value
Modified: trunk/mod_cluster/src/main/resources/mod-cluster-jboss-beans.xml
===================================================================
--- trunk/mod_cluster/src/main/resources/mod-cluster-jboss-beans.xml 2009-01-27 15:01:47 UTC (rev 2223)
+++ trunk/mod_cluster/src/main/resources/mod-cluster-jboss-beans.xml 2009-01-27 16:17:30 UTC (rev 2224)
@@ -21,7 +21,7 @@
<!-- Comma separated list of address:port listing the httpd servers
where mod_cluster is running. -->
- <property name="proxyList">${jboss.modcluster.proxyList}</property>
+ <property name="proxyList">${jboss.modcluster.proxyList:}</property>
<!-- URL prefix to send with commands to mod_cluster. Default is no prefix. -->
<!--property name="proxyURL"></property-->
@@ -116,7 +116,7 @@
</constructor>
<!-- Comma delimited list of address:port listing the httpd servers
where mod_cluster is running. -->
- <property name="proxyList">${jboss.modcluster.proxyList}</property>
+ <property name="proxyList">${jboss.modcluster.proxyList:}</property>
<!-- URL prefix to send with commands to mod_cluster. Default is no prefix. -->
<!--property name="proxyURL"></property-->
15 years, 11 months
JBoss Native SVN: r2223 - in trunk/mod_cluster/src/test/java/org/jboss/modcluster: mcmp and 1 other directory.
by jbossnative-commits@lists.jboss.org
Author: pferraro
Date: 2009-01-27 10:01:47 -0500 (Tue, 27 Jan 2009)
New Revision: 2223
Modified:
trunk/mod_cluster/src/test/java/org/jboss/modcluster/ha/HASingletonAwareResetRequestSourceTestCase.java
trunk/mod_cluster/src/test/java/org/jboss/modcluster/mcmp/ResetRequestSourceTestCase.java
Log:
Ensure excluded contexts are not registered during node reset.
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 2009-01-27 14:57:59 UTC (rev 2222)
+++ trunk/mod_cluster/src/test/java/org/jboss/modcluster/ha/HASingletonAwareResetRequestSourceTestCase.java 2009-01-27 15:01:47 UTC (rev 2223)
@@ -40,6 +40,7 @@
import org.jboss.ha.framework.interfaces.HAServiceKeyProvider;
import org.jboss.ha.framework.interfaces.HASingletonMBean;
import org.jboss.modcluster.config.BalancerConfiguration;
+import org.jboss.modcluster.config.MCMPHandlerConfiguration;
import org.jboss.modcluster.config.NodeConfiguration;
import org.jboss.modcluster.ha.rpc.ResetRequestGroupRpcResponse;
import org.jboss.modcluster.mcmp.MCMPRequest;
@@ -57,6 +58,7 @@
{
private NodeConfiguration nodeConfig = EasyMock.createStrictMock(NodeConfiguration.class);
private BalancerConfiguration balancerConfig = EasyMock.createStrictMock(BalancerConfiguration.class);
+ private MCMPHandlerConfiguration mcmpConfig = EasyMock.createStrictMock(MCMPHandlerConfiguration.class);
private HAServiceKeyProvider key = EasyMock.createStrictMock(HAServiceKeyProvider.class);
private HASingletonMBean singleton = EasyMock.createStrictMock(HASingletonMBean.class);
private HAPartition partition = EasyMock.createStrictMock(HAPartition.class);
@@ -65,7 +67,7 @@
@Test
public void getResetRequestsNonMaster()
{
- HASingletonAwareResetRequestSource source = new HASingletonAwareResetRequestSourceImpl(this.nodeConfig, this.balancerConfig, this.requestFactory, this.singleton, this.key);
+ HASingletonAwareResetRequestSource source = new HASingletonAwareResetRequestSourceImpl(this.nodeConfig, this.balancerConfig, this.mcmpConfig, this.requestFactory, this.singleton, this.key);
EasyMock.expect(this.singleton.isMasterNode()).andReturn(false);
@@ -85,7 +87,7 @@
@Test
public void getResetRequestsNoServer() throws Exception
{
- HASingletonAwareResetRequestSource source = new HASingletonAwareResetRequestSourceImpl(this.nodeConfig, this.balancerConfig, this.requestFactory, this.singleton, this.key);
+ HASingletonAwareResetRequestSource source = new HASingletonAwareResetRequestSourceImpl(this.nodeConfig, this.balancerConfig, this.mcmpConfig, this.requestFactory, this.singleton, this.key);
Map<String, Set<ResetRequestSource.VirtualHost>> emptyResponseMap = Collections.emptyMap();
@@ -116,7 +118,7 @@
@Test
public void getResetRequests() throws Exception
{
- HASingletonAwareResetRequestSource source = new HASingletonAwareResetRequestSourceImpl(this.nodeConfig, this.balancerConfig, this.requestFactory, this.singleton, this.key);
+ HASingletonAwareResetRequestSource source = new HASingletonAwareResetRequestSourceImpl(this.nodeConfig, this.balancerConfig, this.mcmpConfig, this.requestFactory, this.singleton, this.key);
Map<String, Set<ResetRequestSource.VirtualHost>> emptyResponseMap = Collections.emptyMap();
MCMPRequest request1 = EasyMock.createMock(MCMPRequest.class);
@@ -176,7 +178,7 @@
@Test
public void getLocalResetRequestsNoServer() throws Exception
{
- HASingletonAwareResetRequestSource source = new HASingletonAwareResetRequestSourceImpl(this.nodeConfig, this.balancerConfig, this.requestFactory, this.singleton, this.key);
+ HASingletonAwareResetRequestSource source = new HASingletonAwareResetRequestSourceImpl(this.nodeConfig, this.balancerConfig, this.mcmpConfig, this.requestFactory, this.singleton, this.key);
Map<String, Set<ResetRequestSource.VirtualHost>> emptyResponseMap = Collections.emptyMap();
@@ -194,7 +196,7 @@
@Test
public void getLocalResetRequests() throws Exception
{
- HASingletonAwareResetRequestSource source = new HASingletonAwareResetRequestSourceImpl(this.nodeConfig, this.balancerConfig, this.requestFactory, this.singleton, this.key);
+ HASingletonAwareResetRequestSource source = new HASingletonAwareResetRequestSourceImpl(this.nodeConfig, this.balancerConfig, this.mcmpConfig, this.requestFactory, this.singleton, this.key);
Map<String, Set<ResetRequestSource.VirtualHost>> emptyResponseMap = Collections.emptyMap();
Modified: trunk/mod_cluster/src/test/java/org/jboss/modcluster/mcmp/ResetRequestSourceTestCase.java
===================================================================
--- trunk/mod_cluster/src/test/java/org/jboss/modcluster/mcmp/ResetRequestSourceTestCase.java 2009-01-27 14:57:59 UTC (rev 2222)
+++ trunk/mod_cluster/src/test/java/org/jboss/modcluster/mcmp/ResetRequestSourceTestCase.java 2009-01-27 15:01:47 UTC (rev 2223)
@@ -34,6 +34,7 @@
import org.easymock.EasyMock;
import org.jboss.modcluster.ModClusterServiceTestCase;
import org.jboss.modcluster.config.BalancerConfiguration;
+import org.jboss.modcluster.config.MCMPHandlerConfiguration;
import org.jboss.modcluster.config.NodeConfiguration;
import org.jboss.modcluster.mcmp.impl.ResetRequestSourceImpl;
import org.junit.Assert;
@@ -49,9 +50,10 @@
private final NodeConfiguration nodeConfig = EasyMock.createStrictMock(NodeConfiguration.class);
private final BalancerConfiguration balancerConfig = EasyMock.createStrictMock(BalancerConfiguration.class);
+ private final MCMPHandlerConfiguration mcmpConfig = EasyMock.createStrictMock(MCMPHandlerConfiguration.class);
private final MCMPRequestFactory requestFactory = EasyMock.createStrictMock(MCMPRequestFactory.class);
- private final ResetRequestSource source = new ResetRequestSourceImpl(this.nodeConfig, this.balancerConfig, this.requestFactory);
+ private final ResetRequestSource source = new ResetRequestSourceImpl(this.nodeConfig, this.balancerConfig, this.mcmpConfig, this.requestFactory);
@Test
public void testGetResetRequests() throws Exception
15 years, 11 months
JBoss Native SVN: r2222 - trunk/mod_cluster/src/main/java/org/jboss/modcluster/ha.
by jbossnative-commits@lists.jboss.org
Author: pferraro
Date: 2009-01-27 09:57:59 -0500 (Tue, 27 Jan 2009)
New Revision: 2222
Modified:
trunk/mod_cluster/src/main/java/org/jboss/modcluster/ha/HASingletonAwareResetRequestSourceImpl.java
Log:
Ensure excluded contexts are not registered during node reset.
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 2009-01-27 14:57:49 UTC (rev 2221)
+++ trunk/mod_cluster/src/main/java/org/jboss/modcluster/ha/HASingletonAwareResetRequestSourceImpl.java 2009-01-27 14:57:59 UTC (rev 2222)
@@ -36,6 +36,7 @@
import org.jboss.modcluster.Constants;
import org.jboss.modcluster.Utils;
import org.jboss.modcluster.config.BalancerConfiguration;
+import org.jboss.modcluster.config.MCMPHandlerConfiguration;
import org.jboss.modcluster.config.NodeConfiguration;
import org.jboss.modcluster.ha.rpc.ResetRequestGroupRpcResponse;
import org.jboss.modcluster.ha.rpc.ResetRequestSourceRpcHandler;
@@ -69,9 +70,9 @@
private volatile Server server;
- public HASingletonAwareResetRequestSourceImpl(NodeConfiguration nodeConfig, BalancerConfiguration balancerConfig, MCMPRequestFactory requestFactory, HASingletonMBean singleton, HAServiceKeyProvider serviceKeyProvider)
+ public HASingletonAwareResetRequestSourceImpl(NodeConfiguration nodeConfig, BalancerConfiguration balancerConfig, MCMPHandlerConfiguration mcmpConfig, MCMPRequestFactory requestFactory, HASingletonMBean singleton, HAServiceKeyProvider serviceKeyProvider)
{
- super(nodeConfig, balancerConfig, requestFactory);
+ super(nodeConfig, balancerConfig, mcmpConfig, requestFactory);
this.singleton = singleton;
this.rpcStub = new RpcStub(serviceKeyProvider);
15 years, 11 months
JBoss Native SVN: r2221 - in trunk/mod_cluster/src/main/java/org/jboss/modcluster: ha and 1 other directories.
by jbossnative-commits@lists.jboss.org
Author: pferraro
Date: 2009-01-27 09:57:49 -0500 (Tue, 27 Jan 2009)
New Revision: 2221
Modified:
trunk/mod_cluster/src/main/java/org/jboss/modcluster/AbstractModClusterService.java
trunk/mod_cluster/src/main/java/org/jboss/modcluster/DefaultJBossWebEventHandler.java
trunk/mod_cluster/src/main/java/org/jboss/modcluster/Utils.java
trunk/mod_cluster/src/main/java/org/jboss/modcluster/ha/HAModClusterService.java
trunk/mod_cluster/src/main/java/org/jboss/modcluster/mcmp/impl/ResetRequestSourceImpl.java
Log:
Ensure excluded contexts are not registered during node reset.
Modified: trunk/mod_cluster/src/main/java/org/jboss/modcluster/AbstractModClusterService.java
===================================================================
--- trunk/mod_cluster/src/main/java/org/jboss/modcluster/AbstractModClusterService.java 2009-01-27 14:46:09 UTC (rev 2220)
+++ trunk/mod_cluster/src/main/java/org/jboss/modcluster/AbstractModClusterService.java 2009-01-27 14:57:49 UTC (rev 2221)
@@ -50,7 +50,7 @@
public AbstractModClusterService()
{
this.requestFactory = new DefaultMCMPRequestFactory();
- this.mcmpHandler = new DefaultMCMPHandler(this, new ResetRequestSourceImpl(this, this, this.requestFactory), this.requestFactory);
+ this.mcmpHandler = new DefaultMCMPHandler(this, new ResetRequestSourceImpl(this, this, this, this.requestFactory), this.requestFactory);
JBossWebEventHandler eventHandler = new DefaultJBossWebEventHandler(this, this, this, this.mcmpHandler, this.requestFactory, this, new AdvertiseListenerFactoryImpl());
Modified: trunk/mod_cluster/src/main/java/org/jboss/modcluster/DefaultJBossWebEventHandler.java
===================================================================
--- trunk/mod_cluster/src/main/java/org/jboss/modcluster/DefaultJBossWebEventHandler.java 2009-01-27 14:46:09 UTC (rev 2220)
+++ trunk/mod_cluster/src/main/java/org/jboss/modcluster/DefaultJBossWebEventHandler.java 2009-01-27 14:57:49 UTC (rev 2221)
@@ -24,8 +24,6 @@
import java.io.IOException;
import java.net.InetSocketAddress;
-import java.util.HashMap;
-import java.util.HashSet;
import java.util.List;
import java.util.Map;
import java.util.Set;
@@ -54,12 +52,7 @@
* @author Brian Stansberry
*/
public class DefaultJBossWebEventHandler implements JBossWebEventHandler
-{
- private static final String ROOT_CONTEXT = "ROOT";
- private static final String CONTEXT_DELIMITER = ",";
- private static final String HOST_CONTEXT_DELIMITER = ":";
- private static final String DEFAULT_HOST = "localhost";
-
+{
static final Logger log = Logger.getLogger(DefaultJBossWebEventHandler.class);
// ----------------------------------------------------------------- Fields
@@ -75,12 +68,12 @@
private final MCMPRequestFactory requestFactory;
private final AdvertiseListenerFactory listenerFactory;
private final LoadBalanceFactorProviderFactory loadBalanceFactorProviderFactory;
- private final Map<String, Set<String>> excludedContextPaths = new HashMap<String, Set<String>>();
private volatile boolean init;
private LoadBalanceFactorProvider loadBalanceFactorProvider;
private AdvertiseListener advertiseListener;
+ private Map<String, Set<String>> excludedContextPaths;
public DefaultJBossWebEventHandler(NodeConfiguration nodeConfig, BalancerConfiguration balancerConfig,
MCMPHandlerConfiguration mcmpConfig, MCMPHandler mcmpHandler, MCMPRequestFactory requestFactory,
@@ -102,47 +95,7 @@
List<InetSocketAddress> initialProxies = Utils.parseProxies(this.mcmpConfig.getProxyList());
this.mcmpHandler.init(initialProxies);
- String contexts = this.mcmpConfig.getExcludedContexts();
-
- if (contexts != null)
- {
- String trimmedContexts = contexts.trim();
-
- if (trimmedContexts.length() > 0)
- {
- for (String context: trimmedContexts.split(CONTEXT_DELIMITER))
- {
- String[] parts = context.trim().split(HOST_CONTEXT_DELIMITER);
-
- if (parts.length > 2)
- {
- throw new IllegalArgumentException(trimmedContexts + " is not a valid value for excludedContexts");
- }
-
- String host = DEFAULT_HOST;
- String trimmedContext = parts[0].trim();
-
- if (parts.length == 2)
- {
- host = trimmedContext;
- trimmedContext = parts[1].trim();
- }
-
- String path = trimmedContext.equals(ROOT_CONTEXT) ? "" : "/" + trimmedContext;
-
- Set<String> paths = this.excludedContextPaths.get(host);
-
- if (paths == null)
- {
- paths = new HashSet<String>();
-
- this.excludedContextPaths.put(host, paths);
- }
-
- paths.add(path);
- }
- }
- }
+ this.excludedContextPaths = Utils.parseContexts(this.mcmpConfig.getExcludedContexts());
this.loadBalanceFactorProvider = this.loadBalanceFactorProviderFactory.createLoadBalanceFactorProvider();
Modified: trunk/mod_cluster/src/main/java/org/jboss/modcluster/Utils.java
===================================================================
--- trunk/mod_cluster/src/main/java/org/jboss/modcluster/Utils.java 2009-01-27 14:46:09 UTC (rev 2220)
+++ trunk/mod_cluster/src/main/java/org/jboss/modcluster/Utils.java 2009-01-27 14:57:49 UTC (rev 2221)
@@ -8,8 +8,11 @@
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;
+import java.util.HashMap;
+import java.util.HashSet;
import java.util.LinkedHashSet;
import java.util.List;
+import java.util.Map;
import java.util.Set;
import org.apache.catalina.Context;
@@ -27,6 +30,10 @@
public class Utils
{
+ private static final String ROOT_CONTEXT = "ROOT";
+ private static final String CONTEXT_DELIMITER = ",";
+ private static final String HOST_CONTEXT_DELIMITER = ":";
+ private static final String DEFAULT_HOST = "localhost";
private static final int DEFAULT_PORT = 8000;
private static final Logger log = Logger.getLogger(Utils.class);
@@ -275,6 +282,51 @@
return new InetSocketAddress(inetAddress, port);
}
+ public static Map<String, Set<String>> parseContexts(String contexts)
+ {
+ if (contexts == null) return Collections.emptyMap();
+
+ String trimmedContexts = contexts.trim();
+
+ if (trimmedContexts.length() == 0) return Collections.emptyMap();
+
+ Map<String, Set<String>> map = new HashMap<String, Set<String>>();
+
+ for (String context: trimmedContexts.split(CONTEXT_DELIMITER))
+ {
+ String[] parts = context.trim().split(HOST_CONTEXT_DELIMITER);
+
+ if (parts.length > 2)
+ {
+ throw new IllegalArgumentException(trimmedContexts + " is not a valid value for excludedContexts");
+ }
+
+ String host = DEFAULT_HOST;
+ String trimmedContext = parts[0].trim();
+
+ if (parts.length == 2)
+ {
+ host = trimmedContext;
+ trimmedContext = parts[1].trim();
+ }
+
+ String path = trimmedContext.equals(ROOT_CONTEXT) ? "" : "/" + trimmedContext;
+
+ Set<String> paths = map.get(host);
+
+ if (paths == null)
+ {
+ paths = new HashSet<String>();
+
+ map.put(host, paths);
+ }
+
+ paths.add(path);
+ }
+
+ return map;
+ }
+
private Utils()
{
}
Modified: trunk/mod_cluster/src/main/java/org/jboss/modcluster/ha/HAModClusterService.java
===================================================================
--- trunk/mod_cluster/src/main/java/org/jboss/modcluster/ha/HAModClusterService.java 2009-01-27 14:46:09 UTC (rev 2220)
+++ trunk/mod_cluster/src/main/java/org/jboss/modcluster/ha/HAModClusterService.java 2009-01-27 14:57:49 UTC (rev 2221)
@@ -159,7 +159,7 @@
this.loadBalanceFactorProvider = loadFactorProvider;
this.requestFactory = new DefaultMCMPRequestFactory();
- this.resetRequestSource = new HASingletonAwareResetRequestSourceImpl(config, config, this.requestFactory, this, this);
+ this.resetRequestSource = new HASingletonAwareResetRequestSourceImpl(config, config, config, this.requestFactory, this, this);
this.localHandler = new DefaultMCMPHandler(config, this.resetRequestSource, this.requestFactory);
this.clusteredHandler = new ClusteredMCMPHandlerImpl(this.localHandler, this, this);
Modified: 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 2009-01-27 14:46:09 UTC (rev 2220)
+++ trunk/mod_cluster/src/main/java/org/jboss/modcluster/mcmp/impl/ResetRequestSourceImpl.java 2009-01-27 14:57:49 UTC (rev 2221)
@@ -38,6 +38,7 @@
import org.apache.catalina.Service;
import org.jboss.modcluster.Utils;
import org.jboss.modcluster.config.BalancerConfiguration;
+import org.jboss.modcluster.config.MCMPHandlerConfiguration;
import org.jboss.modcluster.config.NodeConfiguration;
import org.jboss.modcluster.mcmp.MCMPRequest;
import org.jboss.modcluster.mcmp.MCMPRequestFactory;
@@ -52,12 +53,14 @@
{
private final NodeConfiguration nodeConfig;
private final BalancerConfiguration balancerConfig;
+ private final MCMPHandlerConfiguration mcmpConfig;
private final MCMPRequestFactory requestFactory;
- public ResetRequestSourceImpl(NodeConfiguration nodeConfig, BalancerConfiguration balancerConfig, MCMPRequestFactory requestFactory)
+ public ResetRequestSourceImpl(NodeConfiguration nodeConfig, BalancerConfiguration balancerConfig, MCMPHandlerConfiguration mcmpConfig, MCMPRequestFactory requestFactory)
{
this.nodeConfig = nodeConfig;
this.balancerConfig = balancerConfig;
+ this.mcmpConfig = mcmpConfig;
this.requestFactory = requestFactory;
}
@@ -72,6 +75,9 @@
protected List<MCMPRequest> getResetRequests(Map<String, Set<VirtualHost>> response, Server server)
{
+ // TODO This is a hack - we shouldn't have to parse the exclusion list every time
+ Map<String, Set<String>> excludedContexts = Utils.parseContexts(this.mcmpConfig.getExcludedContexts());
+
List<MCMPRequest> requests = new ArrayList<MCMPRequest>();
List<MCMPRequest> engineRequests = new LinkedList<MCMPRequest>();
@@ -131,6 +137,13 @@
Context context = (Context) container;
String path = context.getPath();
+ Set<String> excludedPaths = excludedContexts.get(hostName);
+
+ if ((excludedPaths != null) && excludedPaths.contains(path))
+ {
+ continue;
+ }
+
obsoleteContexts.remove(path);
ResetRequestSource.Status status = responseContexts.get(path);
15 years, 11 months
JBoss Native SVN: r2220 - trunk/mod_cluster/src/main/java/org/jboss/modcluster/mcmp/impl.
by jbossnative-commits@lists.jboss.org
Author: pferraro
Date: 2009-01-27 09:46:09 -0500 (Tue, 27 Jan 2009)
New Revision: 2220
Modified:
trunk/mod_cluster/src/main/java/org/jboss/modcluster/mcmp/impl/DefaultMCMPHandler.java
Log:
Code cleanup ;)
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 2009-01-27 14:28:55 UTC (rev 2219)
+++ trunk/mod_cluster/src/main/java/org/jboss/modcluster/mcmp/impl/DefaultMCMPHandler.java 2009-01-27 14:46:09 UTC (rev 2220)
@@ -350,11 +350,15 @@
{
Proxy proxy = this.proxies.get(i);
String string = this.sendRequest(request, proxy);
- if (string != null) {
+
+ if (string != null)
+ {
if (result == null)
+ {
result = new StringBuilder();
- result.append("Proxy[").append(i).append("]: [").append(proxy.getAddress()).append(':').append(proxy.getPort()).append("]: \r\n");
- result.append(string).append("\r\n");
+ }
+ result.append("Proxy[").append(i).append("]: [").append(proxy.getAddress()).append(':').append(proxy.getPort()).append("]: ").append(NEW_LINE);
+ result.append(string).append(NEW_LINE);
}
}
}
@@ -362,7 +366,8 @@
{
lock.unlock();
}
- return (result == null) ? null : result.toString();
+
+ return (result != null) ? result.toString() : null;
}
public InetAddress getLocalAddress() throws IOException
15 years, 11 months
JBoss Native SVN: r2219 - trunk/mod_cluster/src/main/java/org/jboss/modcluster/mcmp/impl.
by jbossnative-commits@lists.jboss.org
Author: jfrederic.clere(a)jboss.com
Date: 2009-01-27 09:28:55 -0500 (Tue, 27 Jan 2009)
New Revision: 2219
Modified:
trunk/mod_cluster/src/main/java/org/jboss/modcluster/mcmp/impl/DefaultMCMPHandler.java
Log:
getProxyMessage() now returns null if no proxy answers are received...
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 2009-01-27 09:47:21 UTC (rev 2218)
+++ trunk/mod_cluster/src/main/java/org/jboss/modcluster/mcmp/impl/DefaultMCMPHandler.java 2009-01-27 14:28:55 UTC (rev 2219)
@@ -339,7 +339,7 @@
private String getProxyMessage(MCMPRequest request)
{
- StringBuilder result = new StringBuilder();
+ StringBuilder result = null;
Lock lock = this.proxiesLock.readLock();
lock.lock();
@@ -349,15 +349,20 @@
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(request, proxy)).append("\r\n");
+ String string = this.sendRequest(request, proxy);
+ if (string != null) {
+ if (result == null)
+ result = new StringBuilder();
+ result.append("Proxy[").append(i).append("]: [").append(proxy.getAddress()).append(':').append(proxy.getPort()).append("]: \r\n");
+ result.append(string).append("\r\n");
+ }
}
}
finally
{
lock.unlock();
}
- return result.toString();
+ return (result == null) ? null : result.toString();
}
public InetAddress getLocalAddress() throws IOException
15 years, 11 months