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 Constructor Description ModClusterListener()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description void
addProxy(String host, int port)
Add a proxy to the list of those with which this handler communicates.LoadBalanceFactorProvider
createLoadBalanceFactorProvider()
boolean
disable()
Disable all webapps for all engines.boolean
disableContext(String hostName, String contextPath)
Disables the webapp with the specified host and context path.boolean
enable()
Enable all webapps for all engines.boolean
enableContext(String hostName, String contextPath)
Enables the webapp with the specified host and context path.String
getAdvertiseGroupAddress()
int
getAdvertisePort()
String
getConnectorAddress()
Returns optional connector address.Integer
getConnectorPort()
Returns optional connector port.String
getExcludedContexts()
String
getExternalConnectorAddress()
Returns optional external connector address.Integer
getExternalConnectorPort()
Returns optional external connector port.int
getInitialLoad()
Class<? extends JvmRouteFactory>
getJvmRouteFactoryClass()
float
getLoadDecayFactor()
Returns the factor by which the contribution of historical load values to the load factor calculation should exponentially decay.int
getLoadHistory()
Returns the number of historic load values used when calculating the load factor.double
getLoadMetricCapacity()
String
getLoadMetricClass()
Returns the class name of the configured load metric.Map<InetSocketAddress,String>
getProxyConfiguration()
Retrieves the full proxy configuration.String
getProxyConfigurationString()
Map<InetSocketAddress,String>
getProxyInfo()
Retrieves the full proxy info message.String
getProxyInfoString()
String
getProxyList()
void
lifecycleEvent(org.apache.catalina.LifecycleEvent event)
Map<InetSocketAddress,String>
ping()
Ping httpd.Map<InetSocketAddress,String>
ping(String jvmRoute)
Ping a node from httpd.Map<InetSocketAddress,String>
ping(String scheme, String host, int port)
Ping a node defined protocol, host and port from httpd.void
refresh()
Refresh configuration.void
removeProxy(String host, int port)
Remove a proxy from the list of those with which this handler communicates.void
reset()
Reset a DOWN connection to the proxy up to ERROR, where the configuration will be refreshed.void
setAdvertiseGroupAddress(String advertiseGroupAddress)
void
setAdvertiseInterface(String advertiseInterface)
void
setAdvertiseInterfaceName(String advertiseInterfaceName)
void
setAdvertisePort(int advertisePort)
void
setConnectorAddress(String connectorAddress)
void
setConnectorPort(int connectorPort)
void
setExcludedContexts(String contexts)
void
setExternalConnectorAddress(String externalConnectorAddress)
void
setExternalConnectorPort(int externalConnectorPort)
void
setInitialLoad(int initialLoad)
void
setJvmRouteFactoryClass(Class<? extends JvmRouteFactory> factoryClass)
void
setLoadDecayFactor(float decayFactor)
Sets the factor by which the contribution of historical load values to the load factor calculation should exponentially decay.void
setLoadDecayFactor(String decayFactor)
String-based variant ofsetLoadDecayFactor(float)
to set float decay factor used by Tomcat modeler.void
setLoadHistory(int history)
Sets the number of historic load values used when calculating the load factor.void
setLoadMetricCapacity(String capacity)
Sets the capacity (i.e.void
setLoadMetricClass(String loadMetricClass)
Sets the class of the desired load metricvoid
setProxyList(String addresses)
void
setSessionDrainingStrategy(String sessionDrainingStrategy)
boolean
stop(long timeout)
boolean
stop(long timeout, TimeUnit unit)
Attempts to gracefully stops all web applications, within the specified timeout.boolean
stopContext(String host, String path, long timeout)
boolean
stopContext(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
-
-
-
-
Method Detail
-
createLoadBalanceFactorProvider
public LoadBalanceFactorProvider createLoadBalanceFactorProvider()
- Specified by:
createLoadBalanceFactorProvider
in interfaceLoadBalanceFactorProviderFactory
-
lifecycleEvent
public void lifecycleEvent(org.apache.catalina.LifecycleEvent event)
- Specified by:
lifecycleEvent
in interfaceorg.apache.catalina.LifecycleListener
-
getJvmRouteFactoryClass
public Class<? extends JvmRouteFactory> getJvmRouteFactoryClass()
-
setJvmRouteFactoryClass
public void setJvmRouteFactoryClass(Class<? extends JvmRouteFactory> factoryClass)
-
getLoadMetricClass
public String getLoadMetricClass()
Returns the class name of the configured load metric.- Returns:
- the name of a class implementing
LoadMetric
-
setLoadMetricClass
public void setLoadMetricClass(String loadMetricClass)
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
public void setLoadDecayFactor(String decayFactor)
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
public void setLoadMetricCapacity(String capacity)
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
public void addProxy(String host, int port)
Description copied from interface:ModClusterServiceMBean
Add a proxy to the list of those with which this handler communicates. Communication does not begin until the next call toMCMPHandler.status()
.- Specified by:
addProxy
in 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:ModClusterServiceMBean
Disable all webapps for all engines.- Specified by:
disable
in interfaceModClusterServiceMBean
- Returns:
- true, if all proxies are responding normally, false otherwise
-
disableContext
public boolean disableContext(String hostName, String contextPath)
Description copied from interface:ModClusterServiceMBean
Disables the webapp with the specified host and context path.- Specified by:
disableContext
in 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
public Map<InetSocketAddress,String> ping()
Description copied from interface:ModClusterServiceMBean
Ping httpd. determines whether each proxy is accessible and healthy. returning the PING_RSP grouped by proxy address.- Specified by:
ping
in interfaceModClusterServiceMBean
- Returns:
- a map of PING_RSP responses, grouped by proxy
-
ping
public Map<InetSocketAddress,String> ping(String jvmRoute)
Description copied from interface:ModClusterServiceMBean
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.- Specified by:
ping
in interfaceModClusterServiceMBean
- Parameters:
jvmRoute
- a jvm route.- Returns:
- a map of PING_RSP responses, grouped by proxy
-
ping
public Map<InetSocketAddress,String> ping(String scheme, String host, int port)
Description copied from interface:ModClusterServiceMBean
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 proxy- Specified by:
ping
in 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:ModClusterServiceMBean
Enable all webapps for all engines.- Specified by:
enable
in interfaceModClusterServiceMBean
- Returns:
- true, if all proxies are responding normally, false otherwise
-
enableContext
public boolean enableContext(String hostName, String contextPath)
Description copied from interface:ModClusterServiceMBean
Enables the webapp with the specified host and context path.- Specified by:
enableContext
in 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
public Map<InetSocketAddress,String> getProxyConfiguration()
Description copied from interface:ModClusterServiceMBean
Retrieves 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 aDUMP
request to all proxies, returning the responses grouped by proxy address.- Specified by:
getProxyConfiguration
in interfaceModClusterServiceMBean
- Returns:
- a map of DUMP_RSP responses, grouped by proxy
-
getProxyInfo
public Map<InetSocketAddress,String> getProxyInfo()
Description copied from interface:ModClusterServiceMBean
Retrieves the full proxy info message. Sends anINFO
request to all proxies, returning the responses grouped by proxy address.- Specified by:
getProxyInfo
in interfaceModClusterServiceMBean
- Returns:
- a map of INFO_RSP responses, grouped by proxy
-
refresh
public void refresh()
Description copied from interface:ModClusterServiceMBean
Refresh configuration.- Specified by:
refresh
in interfaceModClusterServiceMBean
-
removeProxy
public void removeProxy(String host, int port)
Description copied from interface:ModClusterServiceMBean
Remove a proxy from the list of those with which this handler communicates. Communication does not end until the next call toMCMPHandler.status()
.- Specified by:
removeProxy
in 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:ModClusterServiceMBean
Reset a DOWN connection to the proxy up to ERROR, where the configuration will be refreshed.- Specified by:
reset
in interfaceModClusterServiceMBean
-
stop
public boolean stop(long timeout, TimeUnit unit)
Description copied from interface:ModClusterServiceMBean
Attempts to gracefully stops all web applications, within the specified timeout.- Disables all contexts
- Waits for all sessions to drain
- Stops all contexts
- Specified by:
stop
in 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
public boolean stopContext(String host, String path, long timeout, TimeUnit unit)
Description copied from interface:ModClusterServiceMBean
Attempts 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:
stopContext
in interfaceModClusterServiceMBean
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 the specified context was stopped successfully, false if sessions fail to drain before specified timeout.
-
getProxyConfigurationString
public String getProxyConfigurationString()
-
getProxyInfoString
public String getProxyInfoString()
-
stop
public boolean stop(long timeout)
-
getConnectorAddress
public String getConnectorAddress()
Description copied from interface:TomcatConnectorConfiguration
Returns optional connector address.- Specified by:
getConnectorAddress
in interfaceTomcatConnectorConfiguration
- Returns:
- connector address
-
setConnectorAddress
public void setConnectorAddress(String connectorAddress)
-
getConnectorPort
public Integer getConnectorPort()
Description copied from interface:TomcatConnectorConfiguration
Returns optional connector port.- Specified by:
getConnectorPort
in interfaceTomcatConnectorConfiguration
- Returns:
- connector port
-
setConnectorPort
public void setConnectorPort(int connectorPort)
-
getExternalConnectorAddress
public String getExternalConnectorAddress()
Description copied from interface:TomcatConnectorConfiguration
Returns optional external connector address.- Specified by:
getExternalConnectorAddress
in interfaceTomcatConnectorConfiguration
- Returns:
- connector address
-
setExternalConnectorAddress
public void setExternalConnectorAddress(String externalConnectorAddress)
-
getExternalConnectorPort
public Integer getExternalConnectorPort()
Description copied from interface:TomcatConnectorConfiguration
Returns optional external connector port.- Specified by:
getExternalConnectorPort
in interfaceTomcatConnectorConfiguration
- Returns:
- connector port
-
setExternalConnectorPort
public void setExternalConnectorPort(int externalConnectorPort)
-
getAdvertiseGroupAddress
public String getAdvertiseGroupAddress()
-
setAdvertiseGroupAddress
public void setAdvertiseGroupAddress(String advertiseGroupAddress)
-
getAdvertisePort
public int getAdvertisePort()
-
setAdvertisePort
public void setAdvertisePort(int advertisePort)
-
setAdvertiseInterface
public void setAdvertiseInterface(String advertiseInterface)
-
setAdvertiseInterfaceName
public void setAdvertiseInterfaceName(String advertiseInterfaceName)
-
setProxyList
public void setProxyList(String addresses)
-
getProxyList
public String getProxyList()
-
setExcludedContexts
public void setExcludedContexts(String contexts)
-
getExcludedContexts
public String getExcludedContexts()
-
setSessionDrainingStrategy
public void setSessionDrainingStrategy(String sessionDrainingStrategy)
-
-