[jboss-cvs] JBossAS SVN: r77862 - in trunk/tomcat/src: main/org/jboss/web/tomcat/service/modcluster/ha and 4 other directories.
jboss-cvs-commits at lists.jboss.org
jboss-cvs-commits at lists.jboss.org
Wed Sep 3 15:01:24 EDT 2008
Author: pferraro
Date: 2008-09-03 15:01:23 -0400 (Wed, 03 Sep 2008)
New Revision: 77862
Removed:
trunk/tomcat/src/main/org/jboss/web/tomcat/service/modcluster/BasicClusterListener.java
trunk/tomcat/src/main/org/jboss/web/tomcat/service/modcluster/Constants.java
trunk/tomcat/src/main/org/jboss/web/tomcat/service/modcluster/DefaultJBossWebEventHandler.java
trunk/tomcat/src/main/org/jboss/web/tomcat/service/modcluster/JBossWebEventHandler.java
trunk/tomcat/src/main/org/jboss/web/tomcat/service/modcluster/LocalStrings.properties
trunk/tomcat/src/main/org/jboss/web/tomcat/service/modcluster/ModClusterService.java
trunk/tomcat/src/main/org/jboss/web/tomcat/service/modcluster/ModClusterServiceMBean.java
trunk/tomcat/src/main/org/jboss/web/tomcat/service/modcluster/Utils.java
trunk/tomcat/src/main/org/jboss/web/tomcat/service/modcluster/advertise/
trunk/tomcat/src/main/org/jboss/web/tomcat/service/modcluster/config/
trunk/tomcat/src/main/org/jboss/web/tomcat/service/modcluster/ha/ClusteredMCMPHandler.java
trunk/tomcat/src/main/org/jboss/web/tomcat/service/modcluster/ha/ClusteredMCMPHandlerImpl.java
trunk/tomcat/src/main/org/jboss/web/tomcat/service/modcluster/ha/HASingletonAwareResetRequestSource.java
trunk/tomcat/src/main/org/jboss/web/tomcat/service/modcluster/ha/ModClusterServiceDRMEntry.java
trunk/tomcat/src/main/org/jboss/web/tomcat/service/modcluster/ha/rpc/
trunk/tomcat/src/main/org/jboss/web/tomcat/service/modcluster/load/LoadBalanceFactorProvider.java
trunk/tomcat/src/main/org/jboss/web/tomcat/service/modcluster/load/impl/
trunk/tomcat/src/main/org/jboss/web/tomcat/service/modcluster/load/metric/LoadMetric.java
trunk/tomcat/src/main/org/jboss/web/tomcat/service/modcluster/load/metric/LoadMetricMBean.java
trunk/tomcat/src/main/org/jboss/web/tomcat/service/modcluster/load/metric/LoadMetricSource.java
trunk/tomcat/src/main/org/jboss/web/tomcat/service/modcluster/load/metric/LoadMetricSourceRegistration.java
trunk/tomcat/src/main/org/jboss/web/tomcat/service/modcluster/load/metric/impl/
trunk/tomcat/src/main/org/jboss/web/tomcat/service/modcluster/mbeans-descriptors.xml
trunk/tomcat/src/main/org/jboss/web/tomcat/service/modcluster/mcmp/AbstractMCMPHandler.java
trunk/tomcat/src/main/org/jboss/web/tomcat/service/modcluster/mcmp/AddressPort.java
trunk/tomcat/src/main/org/jboss/web/tomcat/service/modcluster/mcmp/MCMPHandler.java
trunk/tomcat/src/main/org/jboss/web/tomcat/service/modcluster/mcmp/MCMPRequest.java
trunk/tomcat/src/main/org/jboss/web/tomcat/service/modcluster/mcmp/MCMPRequestType.java
trunk/tomcat/src/main/org/jboss/web/tomcat/service/modcluster/mcmp/MCMPServer.java
trunk/tomcat/src/main/org/jboss/web/tomcat/service/modcluster/mcmp/MCMPServerState.java
trunk/tomcat/src/main/org/jboss/web/tomcat/service/modcluster/mcmp/MCMPUtils.java
trunk/tomcat/src/main/org/jboss/web/tomcat/service/modcluster/mcmp/ResetRequestSource.java
trunk/tomcat/src/main/org/jboss/web/tomcat/service/modcluster/mcmp/impl/
trunk/tomcat/src/resources/mod-cluster-jboss-beans.xml
Log:
Moved to https://svn.jboss.org/jbossnative/trunk/mod_cluster
Deleted: trunk/tomcat/src/main/org/jboss/web/tomcat/service/modcluster/BasicClusterListener.java
===================================================================
--- trunk/tomcat/src/main/org/jboss/web/tomcat/service/modcluster/BasicClusterListener.java 2008-09-03 18:23:47 UTC (rev 77861)
+++ trunk/tomcat/src/main/org/jboss/web/tomcat/service/modcluster/BasicClusterListener.java 2008-09-03 19:01:23 UTC (rev 77862)
@@ -1,231 +0,0 @@
-/*
- * JBoss, Home of Professional Open Source
- * Copyright 2008, JBoss Inc., and individual contributors as indicated
- * by the @authors tag. See the copyright.txt 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.web.tomcat.service.modcluster;
-
-
-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.Service;
-import org.apache.catalina.util.StringManager;
-import org.jboss.logging.Logger;
-
-
-
-/**
- * This listener communicates with a front end mod_cluster enabled proxy to
- * automatically maintain the node configuration according to what is
- * deployed.
- */
-public class BasicClusterListener
- implements LifecycleListener, ContainerListener
-{
- protected static Logger log = Logger.getLogger(BasicClusterListener.class);
-
- /**
- * The string manager for this package.
- */
- protected StringManager sm =
- StringManager.getManager(Constants.Package);
-
-
- // -------------------------------------------------------------- Constants
-
-
- // ----------------------------------------------------------------- Fields
-
- /**
- * Initialization flag.
- */
- protected boolean init = false;
-
- protected JBossWebEventHandler eventHandler;
-
- // ----------------------------------------------------------- Constructors
-
- public BasicClusterListener(JBossWebEventHandler eventHandler)
- {
- this.eventHandler = eventHandler;
- }
-
- protected BasicClusterListener()
- {
- }
-
- // ------------------------------------------------------------- Properties
-
-
-
- // ---------------------------------------------- LifecycleListener Methods
-
-
- /**
- * Acknowledge the occurrence of the specified event.
- * Note: Will never be called when the listener is associated to a Server,
- * since it is not a Container.
- *
- * @param event ContainerEvent that has occurred
- */
- public void containerEvent(ContainerEvent event) {
-
- Container container = event.getContainer();
- Object child = event.getData();
- String type = event.getType();
-
- if (type.equals(Container.ADD_CHILD_EVENT)) {
- if (container instanceof Host) {
- // Deploying a webapp
- ((Lifecycle) child).addLifecycleListener(this);
- eventHandler.addContext((Context) child);
- } else if (container instanceof Engine) {
- // Deploying a host
- container.addContainerListener(this);
- }
- } else if (type.equals(Container.REMOVE_CHILD_EVENT)) {
- if (container instanceof Host) {
- // Undeploying a webapp
- ((Lifecycle) child).removeLifecycleListener(this);
- eventHandler.removeContext((Context) child);
- } else if (container instanceof Engine) {
- // Undeploying a host
- container.removeContainerListener(this);
- }
- }
-
- }
-
-
- /**
- * Primary entry point for startup and shutdown events.
- *
- * @param event The event that has occurred
- */
- public void lifecycleEvent(LifecycleEvent event) {
-
- Object source = event.getLifecycle();
-
- if (Lifecycle.START_EVENT.equals(event.getType())) {
- if (source instanceof Context) {
- // Start a webapp
- eventHandler.startContext((Context) source);
- } else {
- return;
- }
- } else if (Lifecycle.AFTER_START_EVENT.equals(event.getType())) {
- if (source instanceof Server) {
-
- eventHandler.init();
-
- startServer((Server) source);
-
- init = true;
- } else {
- return;
- }
- } else if (Lifecycle.STOP_EVENT.equals(event.getType())) {
- if (source instanceof Context) {
- // Stop a webapp
- eventHandler.stopContext((Context) source);
- } else if (source instanceof Server) {
-
- stopServer((Server) source);
-
- eventHandler.shutdown();
-
- init = false;
- } else {
- return;
- }
- } else if (Lifecycle.PERIODIC_EVENT.equals(event.getType())) {
- if (init && source instanceof Engine) {
- eventHandler.status((Engine) source);
- }
- }
-
- }
-
-
- /**
- * Send commands to the front end server associated with the startup of the
- * node.
- */
- protected void startServer(Server server) {
-
- // Register ourself as a listener for child services
- Service[] services = server.findServices();
- for (int i = 0; i < services.length; i++) {
- services[i].getContainer().addContainerListener(this);
-
- Engine engine = (Engine) services[i].getContainer();
- ((Lifecycle) engine).addLifecycleListener(this);
-
- Container[] children = engine.findChildren();
- for (int j = 0; j < children.length; j++) {
- children[j].addContainerListener(this);
- Container[] children2 = children[j].findChildren();
- for (int k = 0; k < children2.length; k++) {
- ((Lifecycle) children2[k]).addLifecycleListener(this);
- }
- }
- }
-
- eventHandler.startServer(server);
- }
-
-
- /**
- * Send commands to the front end server associated with the shutdown of the
- * node.
- */
- protected void stopServer(Server server) {
-
- // Register ourself as a listener to child components
- Service[] services = server.findServices();
- for (int i = 0; i < services.length; i++) {
- services[i].getContainer().removeContainerListener(this);
- ((Lifecycle) services[i].getContainer()).removeLifecycleListener(this);
- Container[] children = services[i].getContainer().findChildren();
- for (int j = 0; j < children.length; j++) {
- children[j].removeContainerListener(this);
- Container[] children2 = children[j].findChildren();
- for (int k = 0; k < children2.length; k++) {
- ((Lifecycle) children2[k]).removeLifecycleListener(this);
- }
- }
- }
-
- eventHandler.stopServer(server);
- }
-
- protected void setEventHandler(JBossWebEventHandler handler)
- {
- this.eventHandler = handler;
- }
-
-}
Deleted: trunk/tomcat/src/main/org/jboss/web/tomcat/service/modcluster/Constants.java
===================================================================
--- trunk/tomcat/src/main/org/jboss/web/tomcat/service/modcluster/Constants.java 2008-09-03 18:23:47 UTC (rev 77861)
+++ trunk/tomcat/src/main/org/jboss/web/tomcat/service/modcluster/Constants.java 2008-09-03 19:01:23 UTC (rev 77862)
@@ -1,31 +0,0 @@
-/*
- * JBoss, Home of Professional Open Source
- * Copyright 2006, JBoss Inc., and individual contributors as indicated
- * by the @authors tag. See the copyright.txt 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.web.tomcat.service.modcluster;
-
-
-public class Constants {
-
- public static final String Package = Constants.class.getPackage().getName();
-
-}
Deleted: trunk/tomcat/src/main/org/jboss/web/tomcat/service/modcluster/DefaultJBossWebEventHandler.java
===================================================================
--- trunk/tomcat/src/main/org/jboss/web/tomcat/service/modcluster/DefaultJBossWebEventHandler.java 2008-09-03 18:23:47 UTC (rev 77861)
+++ trunk/tomcat/src/main/org/jboss/web/tomcat/service/modcluster/DefaultJBossWebEventHandler.java 2008-09-03 19:01:23 UTC (rev 77862)
@@ -1,302 +0,0 @@
-/*
- * 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.web.tomcat.service.modcluster;
-
-import java.io.IOException;
-import java.util.List;
-
-import org.apache.catalina.Container;
-import org.apache.catalina.Context;
-import org.apache.catalina.Engine;
-import org.apache.catalina.Server;
-import org.apache.catalina.Service;
-import org.apache.catalina.core.StandardContext;
-import org.apache.catalina.util.StringManager;
-import org.jboss.logging.Logger;
-import org.jboss.web.tomcat.service.modcluster.advertise.AdvertiseListener;
-import org.jboss.web.tomcat.service.modcluster.config.BalancerConfiguration;
-import org.jboss.web.tomcat.service.modcluster.config.MCMPHandlerConfiguration;
-import org.jboss.web.tomcat.service.modcluster.config.NodeConfiguration;
-import org.jboss.web.tomcat.service.modcluster.load.LoadBalanceFactorProvider;
-import org.jboss.web.tomcat.service.modcluster.mcmp.AddressPort;
-import org.jboss.web.tomcat.service.modcluster.mcmp.MCMPHandler;
-import org.jboss.web.tomcat.service.modcluster.mcmp.MCMPRequest;
-import org.jboss.web.tomcat.service.modcluster.mcmp.MCMPUtils;
-
-/**
- * Default implementation of {@link JBossWebEventHandler}.
- *
- * @author Brian Stansberry
- */
-public class DefaultJBossWebEventHandler implements JBossWebEventHandler
-{
- protected static Logger log = Logger.getLogger(DefaultJBossWebEventHandler.class);
-
- // ----------------------------------------------------------------- Fields
-
- /**
- * The string manager for this package.
- */
- private final StringManager sm = StringManager.getManager(Constants.Package);
- private final NodeConfiguration nodeConfiguration;
- private final BalancerConfiguration balancerConfiguration;
- private final MCMPHandler mcmpHandler;
- private final LoadBalanceFactorProvider loadBalanceFactorProvider;
-
- private boolean init;
-
- private AdvertiseListener advertiseListener;
-
- // ----------------------------------------------------------- Constructors
-
- public DefaultJBossWebEventHandler(NodeConfiguration nodeConfiguration, BalancerConfiguration balancerConfiguration,
- MCMPHandler mcmpHandler, LoadBalanceFactorProvider loadBalanceFactorProvider)
- {
- this.nodeConfiguration = nodeConfiguration;
- this.balancerConfiguration = balancerConfiguration;
- this.mcmpHandler = mcmpHandler;
- this.loadBalanceFactorProvider = loadBalanceFactorProvider;
- }
-
- // ---------------------------------------------------- JBossWebEventHandler
-
- public synchronized void init()
- {
- MCMPHandlerConfiguration handlerConfig = this.mcmpHandler.getConfiguration();
- List<AddressPort> initialProxies = MCMPUtils.parseProxies(handlerConfig.getProxyList());
- this.mcmpHandler.init(initialProxies);
-
- Boolean advertise = handlerConfig.getAdvertise();
-
- if (Boolean.TRUE.equals(advertise) || (advertise == null && initialProxies.size() == 0))
- {
- this.advertiseListener = new AdvertiseListener(this.mcmpHandler);
- }
-
- this.init = true;
- }
-
- public synchronized void shutdown()
- {
- this.stopListener();
- this.mcmpHandler.shutdown();
- this.init = false;
- }
-
- /**
- * Send commands to the front end server associated with the startup of the
- * node.
- */
- public void startServer(Server server)
- {
- this.checkInit();
-
- Service[] services = server.findServices();
- for (Service service : services)
- {
- Engine engine = (Engine) service.getContainer();
-
- this.config(engine);
- Container[] children = engine.findChildren();
- for (Container element : children)
- {
- Container[] children2 = element.findChildren();
- for (Container element2 : children2)
- {
- this.addContext((Context) element2);
- }
- }
- }
- }
-
- /**
- * Send commands to the front end server associated with the shutdown of the
- * node.
- */
- public void stopServer(Server server)
- {
- this.checkInit();
-
- Service[] services = server.findServices();
- for (Service service : services)
- {
- this.removeAll((Engine) service.getContainer());
- Container[] children = service.getContainer().findChildren();
- for (Container element : children)
- {
- Container[] children2 = element.findChildren();
- for (Container element2 : children2)
- {
- this.removeContext((Context) element2);
- }
- }
- }
- }
-
- public void config(Engine engine)
- {
- log.debug(this.sm.getString("modcluster.engine.config", engine.getName()));
-
- // If needed, create automagical JVM route (address + port + engineName)
- try
- {
- Utils.establishJvmRouteAndConnectorAddress(engine, this.mcmpHandler);
- }
- catch (Exception e)
- {
- this.mcmpHandler.markProxiesInError();
- log.info(this.sm.getString("modcluster.error.addressJvmRoute"), e);
- return;
- }
-
- MCMPRequest request = MCMPUtils.createConfigRequest(engine, this.getNodeConfiguration(), this.getBalancerConfiguration());
-
- // Send CONFIG request
- this.mcmpHandler.sendRequest(request);
- }
-
- public void addContext(Context context)
- {
- this.checkInit();
-
- log.debug(this.sm.getString("modcluster.context.enable", context.getPath(), context.getParent().getName(), ((StandardContext) context).getState()));
-
- // Send ENABLE-APP if state is started
- if (context.isStarted())
- {
- MCMPRequest request = MCMPUtils.createEnableAppRequest(context);
- this.mcmpHandler.sendRequest(request);
- }
- }
-
- public void startContext(Context context)
- {
- this.checkInit();
-
- log.debug(this.sm.getString("modcluster.context.start", context.getPath(), context.getParent().getName()));
-
- // Send ENABLE-APP
- MCMPRequest request = MCMPUtils.createEnableAppRequest(context);
- this.mcmpHandler.sendRequest(request);
- }
-
- public void stopContext(Context context)
- {
- this.checkInit();
-
- log.debug(this.sm.getString("modcluster.context.stop", context.getPath(), context.getParent().getName()));
-
- // Send STOP-APP
- MCMPRequest request = MCMPUtils.createStopAppRequest(context);
- this.mcmpHandler.sendRequest(request);
- }
-
- public void removeContext(Context context)
- {
- this.checkInit();
-
- log.debug(this.sm.getString("modcluster.context.disable", context.getPath(), context.getParent().getName(), ((StandardContext) context).getState()));
-
- // JVMRoute can be null here if nothing was ever initialized
- if (Utils.getJvmRoute(context) != null)
- {
- MCMPRequest request = MCMPUtils.createRemoveAppRequest(context);
- this.mcmpHandler.sendRequest(request);
- }
- }
-
- public void removeAll(Engine engine)
- {
- this.checkInit();
-
- log.debug(this.sm.getString("modcluster.engine.stop", engine.getName()));
-
- // JVMRoute can be null here if nothing was ever initialized
- if (engine.getJvmRoute() != null)
- {
- // Send REMOVE-APP * request
- MCMPRequest request = MCMPUtils.createRemoveAllRequest(engine);
- this.mcmpHandler.sendRequest(request);
- }
- }
-
- public void status(Engine engine)
- {
- this.checkInit();
-
- log.debug(this.sm.getString("modcluster.engine.status", engine.getName()));
-
- this.mcmpHandler.status();
-
- // Send STATUS request
- int lbf = this.getLoadBalanceFactorProvider().getLoadBalanceFactor();
- MCMPRequest request = MCMPUtils.createStatusRequest(engine, lbf);
- this.mcmpHandler.sendRequest(request);
- }
-
- // ----------------------------------------------------------------- Public
-
- public BalancerConfiguration getBalancerConfiguration()
- {
- return this.balancerConfiguration;
- }
-
- public NodeConfiguration getNodeConfiguration()
- {
- return this.nodeConfiguration;
- }
-
- public LoadBalanceFactorProvider getLoadBalanceFactorProvider()
- {
- return this.loadBalanceFactorProvider;
- }
-
- // ---------------------------------------------------------------- Private
-
- private void checkInit()
- {
- if (!this.init)
- {
- throw new IllegalStateException(this.sm.getString("modcluster.error.uninitialized"));
- }
- }
-
- /**
- * Stop the advertise listener.
- */
- private void stopListener()
- {
- if (this.advertiseListener != null)
- {
- try
- {
- this.advertiseListener.destroy();
- }
- catch (IOException e)
- {
- log.error(this.sm.getString("modcluster.error.stopListener"), e);
- }
- this.advertiseListener = null;
- }
- }
-}
Deleted: trunk/tomcat/src/main/org/jboss/web/tomcat/service/modcluster/JBossWebEventHandler.java
===================================================================
--- trunk/tomcat/src/main/org/jboss/web/tomcat/service/modcluster/JBossWebEventHandler.java 2008-09-03 18:23:47 UTC (rev 77861)
+++ trunk/tomcat/src/main/org/jboss/web/tomcat/service/modcluster/JBossWebEventHandler.java 2008-09-03 19:01:23 UTC (rev 77862)
@@ -1,55 +0,0 @@
-/*
- * 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.web.tomcat.service.modcluster;
-
-import org.apache.catalina.Context;
-import org.apache.catalina.Engine;
-import org.apache.catalina.Server;
-
-/**
- * Handles events notifications coming from JBoss Web via a cluster listener.
- *
- * @author Brian Stansberry
- */
-public interface JBossWebEventHandler
-{
- void init();
- void shutdown();
-
- void addContext(Context context);
-
- void startContext(Context context);
-
- void stopContext(Context context);
-
- void removeContext(Context context);
-
- void config(Engine engine);
-
- void removeAll(Engine engine);
-
- void status(Engine engine);
-
- void startServer(Server server);
-
- void stopServer(Server server);
-}
\ No newline at end of file
Deleted: trunk/tomcat/src/main/org/jboss/web/tomcat/service/modcluster/LocalStrings.properties
===================================================================
--- trunk/tomcat/src/main/org/jboss/web/tomcat/service/modcluster/LocalStrings.properties 2008-09-03 18:23:47 UTC (rev 77861)
+++ trunk/tomcat/src/main/org/jboss/web/tomcat/service/modcluster/LocalStrings.properties 2008-09-03 19:01:23 UTC (rev 77862)
@@ -1,40 +0,0 @@
-# Regular messages
-modcluster.context.disable=Undeploy context [{0}] with state [{2}] to Host [{1}]
-modcluster.context.enable=Deploy context [{0}] with state [{2}] to Host [{1}]
-modcluster.context.start=Start context [{0}] in Host [{1}]
-modcluster.context.stop=Stop context [{0}] in Host [{1}]
-modcluster.engine.config=Sending configuration for engine [{0}]
-modcluster.engine.status=Check status for engine [{0}]
-modcluster.engine.stop=Stop all web applications for engine [{0}]
-modcluster.request=Sending command [{0}] wildcard [{1}] to proxy [{2}]
-modcluster.singleton.ignorestop=Ignoring call to stopOldMaster for domain [{0}] as we are in domain [{1}]
-modcluster.util.address=Detected local address [{0}]
-modcluster.util.jvmRoute=Engine [{0}] will use jvmRoute [{1}]
-
-# Error messages
-modcluster.error.addressJvmRoute=Error connecting to proxy to determine Engine.JVMRoute or Connector.address
-modcluster.error.discovery.add=Failure notifying master of added proxy [{0}]:[{1}]
-modcluster.error.discovery.remove=Failure notifying master of removed proxy [{0}]:[{1}]
-modcluster.error.drm="Error updating DRM
-modcluster.error.invalidHost=Invalid host specified: {0}
-modcluster.error.io=IO error sending command {0} to proxy {1}
-modcluster.error.jmxRegister=Error during JMX registration
-modcluster.error.jmxUnregister=Error during JMX unregistration
-modcluster.error.noproxy=No proxy list or URL configured, advertise disabled and no localhost available; connect connect to mod_cluster
-modcluster.error.nonPositiveAttribute=Invalid {0} specified [{1}] - must be a positive number.
-modcluster.error.nullAttribute=Value for attribute {0} cannot be null
-modcluster.error.other=Error [{2}: {3}] sending command {0} to proxy {1}, configuration will be reset
-modcluster.error.iae.null=[{0}] is null
-modcluster.error.iae.invalid="Invalid value [{0}] for [{1}]
-modcluster.error.parse=Error parsing response header for command {0}
-modcluster.error.rpc.known=Call to [{0}] received throwable from [{1}]
-modcluster.error.rpc.noresp=No valid response to RPC [{0}]
-modcluster.error.rpc.unknown=Call to [{0}] received throwable from unknown server
-modcluster.error.rpc.unexpected=Unexpected response [{0}] to RPC [{1}]
-modcluster.error.startListener=Error starting advertise listener
-modcluster.error.status.complete=Caught exception advising cluster of status upddate completion
-modcluster.error.status.unsupported=status() should not be invoked on ClusteredMCMPHandler
-modcluster.error.stopListener=Error stopping advertise listener
-modcluster.error.stopOldMaster=Call to stopOldMaster failed. New master singleton will not start.
-modcluster.error.syntax=Unrecoverable syntax error [{2}: {3}] sending command {0} to proxy {1}
-modcluster.error.uninitialized=Not initialized; call init() first
\ No newline at end of file
Deleted: trunk/tomcat/src/main/org/jboss/web/tomcat/service/modcluster/ModClusterService.java
===================================================================
--- trunk/tomcat/src/main/org/jboss/web/tomcat/service/modcluster/ModClusterService.java 2008-09-03 18:23:47 UTC (rev 77861)
+++ trunk/tomcat/src/main/org/jboss/web/tomcat/service/modcluster/ModClusterService.java 2008-09-03 19:01:23 UTC (rev 77862)
@@ -1,913 +0,0 @@
-/*
- * JBoss, Home of Professional Open Source.
- * Copyright 2006, 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.web.tomcat.service.modcluster;
-
-import java.io.Serializable;
-import java.util.ArrayList;
-import java.util.Collection;
-import java.util.HashMap;
-import java.util.HashSet;
-import java.util.List;
-import java.util.Map;
-import java.util.Set;
-
-import org.apache.catalina.Context;
-import org.apache.catalina.Engine;
-import org.apache.catalina.Server;
-import org.apache.catalina.util.StringManager;
-import org.jboss.beans.metadata.api.annotations.Inject;
-import org.jboss.beans.metadata.api.model.FromContext;
-import org.jboss.ha.framework.interfaces.ClusterNode;
-import org.jboss.ha.framework.interfaces.DistributedReplicantManager;
-import org.jboss.ha.framework.interfaces.HAPartition;
-import org.jboss.ha.framework.interfaces.HASingletonElectionPolicy;
-import org.jboss.ha.framework.server.HAServiceEvent;
-import org.jboss.ha.framework.server.HAServiceEventFactory;
-import org.jboss.ha.framework.server.HAServiceImpl;
-import org.jboss.ha.framework.server.HAServiceRpcHandler;
-import org.jboss.ha.framework.server.HASingletonImpl;
-import org.jboss.web.tomcat.service.modcluster.config.BalancerConfiguration;
-import org.jboss.web.tomcat.service.modcluster.config.MCMPHandlerConfiguration;
-import org.jboss.web.tomcat.service.modcluster.config.ModClusterConfig;
-import org.jboss.web.tomcat.service.modcluster.config.NodeConfiguration;
-import org.jboss.web.tomcat.service.modcluster.ha.ClusteredMCMPHandler;
-import org.jboss.web.tomcat.service.modcluster.ha.ClusteredMCMPHandlerImpl;
-import org.jboss.web.tomcat.service.modcluster.ha.HASingletonAwareResetRequestSource;
-import org.jboss.web.tomcat.service.modcluster.ha.ModClusterServiceDRMEntry;
-import org.jboss.web.tomcat.service.modcluster.ha.rpc.BooleanGroupRpcResponse;
-import org.jboss.web.tomcat.service.modcluster.ha.rpc.ClusteredMCMPHandlerRpcHandler;
-import org.jboss.web.tomcat.service.modcluster.ha.rpc.GroupRpcResponse;
-import org.jboss.web.tomcat.service.modcluster.ha.rpc.MCMPServerDiscoveryEvent;
-import org.jboss.web.tomcat.service.modcluster.ha.rpc.ModClusterServiceRpcHandler;
-import org.jboss.web.tomcat.service.modcluster.ha.rpc.ModClusterServiceStateGroupRpcResponse;
-import org.jboss.web.tomcat.service.modcluster.ha.rpc.PeerMCMPDiscoveryStatus;
-import org.jboss.web.tomcat.service.modcluster.ha.rpc.ResetRequestGroupRpcResponse;
-import org.jboss.web.tomcat.service.modcluster.ha.rpc.ResetRequestSourceRpcHandler;
-import org.jboss.web.tomcat.service.modcluster.ha.rpc.StringGroupRpcResponse;
-import org.jboss.web.tomcat.service.modcluster.ha.rpc.ThrowableGroupRpcResponse;
-import org.jboss.web.tomcat.service.modcluster.load.LoadBalanceFactorProvider;
-import org.jboss.web.tomcat.service.modcluster.mcmp.AddressPort;
-import org.jboss.web.tomcat.service.modcluster.mcmp.MCMPHandler;
-import org.jboss.web.tomcat.service.modcluster.mcmp.MCMPRequest;
-import org.jboss.web.tomcat.service.modcluster.mcmp.MCMPServer;
-import org.jboss.web.tomcat.service.modcluster.mcmp.MCMPServerState;
-import org.jboss.web.tomcat.service.modcluster.mcmp.MCMPUtils;
-import org.jboss.web.tomcat.service.modcluster.mcmp.impl.DefaultMCMPHandler;
-
-/**
- * A ModClusterService.
- *
- * @author Brian Stansberry
- * @version $Revision$
- */
-public class ModClusterService extends HASingletonImpl<HAServiceEvent>
- implements JBossWebEventHandler, ModClusterServiceMBean, ModClusterServiceRpcHandler<List<?>, MCMPServerState>
-{
- private static final Class<?>[] CLUSTER_STATUS_COMPLETE_TYPES = new Class[] { Map.class };
- private static final Class<?>[] GET_CLUSTER_COORDINATOR_STATE_TYPES = new Class[] { Set.class };
-
- // ----------------------------------------------------------------- Fields
-
- final MCMPHandler localHandler;
- final ClusteredMCMPHandler clusteredHandler;
- final HASingletonAwareResetRequestSource resetRequestSource;
- final Map<ClusterNode, MCMPServerDiscoveryEvent> proxyChangeDigest =
- new HashMap<ClusterNode, MCMPServerDiscoveryEvent>();
-
- /**
- * The string manager for this package.
- */
- final StringManager sm = StringManager.getManager(Constants.Package);
-
- private final LoadBalanceFactorProvider loadManager;
- private final RpcHandler rpcHandler;
- private final JBossWebEventHandler eventHandlerDelegate;
- private final String domain;
- private final boolean masterPerDomain;
-
- volatile int latestLoad;
- private volatile int statusCount = 0;
- private volatile int processStatusFrequency = 1;
- private ModClusterServiceDRMEntry drmEntry;
-
- /**
- * Create a new ClusterCoordinator.
- *
- * @param partition the partition of which we are a member
- * @param config our configuration
- * @param loadFactorProvider source for local load balance statistics
- */
- public ModClusterService(HAPartition partition,
- ModClusterConfig config,
- LoadBalanceFactorProvider loadFactorProvider)
- {
- this(partition, config, loadFactorProvider, null);
- }
-
-
- /**
- * Create a new ClusterCoordinator.
- *
- * @param partition the partition of which we are a member
- * @param config our configuration
- * @param loadFactorProvider source for local load balance statistics
- * @param singletonElector chooses the singleton master
- */
- public ModClusterService(HAPartition partition,
- ModClusterConfig config,
- LoadBalanceFactorProvider loadFactorProvider,
- HASingletonElectionPolicy electionPolicy)
- {
- super(new HAServiceEventFactory());
-
- assert partition != null : this.sm.getString("modcluster.error.iae.null", "partition");
- assert loadFactorProvider != null : this.sm.getString("modcluster.error.iae.null", "loadFactorProvider");
- assert config != null : this.sm.getString("modcluster.error.iae.null", "config is null");
-
- this.setHAPartition(partition);
-
- this.resetRequestSource = new HASingletonAwareResetRequestSource(config, config, this);
- this.localHandler = new DefaultMCMPHandler(config, this.resetRequestSource);
-// this.localHandler.init();
- this.clusteredHandler = new ClusteredMCMPHandlerImpl(this.localHandler, this);
- this.loadManager = loadFactorProvider;
- this.eventHandlerDelegate = new DefaultJBossWebEventHandler(config, config, this.clusteredHandler, loadFactorProvider);
- this.domain = config.getDomain();
- this.masterPerDomain = config.isMasterPerDomain();
-
- this.setElectionPolicy(electionPolicy);
-
- this.drmEntry = new ModClusterServiceDRMEntry(partition.getClusterNode(), null);
-
- this.rpcHandler = new RpcHandler();
- }
-
- /**
- * Create a new ClusterCoordinator using the given component parts.
- * Only intended for use by test suites that may wish to inject
- * mock components.
- *
- * @param partition
- * @param nodeConfig
- * @param balancerConfig
- * @param localHandler
- * @param resetRequestSource
- * @param clusteredHandler
- * @param loadManager
- * @param singletonElector
- */
- protected ModClusterService(HAPartition partition,
- NodeConfiguration nodeConfig,
- BalancerConfiguration balancerConfig,
- MCMPHandlerConfiguration mcmpHandlerConfig,
- MCMPHandler localHandler,
- HASingletonAwareResetRequestSource resetRequestSource,
- ClusteredMCMPHandler clusteredHandler,
- LoadBalanceFactorProvider loadManager,
- HASingletonElectionPolicy electionPolicy)
- {
- super(new HAServiceEventFactory());
-
- assert partition != null : this.sm.getString("modcluster.error.iae.null", "partition");
- assert localHandler != null : this.sm.getString("modcluster.error.iae.null", "localHandler");
- assert loadManager != null : this.sm.getString("modcluster.error.iae.null", "loadManager");
- assert resetRequestSource != null : this.sm.getString("modcluster.error.iae.null", "resetRequestSource");
- assert nodeConfig != null : this.sm.getString("modcluster.error.iae.null", "nodeConfig");
- assert balancerConfig != null : this.sm.getString("modcluster.error.iae.null", "balancerConfig");
- assert clusteredHandler != null : this.sm.getString("modcluster.error.iae.null", "clusteredHandler");
-
- this.setHAPartition(partition);
-
- this.localHandler = localHandler;
- this.resetRequestSource = resetRequestSource;
- this.clusteredHandler = clusteredHandler;
- this.loadManager = loadManager;
- this.eventHandlerDelegate = new DefaultJBossWebEventHandler(nodeConfig, balancerConfig, clusteredHandler, loadManager);
- this.domain = nodeConfig.getDomain();
- this.masterPerDomain = mcmpHandlerConfig.isMasterPerDomain();
-
- this.setElectionPolicy(electionPolicy);
-
- this.drmEntry = new ModClusterServiceDRMEntry(partition.getClusterNode(), null);
-
- this.rpcHandler = new RpcHandler();
- }
-
- // -------------------------------------------------- ModClusterServiceMBean
-
- public void addProxy(String host, int port)
- {
- this.clusteredHandler.addProxy(host, port);
- }
-
-
- public void removeProxy(String host, int port)
- {
- this.clusteredHandler.removeProxy(host, port);
- }
-
-
- public String getProxyConfiguration()
- {
- return this.clusteredHandler.getProxyConfiguration();
- }
-
-
- public void refresh()
- {
- this.clusteredHandler.markProxiesInError();
- }
-
-
- public void reset()
- {
- this.clusteredHandler.reset();
- }
-
-
- // ---------------------------------------------------- JBossWebEventHandler
-
-
- public void init()
- {
- // Use the standard logic
- this.eventHandlerDelegate.init();
- }
-
- public void shutdown()
- {
- // Use the standard logic
- this.eventHandlerDelegate.shutdown();
- }
-
-
- public void startServer(Server server)
- {
- // Pass on ref to our server
- this.resetRequestSource.setJbossWebServer(server);
-
- // Use the standard logic
- this.eventHandlerDelegate.startServer(server);
- }
-
- public void stopServer(Server server)
- {
- // Use the standard logic
- this.eventHandlerDelegate.stopServer(server);
- }
-
- public void config(Engine engine)
- {
- // If needed, create automagical JVM route (address + port + engineName)
- try
- {
- Utils.establishJvmRouteAndConnectorAddress(engine, this.clusteredHandler);
- }
- catch (Exception e) {
- this.clusteredHandler.markProxiesInError();
- this.log.info(this.sm.getString("modcluster.error.addressJvmRoute"), e);
- return;
- }
-
- this.drmEntry.addJvmRoute(engine.getJvmRoute());
- this.updateLocalDRM(this.drmEntry);
-
- // Use the standard logic
- this.eventHandlerDelegate.config(engine);
- }
-
- public void removeAll(Engine engine)
- {
- // Use the standard logic
- this.eventHandlerDelegate.removeAll(engine);
-
- this.drmEntry.removeJvmRoute(engine.getJvmRoute());
- this.updateLocalDRM(this.drmEntry);
- }
-
- public void addContext(Context context)
- {
- // Use the standard logic
- this.eventHandlerDelegate.addContext(context);
- }
-
- public void startContext(Context context)
- {
- // Use the standard logic
- this.eventHandlerDelegate.startContext(context);
- }
-
- public void stopContext(Context context)
- {
- // Use the standard logic
- this.eventHandlerDelegate.stopContext(context);
- }
-
- public void removeContext(Context context)
- {
- // Use the standard logic
- this.eventHandlerDelegate.removeContext(context);
- }
-
- public void status(Engine engine)
- {
- this.latestLoad = this.loadManager.getLoadBalanceFactor();
-
- if (this.isMasterNode())
- {
- this.statusCount = (this.statusCount + 1) % this.processStatusFrequency;
- if (this.statusCount == 0)
- {
- this.updateClusterStatus();
- }
- }
- }
-
-
- // ------------------------------------------------------------- Properties
-
- public String getDomain()
- {
- return this.domain;
- }
-
- public int getProcessStatusFrequency()
- {
- return this.processStatusFrequency;
- }
-
- public void setProcessStatusFrequency(int processStatusFrequency)
- {
- this.processStatusFrequency = processStatusFrequency;
- }
-
-
- // ------------------------------------------------------- Public Overrides
-
- @Override
- public void startSingleton()
- {
- super.startSingleton();
-
- this.clusteredHandler.setMasterNode(true);
- this.resetRequestSource.setMasterNode(true);
-
- // Ensure we do a full status on the next event
- this.statusCount = this.processStatusFrequency - 1;
- }
-
- @Override
- public void stopSingleton()
- {
- super.stopSingleton();
-
- this.clusteredHandler.setMasterNode(false);
- this.resetRequestSource.setMasterNode(false);
- }
-
- @Override
- @Inject(fromContext = FromContext.NAME)
- public void setServiceHAName(String haName)
- {
- super.setServiceHAName(haName);
- }
-
- // -------------------------------------------------------------- Protected
-
- /**
- * {@inheritDoc}
- *
- * @return an inner class that allows us to avoid exposing RPC methods as
- * public methods of this class
- */
- @Override
- protected HAServiceRpcHandler<HAServiceEvent> getRpcHandler()
- {
- return this.rpcHandler;
- }
-
- /**
- * {@inheritDoc}
- *
- * @returns the key used by DRM and the partition rpc handler mapping.
- */
- @Override
- public String getHAServiceKey()
- {
- String name = this.getServiceHAName();
-
- return ((this.domain != null) && this.masterPerDomain) ? name + ":" + this.domain : name;
- }
-
- /**
- * {@inheritDoc}
- *
- * @return a {@link ModClusterServiceDRMEntry}
- */
- @Override
- protected Serializable getReplicant()
- {
- return this.drmEntry;
- }
-
- /**
- * {@inheritDoc}
- * @return a list of cluster nodes from which to elect a new master
- */
- @Override
- @SuppressWarnings("unchecked")
- protected List<ClusterNode> getElectionCandidates()
- {
- List<ModClusterServiceDRMEntry> candidates = this.getHAPartition().getDistributedReplicantManager().lookupReplicants(this.getHAServiceKey());
-
- return this.narrowCandidateList(candidates);
- }
-
- /**
- * Processes the candidate list, discarding those who don't match our domain nor the best
- * candidate when it comes to the ability to communicate with proxies.
- *
- * @param candidates the universe of possible candidates.
- * @return a list of candidates with an equivalent ability to communicate
- * with proxies, or <code>null</code> if <code>candidates</code>
- * is <code>null</code>.
- */
- List<ClusterNode> narrowCandidateList(Collection<ModClusterServiceDRMEntry> candidates)
- {
- if (candidates == null) return null;
-
- List<ClusterNode> narrowed = new ArrayList<ClusterNode>(candidates.size());
- ModClusterServiceDRMEntry champion = null;
-
- for (ModClusterServiceDRMEntry candidate : candidates)
- {
- if (champion == null)
- {
- champion = candidate;
- narrowed.add(candidate.getPeer());
- }
- else
- {
- int compFactor = candidate.compareTo(champion);
- if (compFactor < 0)
- {
- // New champ
- narrowed.clear();
- champion = candidate;
- narrowed.add(candidate.getPeer());
- }
- else if (compFactor == 0)
- {
- // As good as our champ
- narrowed.add(candidate.getPeer());
- }
- // else candidate didn't make the cut; continue
- }
- }
-
- return narrowed;
- }
-
- @SuppressWarnings("unchecked")
- private void updateClusterStatus()
- {
- this.localHandler.status();
- Set<MCMPServerState> masterList = null;
- Map<ClusterNode, MCMPServerDiscoveryEvent> latestEvents = null;
- synchronized (this.proxyChangeDigest)
- {
- masterList = this.localHandler.getProxyStates();
- latestEvents = new HashMap<ClusterNode, MCMPServerDiscoveryEvent>(this.proxyChangeDigest);
- }
- HAPartition partition = this.getHAPartition();
- List<ModClusterServiceDRMEntry> replicants = partition.getDistributedReplicantManager().lookupReplicants(this.getHAServiceKey());
- Map<ClusterNode, ModClusterServiceDRMEntry> nonresponsive = new HashMap<ClusterNode, ModClusterServiceDRMEntry>();
- for (ModClusterServiceDRMEntry replicant : replicants)
- {
- nonresponsive.put(replicant.getPeer(), replicant);
- }
- nonresponsive.remove(partition.getClusterNode());
-
- // FIXME -- what about our own dropped discovery events if we just became master?
- List responses = this.getClusterCoordinatorState(masterList);
-
- // Gather up all the reset requests in one list
- // FIXME -- what about our own dropped requests if we just became master?
- List<MCMPRequest> resetRequests = new ArrayList<MCMPRequest>();
-
- // Gather all the load balance factors
- Map<String, Integer> loadBalanceFactors = new HashMap<String, Integer>();
-
- // Gather the info on who knows about what proxies
- Map<ClusterNode, PeerMCMPDiscoveryStatus> statuses = new HashMap<ClusterNode, PeerMCMPDiscoveryStatus>();
-
- boolean resync = false;
- for (Object response : responses)
- {
- if (response instanceof ModClusterServiceStateGroupRpcResponse)
- {
- ModClusterServiceStateGroupRpcResponse mcssgrr = (ModClusterServiceStateGroupRpcResponse) response;
- ClusterNode cn = mcssgrr.getSender();
-
- // Check for discovery events we haven't processed
- MCMPServerDiscoveryEvent latestEvent = latestEvents.get(cn);
- for (MCMPServerDiscoveryEvent toCheck : mcssgrr.getUnacknowledgedEvents())
- {
- if (latestEvent != null && latestEvent.getEventIndex() <= toCheck.getEventIndex())
- {
- continue; // already processed it
- }
-
- AddressPort ap = toCheck.getMCMPServer();
- if (toCheck.isAddition())
- {
- this.localHandler.addProxy(ap.address, ap.port);
- }
- else
- {
- this.localHandler.removeProxy(ap.address, ap.port);
- }
- resync = true;
- }
-
- if (!resync) // don't bother if we are going to start over
- {
- statuses.put(cn, new PeerMCMPDiscoveryStatus(cn, mcssgrr.getStates(), latestEvent));
-
- List<MCMPRequest> toAdd = mcssgrr.getResetRequests();
- if (toAdd != null)
- {
- resetRequests.addAll(toAdd);
- }
-
- ModClusterServiceDRMEntry removed = nonresponsive.remove(cn);
- if (removed != null)
- {
- Integer lbf = new Integer(mcssgrr.getLoadBalanceFactor());
- for (String jvmRoute : removed.getJvmRoutes())
- {
- loadBalanceFactors.put(jvmRoute, lbf);
- }
- }
- }
- }
- else if (response instanceof ThrowableGroupRpcResponse)
- {
- ThrowableGroupRpcResponse tgrr = (ThrowableGroupRpcResponse) response;
- ClusterNode cn = tgrr.getSender();
-
- this.log.warn(this.sm.getString("modcluster.error.rpc.known", "getClusterCoordinatorState", cn), tgrr.getValue());
-
- // Don't remove from nonresponsive list and we'll pass back an error
- // status (null server list) to this peer
- }
- else if (response instanceof Throwable)
- {
- this.log.warn(this.sm.getString("modcluster.error.rpc.unknown", "getClusterCoordinatorState"), (Throwable) response);
- }
- else
- {
- this.log.error(this.sm.getString("modcluster.error.rpc.unexpected", response, "getClusterCoordinatorState"));
- }
- }
-
- if (resync)
- {
- // We picked up previously unknown discovery events; start over
- this.updateClusterStatus();
- return;
- }
-
- // Add error-state objects for non-responsive peers
- Integer lbf = new Integer(0);
- for (Map.Entry<ClusterNode, ModClusterServiceDRMEntry> entry : nonresponsive.entrySet())
- {
- ClusterNode cn = entry.getKey();
- statuses.put(entry.getKey(), new PeerMCMPDiscoveryStatus(cn, null, latestEvents.get(cn)));
-
- for (String jvmRoute : entry.getValue().getJvmRoutes())
- {
- loadBalanceFactors.put(jvmRoute, lbf);
- }
- }
-
- // FIXME handle crashed members, gone from DRM
-
- // Advise the proxies of any reset requests
- this.localHandler.sendRequests(resetRequests);
-
- // Pass along the LBF values
- List<MCMPRequest> statusRequests = new ArrayList<MCMPRequest>();
- for (Map.Entry<String, Integer> entry : loadBalanceFactors.entrySet())
- {
- statusRequests.add(MCMPUtils.createStatusRequest(entry.getKey(), entry.getValue().intValue()));
- }
- this.localHandler.sendRequests(statusRequests);
-
- // Advise the members the process is done and that they should update DRM
- this.notifyClusterStatusComplete(masterList, statuses);
- }
-
- private void notifyClusterStatusComplete(Set<MCMPServerState> masterList,
- Map<ClusterNode, PeerMCMPDiscoveryStatus> statuses)
- {
- HAPartition partition = this.getHAPartition();
-
- // Determine who should update DRM first -- us or the rest of the nodes
- Set<ModClusterServiceDRMEntry> allStatuses = new HashSet<ModClusterServiceDRMEntry>(statuses.values());
- ModClusterServiceDRMEntry ourCurrentStatus = (ModClusterServiceDRMEntry) partition.getDistributedReplicantManager().lookupLocalReplicant(this.getHAServiceKey());
- allStatuses.add(ourCurrentStatus);
-
- boolean othersFirst = this.narrowCandidateList(allStatuses).contains(partition.getClusterNode());
- ModClusterServiceDRMEntry ourNewStatus = new ModClusterServiceDRMEntry(partition.getClusterNode(), masterList);
- boolean updated = (ourNewStatus.equals(ourCurrentStatus) == false);
-
- if (othersFirst)
- {
- this.clusterStatusComplete(statuses);
-
- if (updated)
- {
- this.updateLocalDRM(ourNewStatus);
- }
- }
- else
- {
- if (updated)
- {
- this.updateLocalDRM(ourNewStatus);
- }
-
- this.clusterStatusComplete(statuses);
- }
- }
-
- /**
- * @see org.jboss.web.tomcat.service.modcluster.ha.rpc.ModClusterServiceRpcHandler#clusterStatusComplete(java.util.Map)
- */
- public void clusterStatusComplete(Map<ClusterNode, PeerMCMPDiscoveryStatus> statuses)
- {
- try
- {
- this.callMethodOnPartition("clusterStatusComplete", new Object[] { statuses }, CLUSTER_STATUS_COMPLETE_TYPES);
- }
- catch (Exception e)
- {
- this.log.error(this.sm.getString("modcluster.error.status.complete"), e);
- }
- }
-
- /**
- * @see org.jboss.web.tomcat.service.modcluster.ha.rpc.ModClusterServiceRpcHandler#getClusterCoordinatorState(java.util.Set)
- */
- public List<?> getClusterCoordinatorState(Set<MCMPServerState> masterList)
- {
- try
- {
- return this.callMethodOnPartition("getClusterCoordinatorState", new Object[] { masterList }, GET_CLUSTER_COORDINATOR_STATE_TYPES);
- }
- catch (Exception e)
- {
- throw Utils.convertToUnchecked(e);
- }
- }
-
- private void updateLocalDRM(ModClusterServiceDRMEntry ourNewStatus) throws Error
- {
- try
- {
- this.getHAPartition().getDistributedReplicantManager().add(this.getHAServiceKey(), ourNewStatus);
- }
- catch (Exception e)
- {
- throw Utils.convertToUnchecked(e);
- }
- }
-
- // ---------------------------------------------------------- Inner classes
-
- /**
- * This is the object that gets invoked on via reflection by HAPartition.
- */
- protected class RpcHandler extends HAServiceImpl<HAServiceEvent>.RpcHandler implements ModClusterServiceRpcHandler<GroupRpcResponse, MCMPServer>, ClusteredMCMPHandlerRpcHandler, ResetRequestSourceRpcHandler<GroupRpcResponse>
- {
- private final ModClusterService coord = ModClusterService.this;
- private final GroupRpcResponse SUCCESS = new GroupRpcResponse(this.coord.getHAPartition().getClusterNode());
-/*
- public GroupRpcResponse getLocalAddress() throws IOException
- {
- if (this.coord.isMasterNode())
- {
- return new InetAddressGroupRpcResponse(this.coord.getHAPartition().getClusterNode(),
- this.coord.localHandler.getLocalAddress());
- }
-
- return null;
- }
-*/
- /**
- * @see org.jboss.web.tomcat.service.modcluster.ha.rpc.ClusteredMCMPHandlerRpcHandler#mcmpServerDiscoveryEvent(org.jboss.web.tomcat.service.modcluster.ha.rpc.MCMPServerDiscoveryEvent)
- */
- public GroupRpcResponse mcmpServerDiscoveryEvent(MCMPServerDiscoveryEvent event)
- {
- if (this.coord.isMasterNode())
- {
- synchronized (ModClusterService.this.proxyChangeDigest)
- {
- AddressPort ap = event.getMCMPServer();
- if (event.isAddition())
- {
- this.coord.localHandler.addProxy(ap.address, ap.port);
- }
- else
- {
- this.coord.localHandler.removeProxy(ap.address, ap.port);
- }
- ModClusterService.this.proxyChangeDigest.put(event.getSender(), event);
- return new GroupRpcResponse(ModClusterService.this.getHAPartition().getClusterNode());
- }
- }
-
- return null;
- }
-
- /**
- * @see org.jboss.web.tomcat.service.modcluster.ha.rpc.ModClusterServiceRpcHandler#getClusterCoordinatorState(java.util.Set)
- */
- public GroupRpcResponse getClusterCoordinatorState(Set<MCMPServer> masterList)
- {
- if (this.coord.isMasterNode() == false)
- {
- Set<MCMPServerState> ourStates = this.coord.clusteredHandler.updateServersFromMasterNode(masterList);
-
- List<MCMPRequest> resetRequests = null;
- boolean needReset = this.coord.clusteredHandler.getNeedsResetTransmission();
- if (needReset)
- {
- resetRequests = this.coord.resetRequestSource.getLocalResetRequests();
- }
-
- GroupRpcResponse response =
- new ModClusterServiceStateGroupRpcResponse(ModClusterService.this.getHAPartition().getClusterNode(),
- this.coord.latestLoad,
- ourStates,
- this.coord.clusteredHandler.getPendingDiscoveryEvents(),
- resetRequests);
-
- if (needReset)
- {
- this.coord.clusteredHandler.recordResetTransmission();
- }
-
- return response;
- }
-
- // TODO is this the correct response here?
- return null;
- }
-
- /**
- * @see org.jboss.web.tomcat.service.modcluster.ha.rpc.ModClusterServiceRpcHandler#clusterStatusComplete(java.util.Map)
- */
- public void clusterStatusComplete(Map<ClusterNode, PeerMCMPDiscoveryStatus> statuses)
- {
- HAPartition partition = this.coord.getHAPartition();
- ClusterNode cn = partition.getClusterNode();
- PeerMCMPDiscoveryStatus newStatus = statuses.get(cn);
- if (newStatus != null)
- {
- // Notify our handler that discovery events have been processed
- this.coord.clusteredHandler.discoveryEventsReceived(newStatus.getLatestDiscoveryEvent());
-
- // Notify our handler that any reset requests have been processed
- this.coord.clusteredHandler.recordResetSuccess();
-
- DistributedReplicantManager drm = partition.getDistributedReplicantManager();
- String key = this.coord.getHAServiceKey();
- ModClusterServiceDRMEntry oldStatus = (ModClusterServiceDRMEntry) drm.lookupLocalReplicant(key);
- if (newStatus.equals(oldStatus) == false)
- {
- try
- {
- drm.add(key, new ModClusterServiceDRMEntry(cn, newStatus.getMCMPServerStates()));
- }
- catch (Exception e)
- {
- this.coord.log.error(ModClusterService.this.sm.getString("modcluster.error.drm"), e);
- }
- }
- }
- }
-
- /**
- * @see org.jboss.web.tomcat.service.modcluster.ha.rpc.ClusteredMCMPHandlerRpcHandler#getProxyConfiguration()
- */
- public GroupRpcResponse getProxyConfiguration()
- {
- if (this.coord.isMasterNode())
- {
- return new StringGroupRpcResponse(ModClusterService.this.getHAPartition().getClusterNode(), this.coord.localHandler.getProxyConfiguration());
- }
-
- return null;
- }
-
- /**
- * @see org.jboss.web.tomcat.service.modcluster.ha.rpc.ClusteredMCMPHandlerRpcHandler#isProxyHealthOK()
- */
- public GroupRpcResponse isProxyHealthOK()
- {
- if (this.coord.isMasterNode())
- {
- return new BooleanGroupRpcResponse(ModClusterService.this.getHAPartition().getClusterNode(), this.coord.localHandler.isProxyHealthOK());
- }
-
- return null;
- }
-
- /**
- * @see org.jboss.web.tomcat.service.modcluster.ha.rpc.ClusteredMCMPHandlerRpcHandler#markProxiesInError()
- */
- public GroupRpcResponse markProxiesInError()
- {
- if (this.coord.isMasterNode())
- {
- this.coord.localHandler.markProxiesInError();
- return this.SUCCESS;
- }
-
- return null;
- }
-
- /**
- * @see org.jboss.web.tomcat.service.modcluster.ha.rpc.ClusteredMCMPHandlerRpcHandler#reset()
- */
- public GroupRpcResponse reset()
- {
- if (this.coord.isMasterNode())
- {
- this.coord.localHandler.reset();
- return this.SUCCESS;
- }
-
- return null;
- }
-
- /**
- * @see org.jboss.web.tomcat.service.modcluster.ha.rpc.ClusteredMCMPHandlerRpcHandler#sendRequest(org.jboss.web.tomcat.service.modcluster.mcmp.MCMPRequest)
- */
- public GroupRpcResponse sendRequest(MCMPRequest request)
- {
- if (this.coord.isMasterNode())
- {
- this.coord.localHandler.sendRequest(request);
- return this.SUCCESS;
- }
-
- return null;
- }
-
- /**
- * @see org.jboss.web.tomcat.service.modcluster.ha.rpc.ClusteredMCMPHandlerRpcHandler#sendRequests(java.util.List)
- */
- public GroupRpcResponse sendRequests(List<MCMPRequest> requests)
- {
- if (this.coord.isMasterNode())
- {
- this.coord.localHandler.sendRequests(requests);
- return this.SUCCESS;
- }
-
- return null;
- }
-
- /**
- * @see org.jboss.web.tomcat.service.modcluster.ha.rpc.ResetRequestSourceRpcHandler#getResetRequests()
- */
- public GroupRpcResponse getResetRequests()
- {
- return new ResetRequestGroupRpcResponse(ModClusterService.this.getHAPartition().getClusterNode(),
- this.coord.resetRequestSource.getLocalResetRequests());
- }
- }
-}
Deleted: trunk/tomcat/src/main/org/jboss/web/tomcat/service/modcluster/ModClusterServiceMBean.java
===================================================================
--- trunk/tomcat/src/main/org/jboss/web/tomcat/service/modcluster/ModClusterServiceMBean.java 2008-09-03 18:23:47 UTC (rev 77861)
+++ trunk/tomcat/src/main/org/jboss/web/tomcat/service/modcluster/ModClusterServiceMBean.java 2008-09-03 19:01:23 UTC (rev 77862)
@@ -1,81 +0,0 @@
-/*
- * 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.web.tomcat.service.modcluster;
-
-import org.jboss.web.tomcat.service.modcluster.mcmp.MCMPRequestType;
-import org.jboss.web.tomcat.service.modcluster.mcmp.MCMPServerState;
-
-/**
- * StandardMBean interface for {@link ModClusterService}.
- *
- * @author Brian Stansberry
- */
-public interface ModClusterServiceMBean
-{
- /**
- * Add a proxy to the list of those with which this handler communicates.
- * Communication does not begin until the next call to {@link #status()}.
- *
- * @param host the hostname of the proxy; a string suitable for passing to
- * <code>InetAddress.getByHost(...)</code>
- * @param port the port on which the proxy listens for MCMP requests
- */
- void addProxy(String host, int port);
-
- /**
- * Remove a proxy from the list of those with which this handler communicates.
- * Communication does not end until the next call to {@link #status()}.
- *
- * @param host the hostname of the proxy; a string suitable for passing to
- * <code>InetAddress.getByHost(...)</code>
- * @param port the port on which the proxy listens for MCMP requests
- */
- void removeProxy(String host, int port);
-
- /**
- * Reset any proxies whose status is {@link MCMPServerState#DOWN DOWN} up to
- * {@link MCMPServerState#ERROR ERROR}, where the configuration will
- * be refreshed.
- */
- void reset();
-
- /**
- * FIXME. This is the same as markProxiesInError().
- *
- * Reset any proxies whose status is {@link MCMPServerState#OK OK} down to
- * {@link MCMPServerState#ERROR ERROR}, which will trigger a refresh of
- * their configuration. To be used through JMX or similar.
- */
- void refresh();
-
- /**
- * Sends a {@link MCMPRequestType#DUMP DUMP} request to all proxies,
- * concatentating their responses into a single string.
- *
- * TODO wouldn't a List<String> be better? Let the caller concatenate if
- * so desired.
- *
- * @return the configuration information from all the accessible proxies.
- */
- String getProxyConfiguration();
-}
Deleted: trunk/tomcat/src/main/org/jboss/web/tomcat/service/modcluster/Utils.java
===================================================================
--- trunk/tomcat/src/main/org/jboss/web/tomcat/service/modcluster/Utils.java 2008-09-03 18:23:47 UTC (rev 77861)
+++ trunk/tomcat/src/main/org/jboss/web/tomcat/service/modcluster/Utils.java 2008-09-03 19:01:23 UTC (rev 77862)
@@ -1,152 +0,0 @@
-package org.jboss.web.tomcat.service.modcluster;
-
-import java.io.IOException;
-import java.net.InetAddress;
-
-import org.apache.catalina.Context;
-import org.apache.catalina.Engine;
-import org.apache.catalina.Host;
-import org.apache.catalina.connector.Connector;
-import org.apache.catalina.util.StringManager;
-import org.apache.tomcat.util.IntrospectionUtils;
-import org.jboss.logging.Logger;
-import org.jboss.web.tomcat.service.modcluster.mcmp.MCMPHandler;
-
-public class Utils
-{
- private static final Logger log = Logger.getLogger(Utils.class);
- private static final StringManager sm = StringManager.getManager(Constants.Package);
-
- /**
- * Find the most likely connector the proxy server should connect to, or
- * accept connections from.
- *
- * @param connectors
- * @return
- */
- public static Connector findProxyConnector(Connector[] connectors)
- {
- int pos = 0;
- int maxThreads = 0;
- for (int i = 0; i < connectors.length; i++) {
- if (connectors[i].getProtocol().startsWith("AJP")) {
- // Return any AJP connector found
- return connectors[i];
- }
- if (Boolean.TRUE.equals(IntrospectionUtils.getProperty(connectors[i].getProtocolHandler(), "reverseConnection"))) {
- return connectors[i];
- }
- Integer mt = (Integer) IntrospectionUtils.getProperty(connectors[i].getProtocolHandler(), "maxThreads");
- if (mt.intValue() > maxThreads) {
- maxThreads = mt.intValue();
- pos = i;
- }
- }
- // If no AJP connector and no reverse, return the connector with the most threads
- return connectors[pos];
- }
-
- /**
- * Return the address on which the connector is bound.
- *
- * @param connector
- * @return
- */
- public static String getAddress(Connector connector)
- {
- InetAddress inetAddress =
- (InetAddress) IntrospectionUtils.getProperty(connector.getProtocolHandler(), "address");
- if (inetAddress == null) {
- // Should not happen
- return "127.0.0.1";
- } else {
- return inetAddress.getHostAddress();
- }
- }
-
- /**
- * Return the JvmRoute for the specified context.
- *
- * @param context
- * @return
- */
- public static String getJvmRoute(Context context)
- {
- return ((Engine) context.getParent().getParent()).getJvmRoute();
- }
-
- /**
- * Return the host and its alias list with which the context is associated.
- *
- * @param context
- * @return
- */
- public static String getHost(Context context)
- {
- StringBuffer result = new StringBuffer();
- Host host = (Host) context.getParent();
- result.append(host.getName());
- String[] aliases = host.findAliases();
- for (int i = 0; i < aliases.length; i++) {
- result.append(',');
- result.append(aliases[i]);
- }
- return result.toString();
- }
-
- public static void establishJvmRouteAndConnectorAddress(Engine engine, MCMPHandler mcmpHandler) throws IOException
- {
- Connector connector = findProxyConnector(engine.getService().findConnectors());
- InetAddress localAddress =
- (InetAddress) IntrospectionUtils.getProperty(connector.getProtocolHandler(), "address");
- if ((engine.getJvmRoute() == null || localAddress == null) && mcmpHandler.getProxyStates().size() > 0) {
- // Automagical JVM route (address + port + engineName)
- if (localAddress == null) {
- localAddress = mcmpHandler.getLocalAddress();
- if (localAddress != null) {
- IntrospectionUtils.setProperty(connector.getProtocolHandler(), "address", localAddress.getHostAddress());
- } else {
- // Should not happen
- IntrospectionUtils.setProperty(connector.getProtocolHandler(), "address", "127.0.0.1");
- }
- log.info(sm.getString("modcluster.util.address", localAddress.getHostAddress()));
- }
- if (engine.getJvmRoute() == null) {
- String hostName = null;
- if (localAddress != null) {
- hostName = localAddress.getHostName();
- } else {
- // Fallback
- hostName = "127.0.0.1";
- }
- String jvmRoute = hostName + ":" + connector.getPort() + ":" + engine.getName();
- engine.setJvmRoute(jvmRoute);
- log.info(sm.getString("modcluster.util.jvmRoute", engine.getName(), jvmRoute));
- }
- }
- }
-
- /**
- * Analyzes the type of the given Throwable, handing it back if it is a
- * RuntimeException, wrapping it in a RuntimeException if it is a checked
- * exception, or throwing it if it is an Error
- *
- * @param t the throwable
- * @return a RuntimeException based on t
- * @throws Error if t is an Error
- */
- public static RuntimeException convertToUnchecked(Throwable t) throws Error
- {
- if (t instanceof Error)
- throw (Error) t;
- else if (t instanceof RuntimeException)
- return (RuntimeException) t;
- else
- return new RuntimeException(t.getMessage(), t);
- }
-
- private Utils()
- {
- }
-
-}
\ No newline at end of file
Deleted: trunk/tomcat/src/main/org/jboss/web/tomcat/service/modcluster/ha/ClusteredMCMPHandler.java
===================================================================
--- trunk/tomcat/src/main/org/jboss/web/tomcat/service/modcluster/ha/ClusteredMCMPHandler.java 2008-09-03 18:23:47 UTC (rev 77861)
+++ trunk/tomcat/src/main/org/jboss/web/tomcat/service/modcluster/ha/ClusteredMCMPHandler.java 2008-09-03 19:01:23 UTC (rev 77862)
@@ -1,55 +0,0 @@
-/*
- * 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.web.tomcat.service.modcluster.ha;
-
-import java.util.List;
-import java.util.Set;
-
-import org.jboss.web.tomcat.service.modcluster.ha.rpc.MCMPServerDiscoveryEvent;
-import org.jboss.web.tomcat.service.modcluster.mcmp.MCMPHandler;
-import org.jboss.web.tomcat.service.modcluster.mcmp.MCMPServer;
-import org.jboss.web.tomcat.service.modcluster.mcmp.MCMPServerState;
-
-/**
- * @author Brian Stansberry
- */
-public interface ClusteredMCMPHandler extends MCMPHandler
-{
- public static final String HA_SERVICE_NAME = "ModClusterService";
-
- List<MCMPServerDiscoveryEvent> getPendingDiscoveryEvents();
- void discoveryEventsReceived(MCMPServerDiscoveryEvent lastReceived);
-
- Set<MCMPServerState> updateServersFromMasterNode(Set<MCMPServer> masterList);
-
- boolean getNeedsResetTransmission();
- void recordResetTransmission();
- void recordResetSuccess();
-
- boolean isMasterNode();
- void setMasterNode(boolean master);
-
- String getHAServiceName();
-
- String getPartitionName();
-}
Deleted: trunk/tomcat/src/main/org/jboss/web/tomcat/service/modcluster/ha/ClusteredMCMPHandlerImpl.java
===================================================================
--- trunk/tomcat/src/main/org/jboss/web/tomcat/service/modcluster/ha/ClusteredMCMPHandlerImpl.java 2008-09-03 18:23:47 UTC (rev 77861)
+++ trunk/tomcat/src/main/org/jboss/web/tomcat/service/modcluster/ha/ClusteredMCMPHandlerImpl.java 2008-09-03 19:01:23 UTC (rev 77862)
@@ -1,530 +0,0 @@
-/*
- * 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.web.tomcat.service.modcluster.ha;
-
-import java.io.IOException;
-import java.net.InetAddress;
-import java.util.ArrayList;
-import java.util.Iterator;
-import java.util.List;
-import java.util.Set;
-import java.util.concurrent.atomic.AtomicInteger;
-
-import net.jcip.annotations.GuardedBy;
-
-import org.apache.catalina.util.StringManager;
-import org.jboss.ha.framework.interfaces.HAServiceKeyProvider;
-import org.jboss.logging.Logger;
-import org.jboss.web.tomcat.service.modcluster.Constants;
-import org.jboss.web.tomcat.service.modcluster.Utils;
-import org.jboss.web.tomcat.service.modcluster.config.MCMPHandlerConfiguration;
-import org.jboss.web.tomcat.service.modcluster.ha.rpc.BooleanGroupRpcResponse;
-import org.jboss.web.tomcat.service.modcluster.ha.rpc.ClusteredMCMPHandlerRpcHandler;
-import org.jboss.web.tomcat.service.modcluster.ha.rpc.GroupRpcResponse;
-import org.jboss.web.tomcat.service.modcluster.ha.rpc.GroupRpcResponseFilter;
-import org.jboss.web.tomcat.service.modcluster.ha.rpc.MCMPServerDiscoveryEvent;
-import org.jboss.web.tomcat.service.modcluster.ha.rpc.StringGroupRpcResponse;
-import org.jboss.web.tomcat.service.modcluster.ha.rpc.ThrowableGroupRpcResponse;
-import org.jboss.web.tomcat.service.modcluster.mcmp.AbstractMCMPHandler;
-import org.jboss.web.tomcat.service.modcluster.mcmp.AddressPort;
-import org.jboss.web.tomcat.service.modcluster.mcmp.MCMPHandler;
-import org.jboss.web.tomcat.service.modcluster.mcmp.MCMPRequest;
-import org.jboss.web.tomcat.service.modcluster.mcmp.MCMPServer;
-import org.jboss.web.tomcat.service.modcluster.mcmp.MCMPServerState;
-
-public class ClusteredMCMPHandlerImpl extends AbstractMCMPHandler implements ClusteredMCMPHandler
-{
- static final Object[] NULL_ARGS = new Object[0];
- static final Class<?>[] NULL_TYPES = new Class[0];
- static final Class<?>[] MCMPREQ_TYPES = new Class[] { MCMPRequest.class };
- static final Class<?>[] MCMPREQS_TYPES = new Class[] { List.class };
- static final Class<?>[] DISC_EVENT_TYPES = new Class[] { MCMPServerDiscoveryEvent.class };
-
- static final Logger log = Logger.getLogger(ClusteredMCMPHandlerImpl.class);
-
- final HAServiceKeyProvider serviceKeyProvider;
- private final MCMPHandler localHandler;
- private final ClusteredMCMPHandlerRpcHandler rpcStub = new RpcStub();
-// private AdvertiseListener advertiseListener;
-
- private volatile String haServiceName;
- private volatile boolean masterNode = false;
-
- @GuardedBy("errorState")
- private final List<Boolean> errorState = new ArrayList<Boolean>();
-
- @GuardedBy("this")
- private List<MCMPServerDiscoveryEvent> pendingDiscoveryEvents = new ArrayList<MCMPServerDiscoveryEvent>();
-
- private AtomicInteger discoveryEventIndex = new AtomicInteger();
-
- /**
- * The string manager for this package.
- */
- final StringManager sm = StringManager.getManager(Constants.Package);
-
- public ClusteredMCMPHandlerImpl(MCMPHandler localHandler, HAServiceKeyProvider serviceKeyProvider)
- {
- this.localHandler = localHandler;
- this.serviceKeyProvider = serviceKeyProvider;
- }
-
- // --------------------------------------------------- ClusteredMCMPHandler
-
- public boolean isMasterNode()
- {
- return this.masterNode;
- }
-
- public void setMasterNode(boolean masterNode)
- {
- this.masterNode = masterNode;
- }
-
- /**
- * @see org.jboss.web.tomcat.service.modcluster.ha.ClusteredMCMPHandler#getHAServiceName()
- */
- public String getHAServiceName()
- {
- return this.haServiceName;
- }
-
- /**
- * @see org.jboss.web.tomcat.service.modcluster.ha.ClusteredMCMPHandler#setHAServiceName(java.lang.String)
- */
- public void setHAServiceName(String serviceName)
- {
- this.haServiceName = serviceName;
- }
-
- /**
- * @see org.jboss.web.tomcat.service.modcluster.ha.ClusteredMCMPHandler#getPartitionName()
- */
- public String getPartitionName()
- {
- return this.serviceKeyProvider.getHAPartition().getPartitionName();
- }
-
- public synchronized List<MCMPServerDiscoveryEvent> getPendingDiscoveryEvents()
- {
- return new ArrayList<MCMPServerDiscoveryEvent>(this.pendingDiscoveryEvents);
- }
-
- public synchronized void discoveryEventsReceived(MCMPServerDiscoveryEvent lastReceived)
- {
- if (lastReceived != null)
- {
- for (Iterator<MCMPServerDiscoveryEvent> it = this.pendingDiscoveryEvents.iterator(); it.hasNext();)
- {
- MCMPServerDiscoveryEvent event = it.next();
- if (event.getEventIndex() <= lastReceived.getEventIndex())
- {
- it.remove();
- }
- else
- {
- return;
- }
- }
- }
- }
-
- public synchronized Set<MCMPServerState> updateServersFromMasterNode(Set<MCMPServer> masterList)
- {
- for (MCMPServer server : masterList)
- {
- this.localHandler.addProxy(server.getAddress(), server.getPort(), server.isEstablished());
- }
-
- for (MCMPServer server : this.localHandler.getProxyStates())
- {
- if (!masterList.contains(server))
- {
- this.localHandler.removeProxy(server.getAddress(), server.getPort());
- }
- }
-
- this.localHandler.status();
-
- return this.localHandler.getProxyStates();
- }
-
- public boolean getNeedsResetTransmission()
- {
- synchronized (this.errorState)
- {
- return this.errorState.size() > 0 && (this.errorState.get(this.errorState.size() - 1).booleanValue() == false);
- }
- }
-
- public void recordResetTransmission()
- {
- synchronized (this.errorState)
- {
- if (this.errorState.size() > 0)
- {
- this.errorState.set(0, Boolean.TRUE);
- }
- }
- }
-
- public void recordResetSuccess()
- {
- synchronized (this.errorState)
- {
- if (this.errorState.size() > 0 || this.errorState.get(this.errorState.size() - 1).booleanValue())
- {
- this.errorState.remove(0);
- }
- }
- }
-
- // ------------------------------------------------------------ MCMPHandler
-
- public MCMPHandlerConfiguration getConfiguration()
- {
- return this.localHandler.getConfiguration();
- }
-
- public synchronized void addProxy(InetAddress address, int port)
- {
- if (this.isMasterNode())
- {
- this.localHandler.addProxy(address, port);
- }
- else
- {
- this.sendDiscoveryEventToPartition(address, port, true);
- }
- }
-
- public void addProxy(InetAddress address, int port, boolean established)
- {
- this.localHandler.addProxy(address, port, established);
- }
-
- /**
- * Remove proxy.
- */
- public synchronized void removeProxy(InetAddress address, int port)
- {
- if (this.isMasterNode())
- {
- this.localHandler.removeProxy(address, port);
- }
- else
- {
- this.sendDiscoveryEventToPartition(address, port, false);
- }
- }
-
- public Set<MCMPServerState> getProxyStates()
- {
- return this.localHandler.getProxyStates();
- }
-
- public InetAddress getLocalAddress() throws IOException
- {
- return this.localHandler.getLocalAddress();
- }
-
- public String getProxyConfiguration()
- {
- if (this.isMasterNode())
- {
- return this.localHandler.getProxyConfiguration();
- }
-
- GroupRpcResponse response = this.rpcStub.getProxyConfiguration();
-
- this.validateResponse(response, false);
-
- return ((StringGroupRpcResponse) response).getValue();
- }
-
- public void init(List<AddressPort> initialProxies)
- {
- if (this.isMasterNode())
- {
- this.localHandler.init(initialProxies);
- }
- else
- {
- this.localHandler.init(new ArrayList<AddressPort>());
-
- if (initialProxies != null)
- {
- for (AddressPort proxy : initialProxies)
- {
- this.sendDiscoveryEventToPartition(proxy.address, proxy.port, true);
- }
- }
- }
- }
-
- public boolean isProxyHealthOK()
- {
- if (this.isMasterNode())
- {
- return this.localHandler.isProxyHealthOK();
- }
-
- GroupRpcResponse response = this.rpcStub.isProxyHealthOK();
-
- this.validateResponse(response, false);
-
- return ((BooleanGroupRpcResponse) response).getValue();
- }
-
- public void markProxiesInError()
- {
- this.recordRequestFailure();
-
- if (this.isMasterNode())
- {
- this.localHandler.markProxiesInError();
- }
- else
- {
- GroupRpcResponse response = this.rpcStub.markProxiesInError();
-
- this.validateResponse(response, false);
- }
- }
-
- public void reset()
- {
- if (this.isMasterNode())
- {
- this.localHandler.reset();
- }
- else
- {
- GroupRpcResponse response = this.rpcStub.reset();
-
- this.validateResponse(response, false);
- }
- }
-
- public void sendRequest(MCMPRequest request)
- {
- if (this.isMasterNode())
- {
- this.localHandler.sendRequest(request);
- }
- else
- {
- GroupRpcResponse response = this.rpcStub.sendRequest(request);
-
- this.validateResponse(response, true);
- }
- }
-
- public void sendRequests(List<MCMPRequest> requests)
- {
- if (this.isMasterNode())
- {
- this.localHandler.sendRequests(requests);
- }
- else
- {
- GroupRpcResponse response = this.rpcStub.sendRequests(requests);
-
- this.validateResponse(response, true);
- }
- }
-
- public void shutdown()
- {
- this.localHandler.shutdown();
- }
-
- public void status()
- {
- log.warn(this.sm.getString("modcluster.error.status.unsupported"));
- }
-
- // ---------------------------------------------------------------- Private
-
- private void validateResponse(GroupRpcResponse response, boolean recordFailure)
- {
- if (response instanceof ThrowableGroupRpcResponse)
- {
- if (recordFailure)
- {
- this.recordRequestFailure();
- }
-
- throw ((ThrowableGroupRpcResponse) response).getValueAsRuntimeException();
- }
- }
-
- private synchronized void sendDiscoveryEventToPartition(InetAddress address, int port, boolean addition)
- {
- AddressPort ap = new AddressPort(address, port);
- MCMPServerDiscoveryEvent event = new MCMPServerDiscoveryEvent(this.serviceKeyProvider.getHAPartition().getClusterNode(), ap, addition, this.discoveryEventIndex.incrementAndGet());
- this.pendingDiscoveryEvents.add(event);
-
- GroupRpcResponse response = this.rpcStub.mcmpServerDiscoveryEvent(event);
-
- if (response instanceof ThrowableGroupRpcResponse)
- {
- // Just log it; we'll retry later
- String msg = addition ? "modcluster.error.discovery.add"
- : "modcluster.error.discovery.remove";
- log.error(this.sm.getString(msg, address.toString(), new Integer(port)), ((ThrowableGroupRpcResponse) response).getValue());
- }
- }
-
- void recordRequestFailure()
- {
- synchronized (this.errorState)
- {
- if (this.errorState.size() == 0 || this.errorState.get(this.errorState.size() -1).booleanValue())
- {
- this.errorState.add(Boolean.FALSE);
- }
- }
- }
-
- class RpcStub implements ClusteredMCMPHandlerRpcHandler
- {
- /**
- * @see org.jboss.web.tomcat.service.modcluster.ha.rpc.ClusteredMCMPHandlerRpcHandler#getProxyConfiguration()
- */
- public GroupRpcResponse getProxyConfiguration()
- {
- return this.invokeRpc("getProxyConfiguration");
- }
-
- /**
- * @see org.jboss.web.tomcat.service.modcluster.ha.rpc.ClusteredMCMPHandlerRpcHandler#isProxyHealthOK()
- */
- public GroupRpcResponse isProxyHealthOK()
- {
- return this.invokeRpc("isProxyHealthOk");
- }
-
- /**
- * @see org.jboss.web.tomcat.service.modcluster.ha.rpc.ClusteredMCMPHandlerRpcHandler#markProxiesInError()
- */
- public GroupRpcResponse markProxiesInError()
- {
- return this.invokeRpc("markProxiesInError");
- }
-
- /**
- * @see org.jboss.web.tomcat.service.modcluster.ha.rpc.ClusteredMCMPHandlerRpcHandler#mcmpServerDiscoveryEvent(org.jboss.web.tomcat.service.modcluster.ha.rpc.MCMPServerDiscoveryEvent)
- */
- public GroupRpcResponse mcmpServerDiscoveryEvent(MCMPServerDiscoveryEvent event)
- {
- try
- {
- return this.invokeRpc("mcmpServerDiscoveryEvent", new Object[] { event }, DISC_EVENT_TYPES);
- }
- catch (Exception e)
- {
- return new ThrowableGroupRpcResponse(null, e);
- }
- }
-
- /**
- * @see org.jboss.web.tomcat.service.modcluster.ha.rpc.ClusteredMCMPHandlerRpcHandler#reset()
- */
- public GroupRpcResponse reset()
- {
- return this.invokeRpc("reset");
- }
-
- /**
- * @see org.jboss.web.tomcat.service.modcluster.ha.rpc.ClusteredMCMPHandlerRpcHandler#sendRequest(org.jboss.web.tomcat.service.modcluster.mcmp.MCMPRequest)
- */
- public GroupRpcResponse sendRequest(MCMPRequest request)
- {
- return this.invokeRpc("sendRequest", new Object[] { request }, MCMPREQ_TYPES, true);
- }
-
- /**
- * @see org.jboss.web.tomcat.service.modcluster.ha.rpc.ClusteredMCMPHandlerRpcHandler#sendRequests(java.util.List)
- */
- public GroupRpcResponse sendRequests(List<MCMPRequest> requests)
- {
- return this.invokeRpc("sendRequests", new Object[] { requests }, MCMPREQS_TYPES, true);
- }
-
- private GroupRpcResponse invokeRpc(String methodName)
- {
- return this.invokeRpc(methodName, NULL_ARGS, NULL_TYPES, false);
- }
-
- private GroupRpcResponse invokeRpc(String methodName, Object[] args, Class<?>[] types, boolean recordFailure)
- {
- try
- {
- return this.invokeRpc(methodName, args, types);
- }
- catch (Exception e)
- {
- if (recordFailure)
- {
- ClusteredMCMPHandlerImpl.this.recordRequestFailure();
- }
-
- throw Utils.convertToUnchecked(e);
- }
- }
-
- private GroupRpcResponse invokeRpc(String methodName, Object[] args, Class<?>[] types) throws Exception
- {
- List<?> responses = ClusteredMCMPHandlerImpl.this.serviceKeyProvider.getHAPartition().callMethodOnCluster(ClusteredMCMPHandlerImpl.this.serviceKeyProvider.getHAServiceKey(), methodName, args, types, false, new GroupRpcResponseFilter());
-
- Throwable thrown = null;
-
- for (Object obj : responses)
- {
- if (obj instanceof GroupRpcResponse)
- {
- return (GroupRpcResponse) obj;
- }
- else if (obj instanceof Throwable)
- {
- if (thrown == null)
- {
- thrown = (Throwable) obj;
- }
- }
- else
- {
- log.warn(ClusteredMCMPHandlerImpl.this.sm.getString("modcluster.error.rpc.unexpected", obj, methodName));
- }
- }
-
- if (thrown != null)
- {
- throw Utils.convertToUnchecked(thrown);
- }
-
- throw new IllegalStateException(ClusteredMCMPHandlerImpl.this.sm.getString("modcluster.error.rpc.noresp", methodName));
- }
- }
-}
\ No newline at end of file
Deleted: trunk/tomcat/src/main/org/jboss/web/tomcat/service/modcluster/ha/HASingletonAwareResetRequestSource.java
===================================================================
--- trunk/tomcat/src/main/org/jboss/web/tomcat/service/modcluster/ha/HASingletonAwareResetRequestSource.java 2008-09-03 18:23:47 UTC (rev 77861)
+++ trunk/tomcat/src/main/org/jboss/web/tomcat/service/modcluster/ha/HASingletonAwareResetRequestSource.java 2008-09-03 19:01:23 UTC (rev 77862)
@@ -1,167 +0,0 @@
-/*
- * 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.web.tomcat.service.modcluster.ha;
-
-import java.util.ArrayList;
-import java.util.Collections;
-import java.util.List;
-
-import org.apache.catalina.Server;
-import org.apache.catalina.util.StringManager;
-import org.jboss.ha.framework.interfaces.HAServiceKeyProvider;
-import org.jboss.logging.Logger;
-import org.jboss.web.tomcat.service.modcluster.Constants;
-import org.jboss.web.tomcat.service.modcluster.Utils;
-import org.jboss.web.tomcat.service.modcluster.config.BalancerConfiguration;
-import org.jboss.web.tomcat.service.modcluster.config.NodeConfiguration;
-import org.jboss.web.tomcat.service.modcluster.ha.rpc.ResetRequestGroupRpcResponse;
-import org.jboss.web.tomcat.service.modcluster.ha.rpc.ResetRequestSourceRpcHandler;
-import org.jboss.web.tomcat.service.modcluster.ha.rpc.ThrowableGroupRpcResponse;
-import org.jboss.web.tomcat.service.modcluster.mcmp.MCMPRequest;
-import org.jboss.web.tomcat.service.modcluster.mcmp.MCMPUtils;
-import org.jboss.web.tomcat.service.modcluster.mcmp.ResetRequestSource;
-
-/**
- * {@link ResetRequestSource} that provides different reset requests
- * depending on whether or not it believes it is running on the singleton
- * master.
- *
- * @author Brian Stansberry
- */
-public class HASingletonAwareResetRequestSource implements ResetRequestSource
-{
- static final String METHOD_NAME = "getResetRequests";
- static final Object[] ARGS = new Object[0];
- static final Class<?>[] TYPES = new Class[0];
-
- private static final Logger log = Logger.getLogger(HASingletonAwareResetRequestSource.class);
-
- /**
- * The string manager for this package.
- */
- private final StringManager sm = StringManager.getManager(Constants.Package);
-
- private final NodeConfiguration nodeConfig;
- private final BalancerConfiguration balancerConfig;
- private final ResetRequestSourceRpcHandler<List<?>> rpcStub;
- private volatile boolean master;
- private volatile Server jbossWebServer;
-
- public HASingletonAwareResetRequestSource(NodeConfiguration nodeConfig, BalancerConfiguration balancerConfig, HAServiceKeyProvider serviceKeyProvider)
- {
- this.nodeConfig = nodeConfig;
- this.balancerConfig = balancerConfig;
- this.rpcStub = new RpcStub(serviceKeyProvider);
- }
-
- public List<MCMPRequest> getResetRequests()
- {
- if (this.master)
- {
- List<MCMPRequest> resets = this.getLocalResetRequests();
- this.addRemoteRequests(resets);
- return resets;
- }
-
- return Collections.emptyList();
- }
-
- public List<MCMPRequest> getLocalResetRequests()
- {
- if (this.jbossWebServer == null)
- {
- return new ArrayList<MCMPRequest>();
- }
-
- return MCMPUtils.getResetRequests(this.jbossWebServer, this.nodeConfig, this.balancerConfig);
- }
-
- public boolean isMasterNode()
- {
- return this.master;
- }
-
- public void setMasterNode(boolean master)
- {
- this.master = master;
- }
-
- public void setJbossWebServer(Server jbossWebServer)
- {
- this.jbossWebServer = jbossWebServer;
- }
-
- private void addRemoteRequests(List<MCMPRequest> resets)
- {
- List<?> responses = this.rpcStub.getResetRequests();
-
- for (Object response : responses)
- {
- if (response instanceof ResetRequestGroupRpcResponse)
- {
- resets.addAll(((ResetRequestGroupRpcResponse) response).getValue());
- }
- else if (response instanceof ThrowableGroupRpcResponse)
- {
- ThrowableGroupRpcResponse tgrr = (ThrowableGroupRpcResponse) response;
- //FIXME what to do?
- log.warn(this.sm.getString("modcluster.error.rpc.known", METHOD_NAME, tgrr.getSender()), tgrr.getValue());
- }
- else if (response instanceof Throwable)
- {
- log.warn(this.sm.getString("modcluster.error.rpc.unknown", METHOD_NAME), (Throwable) response);
- }
- else
- {
- log.error(this.sm.getString("modcluster.error.rpc.unexpected", response, METHOD_NAME));
- }
-
- }
- }
-
- private class RpcStub implements ResetRequestSourceRpcHandler<List<?>>
- {
- private final HAServiceKeyProvider serviceKeyProvider;
-
- public RpcStub(HAServiceKeyProvider serviceKeyProvider)
- {
- this.serviceKeyProvider = serviceKeyProvider;
- }
-
- /**
- * @see org.jboss.web.tomcat.service.modcluster.ha.rpc.ResetRequestSourceRpcHandler#getResetRequests()
- */
- public List<?> getResetRequests()
- {
- try
- {
- return this.serviceKeyProvider.getHAPartition().callMethodOnCluster(this.serviceKeyProvider.getHAServiceKey(), METHOD_NAME, ARGS, TYPES, true);
- }
- catch (Exception e)
- {
- //FIXME what to do?
- throw Utils.convertToUnchecked(e);
- }
- }
- }
-}
Deleted: trunk/tomcat/src/main/org/jboss/web/tomcat/service/modcluster/ha/ModClusterServiceDRMEntry.java
===================================================================
--- trunk/tomcat/src/main/org/jboss/web/tomcat/service/modcluster/ha/ModClusterServiceDRMEntry.java 2008-09-03 18:23:47 UTC (rev 77861)
+++ trunk/tomcat/src/main/org/jboss/web/tomcat/service/modcluster/ha/ModClusterServiceDRMEntry.java 2008-09-03 19:01:23 UTC (rev 77862)
@@ -1,182 +0,0 @@
-/*
- * 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.web.tomcat.service.modcluster.ha;
-
-import java.io.Serializable;
-import java.util.HashSet;
-import java.util.Set;
-
-import org.jboss.ha.framework.interfaces.ClusterNode;
-import org.jboss.web.tomcat.service.modcluster.mcmp.MCMPServerState;
-
-/**
- * Represents the status of a given MCMP client's ability to communicate
- * with MCMP servers.
- *
- * @author Brian Stansberry
- */
-public class ModClusterServiceDRMEntry implements Serializable, Comparable<ModClusterServiceDRMEntry>
-{
- /** The serialVersionUID */
- private static final long serialVersionUID = 8275232749243297786L;
-
- private final ClusterNode peer;
- private final Set<MCMPServerState> mcmpServerStates;
- private final Integer healthyEstablishedCount;
- private final Integer establishedCount;
- private final Integer healthyCount;
- private final Integer knownCount;
- private final Set<String> jvmRoutes = new HashSet<String>();
-
- public ModClusterServiceDRMEntry(ClusterNode peer, Set<MCMPServerState> mcmpServerStates)
- {
- assert peer != null : "peer is null";
-
- this.peer = peer;
- this.mcmpServerStates = mcmpServerStates;
-
- int healthyEstablished = 0;
- int knownEstablished = 0;
- int healthy = 0;
- int known = 0;
-
- if (this.mcmpServerStates != null)
- {
- for (MCMPServerState state : this.mcmpServerStates)
- {
- known++;
- if (state.getState() == MCMPServerState.State.OK)
- {
- healthy++;
- if (state.isEstablished())
- {
- knownEstablished++;
- healthyEstablished++;
- }
- }
- else if (state.isEstablished())
- {
- knownEstablished++;
- }
- }
- }
-
- this.establishedCount = new Integer(knownEstablished);
- this.healthyCount = new Integer(healthy);
- this.healthyEstablishedCount = new Integer(healthyEstablished);
- this.knownCount = new Integer(known);
- }
-
- public ClusterNode getPeer()
- {
- return this.peer;
- }
-
- public Set<MCMPServerState> getMCMPServerStates()
- {
- return this.mcmpServerStates;
- }
-
- public Set<String> getJvmRoutes()
- {
- synchronized (this.jvmRoutes)
- {
- return new HashSet<String>(this.jvmRoutes);
- }
- }
-
- public void addJvmRoute(String jvmRoute)
- {
- synchronized (this.jvmRoutes)
- {
- this.jvmRoutes.add(jvmRoute);
- }
- }
-
- public void removeJvmRoute(String jvmRoute)
- {
- synchronized (this.jvmRoutes)
- {
- this.jvmRoutes.remove(jvmRoute);
- }
- }
-
- public int compareTo(ModClusterServiceDRMEntry other)
- {
- int result = other.healthyEstablishedCount.compareTo(this.healthyEstablishedCount);
- if (result == 0)
- {
- result = other.establishedCount.compareTo(this.establishedCount);
- if (result == 0)
- {
- result = other.healthyCount.compareTo(this.healthyCount);
- if (result == 0)
- {
- result = other.knownCount.compareTo(this.knownCount);
- }
- }
- }
-
- return result;
- }
-
- @Override
- public boolean equals(Object obj)
- {
- if (this == obj)
- {
- return true;
- }
-
- if (obj instanceof ModClusterServiceDRMEntry)
- {
- ModClusterServiceDRMEntry other = (ModClusterServiceDRMEntry) obj;
- return (this.peer.equals(other.peer)
- && this.safeEquals(this.mcmpServerStates, other.mcmpServerStates)
- && this.safeEquals(this.jvmRoutes, other.jvmRoutes));
- }
- return false;
- }
-
- @Override
- public int hashCode()
- {
- int result = 17;
- result += 23 * this.peer.hashCode();
- result += 23 * (this.mcmpServerStates == null ? 0 : this.mcmpServerStates.hashCode());
- result += 23 * (this.jvmRoutes == null ? 0 : this.jvmRoutes.hashCode());
- return result;
- }
-
- @Override
- public String toString()
- {
- return new StringBuilder(this.getClass().getName())
- .append("{peer=").append(this.peer).append("}").toString();
- }
-
- private boolean safeEquals(Object a, Object b)
- {
- return (a == b || (a != null && a.equals(b)));
- }
-}
\ No newline at end of file
Deleted: trunk/tomcat/src/main/org/jboss/web/tomcat/service/modcluster/load/LoadBalanceFactorProvider.java
===================================================================
--- trunk/tomcat/src/main/org/jboss/web/tomcat/service/modcluster/load/LoadBalanceFactorProvider.java 2008-09-03 18:23:47 UTC (rev 77861)
+++ trunk/tomcat/src/main/org/jboss/web/tomcat/service/modcluster/load/LoadBalanceFactorProvider.java 2008-09-03 19:01:23 UTC (rev 77862)
@@ -1,34 +0,0 @@
-/*
- * JBoss, Home of Professional Open Source.
- * Copyright 2006, 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.web.tomcat.service.modcluster.load;
-
-/**
- * Provides the load balance factor for a node.
- *
- * @author Brian Stansberry
- * @version $Revision$
- */
-public interface LoadBalanceFactorProvider
-{
- int getLoadBalanceFactor();
-}
Deleted: trunk/tomcat/src/main/org/jboss/web/tomcat/service/modcluster/load/metric/LoadMetric.java
===================================================================
--- trunk/tomcat/src/main/org/jboss/web/tomcat/service/modcluster/load/metric/LoadMetric.java 2008-09-03 18:23:47 UTC (rev 77861)
+++ trunk/tomcat/src/main/org/jboss/web/tomcat/service/modcluster/load/metric/LoadMetric.java 2008-09-03 19:01:23 UTC (rev 77862)
@@ -1,50 +0,0 @@
-/*
- * 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.web.tomcat.service.modcluster.load.metric;
-
-/**
- * Represents a specific load metric.
- * @author Paul Ferraro
- */
-public interface LoadMetric
-{
- /**
- * Returns the "weight" of this metric, i.e. significance of this load metric compared to the other metrics.
- * @return the weight of the metric
- */
- int getWeight();
-
- /**
- * Returns the load capacity of this metric.
- * Used to normalize the value returned by {@link #getLoad()} expressed as a percentage of the capacity, such that:
- * 0 <= ({@link #getLoad()} / {@link #getCapacity()}) < 1
- * @return the estimated capacity of this metric.
- */
- double getCapacity();
-
- /**
- * Returns the current load. This value only has meaning when expressed as a ratio of the capacity.
- * @return the current load.
- * @throws Exception if there was an error fetching this metric.
- */
- double getLoad() throws Exception;
-}
Deleted: trunk/tomcat/src/main/org/jboss/web/tomcat/service/modcluster/load/metric/LoadMetricMBean.java
===================================================================
--- trunk/tomcat/src/main/org/jboss/web/tomcat/service/modcluster/load/metric/LoadMetricMBean.java 2008-09-03 18:23:47 UTC (rev 77861)
+++ trunk/tomcat/src/main/org/jboss/web/tomcat/service/modcluster/load/metric/LoadMetricMBean.java 2008-09-03 19:01:23 UTC (rev 77862)
@@ -1,34 +0,0 @@
-/*
- * 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.web.tomcat.service.modcluster.load.metric;
-
-
-/**
- * @author Paul Ferraro
- *
- */
-public interface LoadMetricMBean extends LoadMetric
-{
- void setWeight(int weight);
-
- void setCapacity(double capacity);
-}
Deleted: trunk/tomcat/src/main/org/jboss/web/tomcat/service/modcluster/load/metric/LoadMetricSource.java
===================================================================
--- trunk/tomcat/src/main/org/jboss/web/tomcat/service/modcluster/load/metric/LoadMetricSource.java 2008-09-03 18:23:47 UTC (rev 77861)
+++ trunk/tomcat/src/main/org/jboss/web/tomcat/service/modcluster/load/metric/LoadMetricSource.java 2008-09-03 19:01:23 UTC (rev 77862)
@@ -1,47 +0,0 @@
-/*
- * 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.web.tomcat.service.modcluster.load.metric;
-
-import java.util.Collection;
-
-/**
- * A source for obtaining load metrics.
- * @author Paul Ferraro
- */
-public interface LoadMetricSource
-{
- /**
- * Returns the collection of metrics registered with this source.
- * @return the metrics from this source
- */
- Collection<LoadMetric> getMetrics();
-
- /**
- * Prepare any resource required to collect load metrics
- */
- void prepare();
-
- /**
- * Cleanup any resources used to collect load metrics
- */
- void cleanup();
-}
Deleted: trunk/tomcat/src/main/org/jboss/web/tomcat/service/modcluster/load/metric/LoadMetricSourceRegistration.java
===================================================================
--- trunk/tomcat/src/main/org/jboss/web/tomcat/service/modcluster/load/metric/LoadMetricSourceRegistration.java 2008-09-03 18:23:47 UTC (rev 77861)
+++ trunk/tomcat/src/main/org/jboss/web/tomcat/service/modcluster/load/metric/LoadMetricSourceRegistration.java 2008-09-03 19:01:23 UTC (rev 77862)
@@ -1,32 +0,0 @@
-/*
- * 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.web.tomcat.service.modcluster.load.metric;
-
-
-/**
- * @author Paul Ferraro
- *
- */
-public interface LoadMetricSourceRegistration
-{
- void add(LoadMetricSource source);
-}
Deleted: trunk/tomcat/src/main/org/jboss/web/tomcat/service/modcluster/mbeans-descriptors.xml
===================================================================
--- trunk/tomcat/src/main/org/jboss/web/tomcat/service/modcluster/mbeans-descriptors.xml 2008-09-03 18:23:47 UTC (rev 77861)
+++ trunk/tomcat/src/main/org/jboss/web/tomcat/service/modcluster/mbeans-descriptors.xml 2008-09-03 19:01:23 UTC (rev 77862)
@@ -1,138 +0,0 @@
-<?xml version="1.0"?>
-<mbeans-descriptors>
-
- <mbean name="ClusterListener"
- description="Cluster listener for mod_cluster"
- domain="Catalina"
- group="Listener"
- type="org.jboss.web.cluster.ClusterListener">
-
- <attribute name="className"
- description="Fully qualified class name of the managed object"
- type="java.lang.String"
- writeable="false"/>
-
- <attribute name="containerName"
- description="Object name of the container"
- type="javax.management.ObjectName"/>
-
- <attribute name="proxyConfiguration"
- description="Get the mod_cluster configuration"
- type="java.lang.String"
- writeable="false"/>
-
- <attribute name="proxyList"
- description="Comma delimited list of proxy servers"
- type="java.lang.String"/>
-
- <attribute name="socketTimeout"
- description="Connection timeout for communication with the proxy"
- type="int"/>
-
- <attribute name="advertise"
- description="Enable autodiscovery of httpd servers"
- type="boolean"/>
-
- <attribute name="advertiseGroupAddress"
- description="Multicast address for discovery"
- type="java.lang.String"/>
-
- <attribute name="advertisePort"
- description="Multicast port for discovery"
- type="int"/>
-
- <attribute name="advertiseSecurityKey"
- description="Security key for discovery"
- type="java.lang.String"/>
-
- <attribute name="domain"
- description="Domain parameter, which allows tying a jvmRoute to a particular domain"
- type="java.lang.String"/>
-
- <attribute name="flushPackets"
- description="Allows controlling flushing of packets"
- type="boolean"/>
-
- <attribute name="flushWait"
- description="Time in ms to wait before flushing packets"
- type="int"/>
-
- <attribute name="ping"
- description="Time in s to wait for a pong answer to a ping"
- type="int"/>
-
- <attribute name="smax"
- description="Maximum time on seconds for idle connections above smax"
- type="int"/>
-
- <attribute name="balancer"
- description="Name of the balancer"
- type="java.lang.String"/>
-
- <attribute name="stickySession"
- description="Enables sticky sessions"
- type="boolean"/>
-
- <attribute name="stickySessionRemove"
- description="Remove session when the request cannot be routed to the right node"
- type="boolean"/>
-
- <attribute name="stickySessionForce"
- description="Return an error when the request cannot be routed to the right node"
- type="boolean"/>
-
- <attribute name="workerTimeout"
- description="Timeout to wait for an available worker (default is no wait)"
- type="int"/>
-
- <attribute name="maxAttempts"
- description="Maximum number of attempts to send the request to the backend server"
- type="int"/>
-
- <operation name="refresh"
- description="Refresh configuration"
- impact="ACTION"
- returnType="void"/>
-
- <operation name="reset"
- description="Move the node out of an error state"
- impact="ACTION"
- returnType="void"/>
-
- <operation name="disable"
- description="Disable all webapps for all engines"
- impact="ACTION"
- returnType="boolean"/>
-
- <operation name="enable"
- description="Enable all webapps for all engines"
- impact="ACTION"
- returnType="boolean"/>
-
- <operation name="addProxy"
- description="Add a proxy"
- impact="ACTION"
- returnType="void">
- <parameter name="host"
- description="Proxy address"
- type="java.lang.String"/>
- <parameter name="port"
- description="Proxy port"
- type="int"/>
- </operation>
-
- <operation name="removeProxy"
- description="Remove a proxy"
- impact="ACTION"
- returnType="void">
- <parameter name="host"
- description="Proxy address"
- type="java.lang.String"/>
- <parameter name="port"
- description="Proxy port"
- type="int"/>
- </operation>
-
- </mbean>
-
-</mbeans-descriptors>
Deleted: trunk/tomcat/src/main/org/jboss/web/tomcat/service/modcluster/mcmp/AbstractMCMPHandler.java
===================================================================
--- trunk/tomcat/src/main/org/jboss/web/tomcat/service/modcluster/mcmp/AbstractMCMPHandler.java 2008-09-03 18:23:47 UTC (rev 77861)
+++ trunk/tomcat/src/main/org/jboss/web/tomcat/service/modcluster/mcmp/AbstractMCMPHandler.java 2008-09-03 19:01:23 UTC (rev 77862)
@@ -1,80 +0,0 @@
-/*
- * 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.web.tomcat.service.modcluster.mcmp;
-
-import java.net.InetAddress;
-import java.net.UnknownHostException;
-
-/**
- * Abstract {@link MCMPHandler} that implements the trivial convenience methods.
- *
- * @author Paul Ferraro
- */
-public abstract class AbstractMCMPHandler implements MCMPHandler
-{
- /**
- * @{inheritDoc}
- * @see org.jboss.web.tomcat.service.modcluster.mcmp.MCMPHandler#addProxy(java.lang.String)
- */
- public void addProxy(String address)
- {
- AddressPort ap = MCMPUtils.parseAddressPort(address);
-
- this.addProxy(ap.address, ap.port);
- }
-
- /**
- * @{inheritDoc}
- * @see org.jboss.web.tomcat.service.modcluster.mcmp.MCMPHandler#addProxy(java.lang.String, int)
- */
- public void addProxy(String host, int port)
- {
- try
- {
- InetAddress address = InetAddress.getByName(host);
-
- this.addProxy(address, port);
- }
- catch (UnknownHostException e)
- {
- throw new IllegalArgumentException(e);
- }
- }
-
- /**
- * @{inheritDoc}
- * @see org.jboss.web.tomcat.service.modcluster.mcmp.MCMPHandler#removeProxy(java.lang.String, int)
- */
- public void removeProxy(String host, int port)
- {
- try
- {
- InetAddress address = InetAddress.getByName(host);
-
- this.removeProxy(address, port);
- }
- catch (UnknownHostException e)
- {
- throw new IllegalArgumentException(e);
- }
- }
-}
Deleted: trunk/tomcat/src/main/org/jboss/web/tomcat/service/modcluster/mcmp/AddressPort.java
===================================================================
--- trunk/tomcat/src/main/org/jboss/web/tomcat/service/modcluster/mcmp/AddressPort.java 2008-09-03 18:23:47 UTC (rev 77861)
+++ trunk/tomcat/src/main/org/jboss/web/tomcat/service/modcluster/mcmp/AddressPort.java 2008-09-03 19:01:23 UTC (rev 77862)
@@ -1,85 +0,0 @@
-/*
- * 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.web.tomcat.service.modcluster.mcmp;
-
-import java.io.Serializable;
-import java.net.InetAddress;
-
-/**
- * Simple data object encapsulating an InetAddress and a port.
- *
- * @author Brian Stansberry
- */
-public class AddressPort implements Serializable
-{
- /** The serialVersionUID */
- private static final long serialVersionUID = 3835532412744565879L;
-
- public final InetAddress address;
- public final int port;
-
- public AddressPort(InetAddress address, int port)
- {
- this.address = address;
- this.port = port;
- }
-
- public boolean equals(InetAddress address, int port)
- {
- if (this.port != port) {
- return false;
- }
- if (address == null) {
- return (this.address == null);
- }
- else
- {
- return (address.equals(this.address));
- }
- }
-
- @Override
- public boolean equals(Object o) {
- if (o instanceof AddressPort) {
- AddressPort compare = (AddressPort) o;
- return equals(compare.address, compare.port);
- }
- return false;
- }
-
- @Override
- public int hashCode()
- {
- int result = 17;
- result += 23 * (this.address == null ? 0 : this.address.hashCode());
- result += 23 * this.port;
- return result;
- }
-
- @Override
- public String toString()
- {
- return "AddressPort{" + address + ":" + port + "}";
- }
-
-}
\ No newline at end of file
Deleted: trunk/tomcat/src/main/org/jboss/web/tomcat/service/modcluster/mcmp/MCMPHandler.java
===================================================================
--- trunk/tomcat/src/main/org/jboss/web/tomcat/service/modcluster/mcmp/MCMPHandler.java 2008-09-03 18:23:47 UTC (rev 77861)
+++ trunk/tomcat/src/main/org/jboss/web/tomcat/service/modcluster/mcmp/MCMPHandler.java 2008-09-03 19:01:23 UTC (rev 77862)
@@ -1,188 +0,0 @@
-/*
- * JBoss, Home of Professional Open Source.
- * Copyright 2006, 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.web.tomcat.service.modcluster.mcmp;
-
-import java.io.IOException;
-import java.net.InetAddress;
-import java.util.List;
-import java.util.Set;
-
-import org.jboss.web.tomcat.service.modcluster.config.MCMPHandlerConfiguration;
-
-/**
- * Handles communication via MCMP with the httpd side.
- *
- * @author Brian Stansberry
- * @version $Revision$
- */
-public interface MCMPHandler
-{
- /** Gets this handler's configuration */
- MCMPHandlerConfiguration getConfiguration();
-
- /** Initialize the handler with the given list of proxies */
- void init(List<AddressPort> initialProxies);
-
- /** Perform any shut down work. */
- void shutdown();
-
- /**
- * Send a request to all healthy proxies.
- *
- * @param request the request. Cannot be <code>null</code>
- **/
- void sendRequest(MCMPRequest request);
-
- /**
- * Send a list of requests to all healthy proxies, with all requests
- * in the list sent to each proxy before moving on to the next.
- *
- * @param requests the requests. Cannot be <code>null</code>
- */
- void sendRequests(List<MCMPRequest> requests);
-
- /**
- * Add a proxy to the list of those with which this handler communicates.
- * Communication does not begin until the next call to {@link #status()}.
- *
- * @param address a string in the form hostname:port, where the hostname
- * portion is suitable for passing to <code>InetAddress.getByHost(...)</code>
- */
- void addProxy(String address);
-
- /**
- * Add a proxy to the list of those with which this handler communicates.
- * Communication does not begin until the next call to {@link #status()}.
- *
- * @param host the hostname of the proxy; a string suitable for passing to
- * <code>InetAddress.getByHost(...)</code>
- * @param port the port on which the proxy listens for MCMP requests
- */
- void addProxy(String host, int port);
-
- /**
- * Add a proxy to the list of those with which this handler communicates.
- * Communication does not begin until the next call to {@link #status()}.
- * <p>
- * Same as {@link #addProxy(InetAddress, int, boolean) addProxy(address, port, false}.
- * </p>
- *
- * @param address InetAddress on which the proxy listens for MCMP requests
- * @param port the port on which the proxy listens for MCMP requests
- */
- void addProxy(InetAddress address, int port);
-
- /**
- * Add a proxy to the list of those with which this handler communicates.
- * Communication does not begin until the next call to {@link #status()}.
- *
- * @param address InetAddress on which the proxy listens for MCMP requests
- * @param port the port on which the proxy listens for MCMP requests
- * @param established <code>true</code> if the proxy should be considered
- * {@link MCMPServer#isEstablished() established},
- * <code>false</code> otherwise.
- */
- void addProxy(InetAddress address, int port, boolean established);
-
- /**
- * Remove a proxy from the list of those with which this handler communicates.
- * Communication does not end until the next call to {@link #status()}.
- *
- * @param host the hostname of the proxy; a string suitable for passing to
- * <code>InetAddress.getByHost(...)</code>
- * @param port the port on which the proxy listens for MCMP requests
- */
- void removeProxy(String host, int port);
-
- /**
- * Remove a proxy from the list of those with which this handler communicates.
- * Communication does not begin until the next call to {@link #status()}.
- *
- * @param address InetAddress on which the proxy listens for MCMP requests
- * @param port the port on which the proxy listens for MCMP requests
- */
- void removeProxy(InetAddress address, int port);
-
- /**
- * Get the state of all proxies
- *
- * @return a set of status objects indicating the status of this handler's
- * communication with all proxies.
- */
- Set<MCMPServerState> getProxyStates();
-
- /**
- * Reset any proxies whose status is {@link MCMPServerState#DOWN DOWN} up to
- * {@link MCMPServerState#ERROR ERROR}, where the configuration will
- * be refreshed.
- */
- void reset();
-
- /**
- * Reset any proxies whose status is {@link MCMPServerState#OK OK} down to
- * {@link MCMPServerState#ERROR ERROR}, which will trigger a refresh of
- * their configuration.
- */
- void markProxiesInError();
-
- /**
- * Convenience method that checks whether the status of all proxies is
- * {@link MCMPServerState#OK OK}.
- *
- * @return <code>true</code> if all proxies are {@link MCMPServerState#OK OK},
- * <code>false</code> otherwise
- */
- boolean isProxyHealthOK();
-
- /**
- * Attempts to determine the address via which this node communicates
- * with the proxies.
- *
- * @return the address, or <code>null</code> if it cannot be determined
- *
- * @throws IOException
- */
- InetAddress getLocalAddress() throws IOException;
-
- /**
- * Sends a {@link MCMPRequestType#DUMP DUMP} request to all proxies,
- * concatentating their responses into a single string.
- *
- * TODO wouldn't a List<String> be better? Let the caller concatenate if
- * so desired.
- *
- * @return the configuration information from all the accessible proxies.
- */
- String getProxyConfiguration();
-
- /**
- * Perform periodic processing. Update the list of proxies to reflect any
- * calls to <code>addProxy(...)</code> or <code>removeProxy(...)</code>.
- * Attempt to establish communication with any proxies whose state is
- * {@link MCMPServerState#ERROR ERROR}. If successful and a
- * {@link ResetRequestSource} has been provided, update the proxy with the
- * list of requests provided by the source.
- */
- void status();
-
-}
Deleted: trunk/tomcat/src/main/org/jboss/web/tomcat/service/modcluster/mcmp/MCMPRequest.java
===================================================================
--- trunk/tomcat/src/main/org/jboss/web/tomcat/service/modcluster/mcmp/MCMPRequest.java 2008-09-03 18:23:47 UTC (rev 77861)
+++ trunk/tomcat/src/main/org/jboss/web/tomcat/service/modcluster/mcmp/MCMPRequest.java 2008-09-03 19:01:23 UTC (rev 77862)
@@ -1,90 +0,0 @@
-/*
- * JBoss, Home of Professional Open Source.
- * Copyright 2006, 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.web.tomcat.service.modcluster.mcmp;
-
-import java.io.Serializable;
-import java.util.Collections;
-import java.util.HashMap;
-import java.util.Map;
-
-import net.jcip.annotations.Immutable;
-
-/**
- * Encapsulates the parameters for a request over MCMP.
- *
- * @author Brian Stansberry
- * @version $Revision$
- */
- at Immutable
-public class MCMPRequest implements Serializable
-{
- /** The serialVersionUID */
- private static final long serialVersionUID = 7107364666635260031L;
-
- private final MCMPRequestType requestType;
- private final boolean wildcard;
- private final Map<String, String> parameters;
-
- /**
- * Create a new ModClusterRequest.
- */
- public MCMPRequest(MCMPRequestType requestType, boolean wildcard, Map<String, String> parameters)
- {
- this.requestType = requestType;
- this.wildcard = wildcard;
- this.parameters = Collections.unmodifiableMap(new HashMap<String, String>(parameters));
- }
-
- public MCMPRequestType getRequestType()
- {
- return requestType;
- }
-
- public boolean isWildcard()
- {
- return wildcard;
- }
-
- public Map<String, String> getParameters()
- {
- return parameters;
- }
-
- public String toString()
- {
- StringBuilder sb = new StringBuilder(getClass().getName());
- sb.append("{requestType=");
- sb.append(requestType);
- sb.append(",wildcard=");
- sb.append(wildcard);
- sb.append(",parameters=");
- synchronized (parameters)
- {
- sb.append(parameters);
- }
- sb.append("}");
-
- return sb.toString();
- }
-
-}
Deleted: trunk/tomcat/src/main/org/jboss/web/tomcat/service/modcluster/mcmp/MCMPRequestType.java
===================================================================
--- trunk/tomcat/src/main/org/jboss/web/tomcat/service/modcluster/mcmp/MCMPRequestType.java 2008-09-03 18:23:47 UTC (rev 77861)
+++ trunk/tomcat/src/main/org/jboss/web/tomcat/service/modcluster/mcmp/MCMPRequestType.java 2008-09-03 19:01:23 UTC (rev 77862)
@@ -1,67 +0,0 @@
-/*
- * JBoss, Home of Professional Open Source.
- * Copyright 2006, 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.web.tomcat.service.modcluster.mcmp;
-
-/**
- * Valid types of MCMP requests.
- *
- * @author Brian Stansberry
- * @version $Revision$
- */
-public enum MCMPRequestType
-{
- CONFIG("CONFIG", true),
- ENABLE_APP("ENABLE-APP", false),
- DISABLE_APP("DISABLE-APP", false),
- STOP_APP("STOP-APP", false),
- REMOVE_APP("REMOVE-APP", false),
- STATUS("STATUS", false),
- INFO("INFO", false),
- DUMP("DUMP", false);
-
- private final String command;
- private final boolean establishesServer;
-
- private MCMPRequestType(String command, boolean establishesServer)
- {
- this.command = command;
- this.establishesServer = establishesServer;
- }
-
- public String getCommand()
- {
- return this.command;
- }
-
- public boolean getEstablishesServer()
- {
- return this.establishesServer;
- }
-
- public String toString()
- {
- return command;
- }
-
-
-}
Deleted: trunk/tomcat/src/main/org/jboss/web/tomcat/service/modcluster/mcmp/MCMPServer.java
===================================================================
--- trunk/tomcat/src/main/org/jboss/web/tomcat/service/modcluster/mcmp/MCMPServer.java 2008-09-03 18:23:47 UTC (rev 77861)
+++ trunk/tomcat/src/main/org/jboss/web/tomcat/service/modcluster/mcmp/MCMPServer.java 2008-09-03 19:01:23 UTC (rev 77862)
@@ -1,43 +0,0 @@
-/*
- * 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.web.tomcat.service.modcluster.mcmp;
-
-import java.net.InetAddress;
-
-/**
- * Represents a native server that is running the <code>mod_cluster</code>
- * module and proxying requests to JBoss Web. For example, an Apache httpd
- * instance. Such an instance represents the server in the Mod Cluster
- * Management Protocol, with an MCMPHandler acting as the client.
- *
- * @author Brian Stansberry
- */
-public interface MCMPServer
-{
- InetAddress getAddress();
-
- int getPort();
-
- boolean isEstablished();
-
-}
Deleted: trunk/tomcat/src/main/org/jboss/web/tomcat/service/modcluster/mcmp/MCMPServerState.java
===================================================================
--- trunk/tomcat/src/main/org/jboss/web/tomcat/service/modcluster/mcmp/MCMPServerState.java 2008-09-03 18:23:47 UTC (rev 77861)
+++ trunk/tomcat/src/main/org/jboss/web/tomcat/service/modcluster/mcmp/MCMPServerState.java 2008-09-03 19:01:23 UTC (rev 77862)
@@ -1,39 +0,0 @@
-/*
- * 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.web.tomcat.service.modcluster.mcmp;
-
-
-/**
- * Extends {@link MCMPServer} to provide information about the current
- * state of communications with that server.
- *
- * @author Brian Stansberry
- */
-public interface MCMPServerState extends MCMPServer
-{
- /** Possible communication states vis a vis the server */
- public enum State { OK, ERROR, DOWN };
-
- State getState();
-
-}
Deleted: trunk/tomcat/src/main/org/jboss/web/tomcat/service/modcluster/mcmp/MCMPUtils.java
===================================================================
--- trunk/tomcat/src/main/org/jboss/web/tomcat/service/modcluster/mcmp/MCMPUtils.java 2008-09-03 18:23:47 UTC (rev 77861)
+++ trunk/tomcat/src/main/org/jboss/web/tomcat/service/modcluster/mcmp/MCMPUtils.java 2008-09-03 19:01:23 UTC (rev 77862)
@@ -1,311 +0,0 @@
-/*
- * JBoss, Home of Professional Open Source.
- * Copyright 2006, 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.web.tomcat.service.modcluster.mcmp;
-
-import java.net.InetAddress;
-import java.util.ArrayList;
-import java.util.HashMap;
-import java.util.List;
-import java.util.Map;
-import java.util.StringTokenizer;
-
-import org.apache.catalina.Container;
-import org.apache.catalina.Context;
-import org.apache.catalina.Engine;
-import org.apache.catalina.Server;
-import org.apache.catalina.Service;
-import org.apache.catalina.connector.Connector;
-import org.apache.catalina.util.StringManager;
-import org.apache.tomcat.util.IntrospectionUtils;
-import org.jboss.logging.Logger;
-import org.jboss.web.tomcat.service.modcluster.Constants;
-import org.jboss.web.tomcat.service.modcluster.Utils;
-import org.jboss.web.tomcat.service.modcluster.config.BalancerConfiguration;
-import org.jboss.web.tomcat.service.modcluster.config.NodeConfiguration;
-
-/**
- * Utility methods related to the Mod-Cluster Management Protocol.
- *
- * @author Brian Stansberry
- * @version $Revision$
- */
-public class MCMPUtils
-{
- public static final int DEFAULT_PORT = 8000;
-
- private static final MCMPRequest INFO = new MCMPRequest(MCMPRequestType.INFO, false, new HashMap<String, String>());
-
- private static final Logger log = Logger.getLogger(MCMPUtils.class);
-
- /**
- * The string manager for this package.
- */
- private static final StringManager sm = StringManager.getManager(Constants.Package);
-
-
- public static MCMPRequest createConfigRequest(Engine engine, NodeConfiguration nodeConfig, BalancerConfiguration balancerConfig)
- {
- Connector connector = Utils.findProxyConnector(engine.getService().findConnectors());
- Map<String, String> parameters = new HashMap<String, String>();
- parameters.put("JVMRoute", engine.getJvmRoute());
- boolean reverseConnection =
- Boolean.TRUE.equals(IntrospectionUtils.getProperty(connector.getProtocolHandler(), "reverseConnection"));
- boolean ssl =
- Boolean.TRUE.equals(IntrospectionUtils.getProperty(connector.getProtocolHandler(), "SSLEnabled"));
- boolean ajp = ((String) IntrospectionUtils.getProperty(connector.getProtocolHandler(), "name")).startsWith("ajp-");
-
- if (reverseConnection) {
- parameters.put("Reversed", "true");
- }
- parameters.put("Host", Utils.getAddress(connector));
- parameters.put("Port", "" + connector.getPort());
- if (ajp) {
- parameters.put("Type", "ajp");
- } else if (ssl) {
- parameters.put("Type", "https");
- } else {
- parameters.put("Type", "http");
- }
-
- // Other configuration parameters
- if (nodeConfig.getDomain() != null) {
- parameters.put("Domain", nodeConfig.getDomain());
- }
- if (nodeConfig.getFlushPackets()) {
- parameters.put("flushpackets", "On");
- }
- if (nodeConfig.getFlushWait() != -1) {
- parameters.put("flushwait", "" + nodeConfig.getFlushWait());
- }
- if (nodeConfig.getPing() != -1) {
- parameters.put("ping", "" + nodeConfig.getPing());
- }
- if (nodeConfig.getSmax() != -1) {
- parameters.put("smax", "" + nodeConfig.getSmax());
- }
- if (nodeConfig.getTtl() != -1) {
- parameters.put("ttl", "" + nodeConfig.getTtl());
- }
- if (nodeConfig.getNodeTimeout() != -1) {
- parameters.put("Timeout", "" + nodeConfig.getNodeTimeout());
- }
- if (nodeConfig.getBalancer() != null) {
- parameters.put("Balancer", nodeConfig.getBalancer());
- }
- if (!balancerConfig.getStickySession()) {
- parameters.put("StickySession", "No");
- }
- if (!org.apache.catalina.Globals.SESSION_COOKIE_NAME.equals("JSESSIONID")) {
- parameters.put("StickySessionCookie", org.apache.catalina.Globals.SESSION_COOKIE_NAME);
- }
- if (!org.apache.catalina.Globals.SESSION_PARAMETER_NAME.equals("jsessionid")) {
- parameters.put("StickySessionPath", org.apache.catalina.Globals.SESSION_PARAMETER_NAME);
- }
- if (balancerConfig.getStickySessionRemove()) {
- parameters.put("StickSessionRemove", "Yes");
- }
- if (!balancerConfig.getStickySessionForce()) {
- parameters.put("StickySessionForce", "No");
- }
- if (balancerConfig.getWorkerTimeout() != -1) {
- parameters.put("WaitWorker", "" + balancerConfig.getWorkerTimeout());
- }
- if (balancerConfig.getMaxAttempts() != -1) {
- parameters.put("Maxattempts", "" + balancerConfig.getMaxAttempts());
- }
-
- return new MCMPRequest(MCMPRequestType.CONFIG, false, parameters);
- }
-
- public static MCMPRequest createEnableAppRequest(Context context)
- {
- return new MCMPRequest(MCMPRequestType.ENABLE_APP, false, createContextParameters(context));
- }
-
- public static MCMPRequest createDisableAppRequest(Context context)
- {
- return new MCMPRequest(MCMPRequestType.DISABLE_APP, false, createContextParameters(context));
- }
-
- public static MCMPRequest createStopAppRequest(Context context)
- {
- return new MCMPRequest(MCMPRequestType.STOP_APP, false, createContextParameters(context));
- }
-
- public static MCMPRequest createRemoveAppRequest(Context context)
- {
- return new MCMPRequest(MCMPRequestType.REMOVE_APP, false, createContextParameters(context));
- }
-
- public static MCMPRequest createStatusRequest(Engine engine, int lbf)
- {
- Map<String, String> parameters = new HashMap<String, String>();
- parameters.put("JVMRoute", engine.getJvmRoute());
- parameters.put("Load", String.valueOf(lbf));
- return new MCMPRequest(MCMPRequestType.STATUS, false, parameters);
- }
-
- public static MCMPRequest createStatusRequest(String jvmRoute, int lbf)
- {
- Map<String, String> parameters = new HashMap<String, String>();
- parameters.put("JVMRoute", jvmRoute);
- parameters.put("Load", String.valueOf(lbf));
- return new MCMPRequest(MCMPRequestType.STATUS, false, parameters);
- }
-
- public static MCMPRequest createEnableEngineRequest(Engine engine)
- {
- return new MCMPRequest(MCMPRequestType.ENABLE_APP, true, createEngineParameters(engine));
- }
-
- public static MCMPRequest createDisableEngineRequest(Engine engine)
- {
- return new MCMPRequest(MCMPRequestType.DISABLE_APP, true, createEngineParameters(engine));
- }
-
- public static MCMPRequest createRemoveAllRequest(Engine engine)
- {
- return new MCMPRequest(MCMPRequestType.REMOVE_APP, true, createEngineParameters(engine));
- }
-
- /**
- * Reset configuration for a particular proxy following an error.
- */
- public static List<MCMPRequest> getResetRequests(Server server,
- NodeConfiguration nodeConfig, BalancerConfiguration balancerConfig) {
-
- List<MCMPRequest> requests = new ArrayList<MCMPRequest>();
- Service[] services = server.findServices();
- for (int i = 0; i < services.length; i++) {
- Engine engine = (Engine) services[i].getContainer();
- if (engine.getJvmRoute() != null)
- {
- requests.add(MCMPUtils.createRemoveAllRequest(engine));
- }
- requests.add(MCMPUtils.createConfigRequest(engine, nodeConfig, balancerConfig));
- Container[] children = engine.findChildren();
- for (int j = 0; j < children.length; j++) {
- Container[] children2 = children[j].findChildren();
- for (int k = 0; k < children2.length; k++) {
- Context ctx = (Context) children2[k];
- if (ctx.isStarted())
- {
- requests.add(MCMPUtils.createEnableAppRequest(ctx));
- }
- }
- }
- }
-
- return requests;
- }
-
- public static MCMPRequest getInfoRequest()
- {
- return INFO;
- }
-
- private static Map<String, String> createEngineParameters(Engine engine)
- {
- Map<String, String> parameters = new HashMap<String, String>();
- parameters.put("JVMRoute", engine.getJvmRoute());
- return parameters;
- }
-
- private static Map<String, String> createContextParameters(Context context)
- {
- Map<String, String> parameters = new HashMap<String, String>();
- parameters.put("JVMRoute", Utils.getJvmRoute(context));
- parameters.put("Context", ("".equals(context.getPath())) ? "/" : context.getPath());
- parameters.put("Alias", Utils.getHost(context));
- return parameters;
- }
-
- public static AddressPort parseAddressPort(String addressPort)
- {
- int pos = addressPort.indexOf(':');
- String host = null;
- int port = 0;
- if (pos < 0) {
- host = addressPort;
- } else if (pos == 0) {
- host = null;
- port = Integer.parseInt(addressPort.substring(1));
- } else {
- host = addressPort.substring(0, pos);
- port = Integer.parseInt(addressPort.substring(pos + 1));
- }
-
- InetAddress address = null;
- try {
- address = InetAddress.getByName(host);
- } catch (Exception e) {
- throw new IllegalArgumentException(e);
- }
-
- return new AddressPort(address, port);
- }
-
- public static List<AddressPort> parseProxies(String proxyList)
- {
- List<AddressPort> proxies = new ArrayList<AddressPort>();
- if (proxyList != null)
- {
- StringTokenizer tok = new StringTokenizer(proxyList, ",");
- while (tok.hasMoreTokens()) {
- String token = tok.nextToken().trim();
- int pos = token.indexOf(':');
- String address = null;
- int port = DEFAULT_PORT;
- if (pos < 0) {
- address = token;
- } else if (pos == 0) {
- address = null;
- port = Integer.parseInt(token.substring(1));
- } else {
- address = token.substring(0, pos);
- port = Integer.parseInt(token.substring(pos + 1));
- }
- InetAddress inetAddress = null;
- try {
- if (address != null) {
- inetAddress = InetAddress.getByName(address);
- }
- } catch (Exception e) {
- log.error(sm.getString("modcluster.error.invalidHost", address), e);
- continue;
- }
- proxies.add(new AddressPort(inetAddress, port));
- }
- }
-
- return proxies;
- }
-
- /**
- * Disable external instantiation.
- */
- private MCMPUtils()
- {
- }
-
-}
Deleted: trunk/tomcat/src/main/org/jboss/web/tomcat/service/modcluster/mcmp/ResetRequestSource.java
===================================================================
--- trunk/tomcat/src/main/org/jboss/web/tomcat/service/modcluster/mcmp/ResetRequestSource.java 2008-09-03 18:23:47 UTC (rev 77861)
+++ trunk/tomcat/src/main/org/jboss/web/tomcat/service/modcluster/mcmp/ResetRequestSource.java 2008-09-03 19:01:23 UTC (rev 77862)
@@ -1,45 +0,0 @@
-/*
- * 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.web.tomcat.service.modcluster.mcmp;
-
-import java.util.List;
-
-/**
- * Source for a list of requests that should be sent to an httpd-side
- * mod_cluster instance when an {@link MCMPHandler} determines that
- * the httpd-side state needs to be reset.
- *
- * @author Brian Stansberry
- *
- */
-public interface ResetRequestSource
-{
- /**
- * Gets a list of requests that should be sent to an httpd-side
- * mod_cluster instance when an {@link MCMPHandler} determines that
- * its state needs to be reset.
- *
- * @return a list of requests. Will not return <code>null</code>.
- */
- List<MCMPRequest> getResetRequests();
-}
Deleted: trunk/tomcat/src/resources/mod-cluster-jboss-beans.xml
===================================================================
--- trunk/tomcat/src/resources/mod-cluster-jboss-beans.xml 2008-09-03 18:23:47 UTC (rev 77861)
+++ trunk/tomcat/src/resources/mod-cluster-jboss-beans.xml 2008-09-03 19:01:23 UTC (rev 77862)
@@ -1,98 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-
-<!--
- Beans that provide JBoss AS-side functionality for mod_cluster. These
- beans are all "On Demand", i.e. that are not installed unless requested.
--->
-<deployment xmlns="urn:jboss:bean-deployer:2.0">
-
- <!-- Configuration bean -->
- <bean name="ModClusterConfig"
- class="org.jboss.web.tomcat.service.modcluster.config.ModClusterConfig"
- mode="On Demand">
-
- <!-- Configure this node's communication with the load balancer -->
-
- <!-- Comma separated list of address:port listing the httpd servers
- where mod_cluster is running.
- <property name="proxyList"></property>
- -->
- <!--URL prefix to send with commands to mod_cluster. Default is no prefix
- <property name="proxyURL">/bla</property>
- -->
-
- <!-- mod_advertise is a small httpd module that advertises the
- availability of httpd servers via multicast, allowing
- ModClusterService to discover the httpd front-end instead of/in
- addition to having them defined in proxyList.
- -->
- <!-- Whether to listen for advertise messages -->
- <property name="advertise">true</property>
- <!-- Multicast address to listen on for advertisements -->
- <property name="advertiseGroupAddress">${jboss.modcluster.advertise.address,jboss.partition.udpGroup:224.0.1.105}</property>
- <!-- Port to listen to for advertisements -->
- <property name="advertisePort">${jboss.modcluster.advertise.address:23364}</property>
-
- <!-- Key the front-end is going to send with advertise messages.
- Default is no key no check.
- <property name="advertiseSecurityKey"></property>
- -->
-
- <!-- Whether to use SSL to communicate with mod_cluster. Note this
- has nothing to do with handling of https requests by JBoss Web -->
- <property name="ssl">false</property>
-
-
- <!-- Configuration values for the load balancer itself (must be the
- same on all nodes in the cluster). These will be passed to the
- load balancer. -->
- <property name="stickySession">true</property>
- <property name="stickySessionForce">false</property>
- <property name="stickySessionRemove">false</property>
- <property name="maxAttempts">-1</property>
- <property name="workerTimeout">-1</property>
-
- </bean>
-
- <!-- Provides information to ModClusterService informing it how much load
- this server should take. This basic impl just uses a static
- configuration and doesn't adjust it based on runtime conditions. -->
- <bean name="ModClusterLoadBalanceFactorProvider"
- class="org.jboss.web.tomcat.service.modcluster.load.impl.StaticLoadBalanceFactorProvider"
- mode="On Demand">
-
- <property name="loadBalanceFactor">1</property>
-
- </bean>
-
- <!-- The core ModClusterService -->
- <bean name="ModClusterService"
- class="org.jboss.web.tomcat.service.modcluster.ModClusterService"
- mode="On Demand">
-
- <annotation>@org.jboss.aop.microcontainer.aspects.jmx.JMX(name="jboss.web:service=ModCluster",exposedInterface=org.jboss.web.tomcat.service.modcluster.ModClusterServiceMBean.class)</annotation>
-
- <constructor>
- <parameter><inject bean="HAPartition"/></parameter>
- <parameter><inject bean="ModClusterConfig"/></parameter>
- <parameter><inject bean="ModClusterLoadBalanceFactorProvider"/></parameter>
- <parameter><bean class="org.jboss.ha.singleton.HASingletonElectionPolicySimple"/></parameter>
- </constructor>
-
- </bean>
-
- <!--
- An org.apache.catalina.LifecycleListener impl that notifies
- ModClusterService of events inside JBoss Web (deployments, starts, stops. etc.)
- -->
- <bean name="ModClusterLifecycleListener"
- class="org.jboss.web.tomcat.service.modcluster.BasicClusterListener"
- mode="On Demand">
-
- <constructor>
- <parameter><inject bean="ModClusterService"/></parameter>
- </constructor>
-
- </bean>
-
-</deployment>
\ No newline at end of file
More information about the jboss-cvs-commits
mailing list