Class ModClusterListener
java.lang.Object
org.jboss.modcluster.config.impl.ModClusterConfig
org.jboss.modcluster.container.tomcat.ModClusterListener
- All Implemented Interfaces:
org.apache.catalina.LifecycleListener,AdvertiseConfiguration,BalancerConfiguration,MCMPHandlerConfiguration,NodeConfiguration,SSLConfiguration,TomcatConnectorConfiguration,LoadBalanceFactorProviderFactory,ModClusterServiceMBean
- Direct Known Subclasses:
ModClusterListener
public class ModClusterListener
extends ModClusterConfig
implements TomcatConnectorConfiguration, org.apache.catalina.LifecycleListener, LoadBalanceFactorProviderFactory, ModClusterServiceMBean
Mod_cluster lifecycle listener for use in Tomcat.
- Author:
- Paul Ferraro
-
Field Summary
Fields inherited from interface org.jboss.modcluster.config.AdvertiseConfiguration
DEFAULT_SOCKET_ADDRESS -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoidAdd a proxy to the list of those with which this handler communicates.booleandisable()Disable all webapps for all engines.booleandisableContext(String hostName, String contextPath) Disables the webapp with the specified host and context path.booleanenable()Enable all webapps for all engines.booleanenableContext(String hostName, String contextPath) Enables the webapp with the specified host and context path.intReturns optional connector address.Returns optional connector port.Returns optional external connector address.Returns optional external connector port.intClass<? extends JvmRouteFactory>floatReturns the factor by which the contribution of historical load values to the load factor calculation should exponentially decay.intReturns the number of historic load values used when calculating the load factor.doubleReturns the class name of the configured load metric.Retrieves the full proxy configuration.Retrieves the full proxy info message.voidlifecycleEvent(org.apache.catalina.LifecycleEvent event) ping()Ping httpd. determines whether each proxy is accessible and healthy. returning the PING_RSP grouped by proxy address.Ping a node from httpd. returning the PING_RSP grouped by proxy address. determines whether the node configured with the specified jvm route is accessible from each proxy returning the PING_RSP grouped by proxy address.Ping a node defined protocol, host and port from httpd. determines whether a node (not necessarily configured) with the matching connector is accessible from each proxyvoidrefresh()Refresh configuration.voidremoveProxy(String host, int port) Remove a proxy from the list of those with which this handler communicates.voidreset()Reset a DOWN connection to the proxy up to ERROR, where the configuration will be refreshed.voidsetAdvertiseGroupAddress(String advertiseGroupAddress) voidsetAdvertiseInterface(String advertiseInterface) voidsetAdvertiseInterfaceName(String advertiseInterfaceName) voidsetAdvertisePort(int advertisePort) voidsetConnectorAddress(String connectorAddress) voidsetConnectorPort(int connectorPort) voidsetExcludedContexts(String contexts) voidsetExternalConnectorAddress(String externalConnectorAddress) voidsetExternalConnectorPort(int externalConnectorPort) voidsetInitialLoad(int initialLoad) voidsetJvmRouteFactoryClass(Class<? extends JvmRouteFactory> factoryClass) voidsetLoadDecayFactor(float decayFactor) Sets the factor by which the contribution of historical load values to the load factor calculation should exponentially decay.voidsetLoadDecayFactor(String decayFactor) String-based variant ofsetLoadDecayFactor(float)to set float decay factor used by Tomcat modeler.voidsetLoadHistory(int history) Sets the number of historic load values used when calculating the load factor.voidsetLoadMetricCapacity(String capacity) Sets the capacity (i.e. maximum expected value) of the load values returned by the load metric specified bygetLoadMetricClass()voidsetLoadMetricClass(String loadMetricClass) Sets the class of the desired load metricvoidsetProxyList(String addresses) voidsetSessionDrainingStrategy(String sessionDrainingStrategy) booleanstop(long timeout) booleanAttempts to gracefully stops all web applications, within the specified timeout.booleanstopContext(String host, String path, long timeout) booleanstopContext(String host, String path, long timeout, TimeUnit unit) Attempts to gracefully stops a single web application, within the specified timeout.Methods inherited from class org.jboss.modcluster.config.impl.ModClusterConfig
getAdvertise, getAdvertiseInterface, getAdvertiseSecurityKey, getAdvertiseSocketAddress, getAdvertiseThreadFactory, getBalancer, getExcludedContextsPerHost, getFlushPackets, getFlushWait, getJvmRouteFactory, getLoadBalancingGroup, getMaxAttempts, getNodeTimeout, getPing, getProxies, getProxyConfigurations, getProxyURL, getSessionDrainingStrategy, getSmax, getSocketFactory, getSocketTimeout, getSslCertificateEncodingAlgorithm, getSslCiphers, getSslCrlFile, getSslKeyAlias, getSslKeyStore, getSslKeyStorePassword, getSslKeyStoreProvider, getSslKeyStoreType, getSslProtocol, getSslTrustAlgorithm, getSslTrustMaxCertLength, getSslTrustStore, getSslTrustStorePassword, getSslTrustStoreProvider, getSslTrustStoreType, getStickySession, getStickySessionForce, getStickySessionRemove, getStopContextTimeout, getStopContextTimeoutUnit, getTtl, getWorkerTimeout, isAutoEnableContexts, isSsl, setAdvertise, setAdvertiseInterface, setAdvertiseInterface, setAdvertiseSecurityKey, setAdvertiseSocketAddress, setAdvertiseThreadFactory, setAutoEnableContexts, setBalancer, setExcludedContextsPerHost, setFlushPackets, setFlushWait, setJvmRouteFactory, setLoadBalancingGroup, setMaxAttempts, setNodeTimeout, setPing, setProxies, setProxyConfigurations, setProxyURL, setSessionDrainingStrategy, setSmax, setSocketTimeout, setSsl, setSslCertificateEncodingAlgorithm, setSslCiphers, setSslCrlFile, setSslKeyAlias, setSslKeyStore, setSslKeyStorePassword, setSslKeyStoreProvider, setSslKeyStoreType, setSslProtocol, setSslTrustAlgorithm, setSslTrustMaxCertLength, setSslTrustStore, setSslTrustStorePassword, setSslTrustStoreProvider, setSslTrustStoreType, setStickySession, setStickySessionForce, setStickySessionRemove, setStopContextTimeout, setStopContextTimeoutUnit, setTtl, setWorkerTimeout
-
Constructor Details
-
ModClusterListener
public ModClusterListener()
-
-
Method Details
-
createLoadBalanceFactorProvider
- Specified by:
createLoadBalanceFactorProviderin interfaceLoadBalanceFactorProviderFactory
-
lifecycleEvent
public void lifecycleEvent(org.apache.catalina.LifecycleEvent event) - Specified by:
lifecycleEventin interfaceorg.apache.catalina.LifecycleListener
-
getJvmRouteFactoryClass
-
setJvmRouteFactoryClass
-
getLoadMetricClass
Returns the class name of the configured load metric.- Returns:
- the name of a class implementing
LoadMetric
-
setLoadMetricClass
Sets the class of the desired load metric- Parameters:
loadMetricClass- a class implementingLoadMetric- Throws:
IllegalArgumentException- if metric class could not be loaded
-
getLoadDecayFactor
public float getLoadDecayFactor()Returns the factor by which the contribution of historical load values to the load factor calculation should exponentially decay.- Returns:
- the configured load decay factor
-
setLoadDecayFactor
public void setLoadDecayFactor(float decayFactor) Sets the factor by which the contribution of historical load values to the load factor calculation should exponentially decay.- Parameters:
decayFactor- a positive number
-
setLoadDecayFactor
String-based variant ofsetLoadDecayFactor(float)to set float decay factor used by Tomcat modeler.- Parameters:
decayFactor- a positive number
-
getLoadHistory
public int getLoadHistory()Returns the number of historic load values used when calculating the load factor.- Returns:
- the configured load history
-
setLoadHistory
public void setLoadHistory(int history) Sets the number of historic load values used when calculating the load factor.- Parameters:
history-
-
getLoadMetricCapacity
public double getLoadMetricCapacity() -
setLoadMetricCapacity
Sets the capacity (i.e. maximum expected value) of the load values returned by the load metric specified bygetLoadMetricClass()- Parameters:
capacity- a load capacity
-
getInitialLoad
public int getInitialLoad() -
setInitialLoad
public void setInitialLoad(int initialLoad) -
addProxy
Description copied from interface:ModClusterServiceMBeanAdd a proxy to the list of those with which this handler communicates. Communication does not begin until the next call toMCMPHandler.status().- Specified by:
addProxyin interfaceModClusterServiceMBean- Parameters:
host- the hostname of the proxy; a string suitable for passing toInetAddress.getByHost(...)port- the port on which the proxy listens for MCMP requests
-
disable
public boolean disable()Description copied from interface:ModClusterServiceMBeanDisable all webapps for all engines.- Specified by:
disablein interfaceModClusterServiceMBean- Returns:
- true, if all proxies are responding normally, false otherwise
-
disableContext
Description copied from interface:ModClusterServiceMBeanDisables the webapp with the specified host and context path.- Specified by:
disableContextin interfaceModClusterServiceMBean- Parameters:
hostName- host name of the target webappcontextPath- context path of the target webapp- Returns:
- true, if all proxies are responding normally, false otherwise
-
ping
Description copied from interface:ModClusterServiceMBeanPing httpd. determines whether each proxy is accessible and healthy. returning the PING_RSP grouped by proxy address.- Specified by:
pingin interfaceModClusterServiceMBean- Returns:
- a map of PING_RSP responses, grouped by proxy
-
ping
Description copied from interface:ModClusterServiceMBeanPing a node from httpd. returning the PING_RSP grouped by proxy address. determines whether the node configured with the specified jvm route is accessible from each proxy returning the PING_RSP grouped by proxy address.- Specified by:
pingin interfaceModClusterServiceMBean- Parameters:
jvmRoute- a jvm route.- Returns:
- a map of PING_RSP responses, grouped by proxy
-
ping
Description copied from interface:ModClusterServiceMBeanPing a node defined protocol, host and port from httpd. determines whether a node (not necessarily configured) with the matching connector is accessible from each proxy- Specified by:
pingin interfaceModClusterServiceMBean- Parameters:
scheme- ajp, http or httpshost- name or IP of a the host- Returns:
- a map of PING_RSP responses, grouped by proxy
-
enable
public boolean enable()Description copied from interface:ModClusterServiceMBeanEnable all webapps for all engines.- Specified by:
enablein interfaceModClusterServiceMBean- Returns:
- true, if all proxies are responding normally, false otherwise
-
enableContext
Description copied from interface:ModClusterServiceMBeanEnables the webapp with the specified host and context path.- Specified by:
enableContextin interfaceModClusterServiceMBean- Parameters:
hostName- host name of the target webappcontextPath- context path of the target webapp- Returns:
- true, if all proxies are responding normally, false otherwise
-
getProxyConfiguration
Description copied from interface:ModClusterServiceMBeanRetrieves the full proxy configuration. response: node: [1:1] JVMRoute: node1 Domain: [bla] Host: 127.0.0.1 Port: 8009 Type: ajp host: 1 [] vhost: 1 node: 1 context: 1 [/] vhost: 1 node: 1 status: 1 context: 2 [/myapp] vhost: 1 node: 1 status: 1 context: 3 [/host-manager] vhost: 1 node: 1 status: 1 context: 4 [/docs] vhost: 1 node: 1 status: 1 context: 5 [/manager] vhost: 1 node: 1 status: 1 Sends aDUMPrequest to all proxies, returning the responses grouped by proxy address.- Specified by:
getProxyConfigurationin interfaceModClusterServiceMBean- Returns:
- a map of DUMP_RSP responses, grouped by proxy
-
getProxyInfo
Description copied from interface:ModClusterServiceMBeanRetrieves the full proxy info message. Sends anINFOrequest to all proxies, returning the responses grouped by proxy address.- Specified by:
getProxyInfoin interfaceModClusterServiceMBean- Returns:
- a map of INFO_RSP responses, grouped by proxy
-
refresh
public void refresh()Description copied from interface:ModClusterServiceMBeanRefresh configuration.- Specified by:
refreshin interfaceModClusterServiceMBean
-
removeProxy
Description copied from interface:ModClusterServiceMBeanRemove a proxy from the list of those with which this handler communicates. Communication does not end until the next call toMCMPHandler.status().- Specified by:
removeProxyin interfaceModClusterServiceMBean- Parameters:
host- the hostname of the proxy; a string suitable for passing toInetAddress.getByHost(...)port- the port on which the proxy listens for MCMP requests
-
reset
public void reset()Description copied from interface:ModClusterServiceMBeanReset a DOWN connection to the proxy up to ERROR, where the configuration will be refreshed.- Specified by:
resetin interfaceModClusterServiceMBean
-
stop
Description copied from interface:ModClusterServiceMBeanAttempts to gracefully stops all web applications, within the specified timeout.- Disables all contexts
- Waits for all sessions to drain
- Stops all contexts
- Specified by:
stopin interfaceModClusterServiceMBean- Parameters:
timeout- number of units of time for which to wait for sessions to drain. Negative or zero timeout value will wait forever.unit- unit of time represented in timeout parameter- Returns:
- true, if all contexts stopped successfully, false if sessions fail to drain before specified timeout.
-
stopContext
Description copied from interface:ModClusterServiceMBeanAttempts to gracefully stops a single web application, within the specified timeout.- Disables the specified context
- Waits for all sessions for the specified context to drain
- Stops the specified context
- Specified by:
stopContextin interfaceModClusterServiceMBeantimeout- number of units of time for which to wait for sessions to drain. Negative or zero timeout value will wait forever.unit- unit of time represented in timeout parameter- Returns:
- true, if the specified context was stopped successfully, false if sessions fail to drain before specified timeout.
-
getProxyConfigurationString
-
getProxyInfoString
-
stop
public boolean stop(long timeout) -
stopContext
-
getConnectorAddress
Description copied from interface:TomcatConnectorConfigurationReturns optional connector address.- Specified by:
getConnectorAddressin interfaceTomcatConnectorConfiguration- Returns:
- connector address
-
setConnectorAddress
-
getConnectorPort
Description copied from interface:TomcatConnectorConfigurationReturns optional connector port.- Specified by:
getConnectorPortin interfaceTomcatConnectorConfiguration- Returns:
- connector port
-
setConnectorPort
public void setConnectorPort(int connectorPort) -
getExternalConnectorAddress
Description copied from interface:TomcatConnectorConfigurationReturns optional external connector address.- Specified by:
getExternalConnectorAddressin interfaceTomcatConnectorConfiguration- Returns:
- connector address
-
setExternalConnectorAddress
-
getExternalConnectorPort
Description copied from interface:TomcatConnectorConfigurationReturns optional external connector port.- Specified by:
getExternalConnectorPortin interfaceTomcatConnectorConfiguration- Returns:
- connector port
-
setExternalConnectorPort
public void setExternalConnectorPort(int externalConnectorPort) -
getAdvertiseGroupAddress
-
setAdvertiseGroupAddress
-
getAdvertisePort
public int getAdvertisePort() -
setAdvertisePort
public void setAdvertisePort(int advertisePort) -
setAdvertiseInterface
-
setAdvertiseInterfaceName
-
setProxyList
-
getProxyList
-
setExcludedContexts
-
getExcludedContexts
-
setSessionDrainingStrategy
-