Package org.jboss.modcluster
Class ModClusterService
java.lang.Object
org.jboss.modcluster.ModClusterService
- All Implemented Interfaces:
ContainerEventHandler
,LoadBalanceFactorProvider
,ContextFilter
,MCMPConnectionListener
,ModClusterServiceMBean
public class ModClusterService
extends Object
implements ModClusterServiceMBean, ContainerEventHandler, LoadBalanceFactorProvider, MCMPConnectionListener, ContextFilter
-
Field Summary
-
Constructor Summary
ModifierConstructorDescriptionModClusterService
(ModClusterConfig config, LoadBalanceFactorProvider loadBalanceFactorProvider) ModClusterService
(ModClusterConfig config, LoadBalanceFactorProviderFactory loadBalanceFactorProviderFactory) ModClusterService
(ModClusterConfiguration config, LoadBalanceFactorProvider loadBalanceFactorProvider) protected
ModClusterService
(NodeConfiguration nodeConfig, BalancerConfiguration balancerConfig, MCMPHandlerConfiguration mcmpConfig, AdvertiseConfiguration advertiseConfig, LoadBalanceFactorProviderFactory loadBalanceFactorProviderFactory, MCMPRequestFactory requestFactory, MCMPResponseParser responseParser, ResetRequestSource resetRequestSource, MCMPHandler mcmpHandler, AdvertiseListenerFactory listenerFactory) -
Method Summary
Modifier and TypeMethodDescriptionvoid
Indicates the deployment of a new web application which is not intending to start immediately.void
Add a proxy to the list of those with which this handler communicates.protected void
Configures the specified engine.void
connectionEstablished
(InetAddress localAddress) boolean
disable()
Disable all webapps for all engines.boolean
disableContext
(String host, String path) Disables the webapp with the specified host and context path.boolean
enable()
Enable all webapps for all engines.boolean
enableContext
(String host, String path) Enables the webapp with the specified host and context path.protected void
establishJvmRoute
(Engine engine) getExcludedContexts
(Host host) Returns the contexts that will *not* be registered in any proxy for the given host.int
getLoadBalanceFactor
(Engine engine) Retrieves the full proxy configuration.Retrieves the full proxy info message.void
Triggers the initialization of mod_cluster.boolean
Indicates when contexts should auto-enable by default.boolean
ping()
Ping httpd.Ping a node from httpd.Ping a node defined protocol, host and port from httpd.void
refresh()
Refresh configuration.void
Indicates the undeployment of the specified context.protected void
Sends REMOVE-APP *, if engine was initializedvoid
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
shutdown()
Triggers the shutdown of mod_cluster.void
Indicates the specified web application context was started.void
Indicates the servlet container has been started.void
This is a periodic event that triggers a STATUS command containing newly calculated load factor.boolean
Attempts to gracefully stops all web applications, within the specified timeout.void
Indicates the specified web application context was stopped.void
Indicates the servlet container has been stopped.boolean
stopContext
(String host, String path, long timeout, TimeUnit unit) Attempts to gracefully stops a single web application, within the specified timeout.
-
Field Details
-
DEFAULT_PORT
public static final int DEFAULT_PORT- See Also:
-
-
Constructor Details
-
ModClusterService
public ModClusterService(ModClusterConfiguration config, LoadBalanceFactorProvider loadBalanceFactorProvider) -
ModClusterService
public ModClusterService(ModClusterConfig config, LoadBalanceFactorProvider loadBalanceFactorProvider) -
ModClusterService
public ModClusterService(ModClusterConfig config, LoadBalanceFactorProviderFactory loadBalanceFactorProviderFactory) -
ModClusterService
protected ModClusterService(NodeConfiguration nodeConfig, BalancerConfiguration balancerConfig, MCMPHandlerConfiguration mcmpConfig, AdvertiseConfiguration advertiseConfig, LoadBalanceFactorProviderFactory loadBalanceFactorProviderFactory, MCMPRequestFactory requestFactory, MCMPResponseParser responseParser, ResetRequestSource resetRequestSource, MCMPHandler mcmpHandler, AdvertiseListenerFactory listenerFactory)
-
-
Method Details
-
init
Description copied from interface:ContainerEventHandler
Triggers the initialization of mod_cluster. This event should be triggered only once, after the startup of the servlet container, but before triggering theContainerEventHandler.start(Server)
event.- Specified by:
init
in interfaceContainerEventHandler
- Parameters:
server
- a server
-
getExcludedContexts
Description copied from interface:ContextFilter
Returns the contexts that will *not* be registered in any proxy for the given host.- Specified by:
getExcludedContexts
in interfaceContextFilter
- Returns:
- a set of context paths excluded for the given host
-
isAutoEnableContexts
public boolean isAutoEnableContexts()Description copied from interface:ContextFilter
Indicates when contexts should auto-enable by default. If auto-enable is off, then contexts are disabled by default and must be enabled manually.- Specified by:
isAutoEnableContexts
in interfaceContextFilter
- Returns:
- true, contexts should be auto-enabled, false otherwise.
-
shutdown
public void shutdown()Description copied from interface:ContainerEventHandler
Triggers the shutdown of mod_cluster. Closes any resources created inContainerEventHandler.init(Server)
.- Specified by:
shutdown
in interfaceContainerEventHandler
-
start
Description copied from interface:ContainerEventHandler
Indicates the servlet container has been started. This event triggers the configuration of each servlet engine, and the addition of all web application contexts.- Specified by:
start
in interfaceContainerEventHandler
- Parameters:
server
- the started server
-
stop
Description copied from interface:ContainerEventHandler
Indicates the servlet container has been stopped. This event triggers the removal of all web application contexts, and REMOVE-APP * of each engine.- Specified by:
stop
in interfaceContainerEventHandler
- Parameters:
server
- the stopped server
-
config
Configures the specified engine. Sends CONFIG request. -
isEstablished
public boolean isEstablished()- Specified by:
isEstablished
in interfaceMCMPConnectionListener
-
connectionEstablished
- Specified by:
connectionEstablished
in interfaceMCMPConnectionListener
-
establishJvmRoute
-
add
Description copied from interface:ContainerEventHandler
Indicates the deployment of a new web application which is not intending to start immediately. This will issue a STOP-APP without session draining command on the proxies. In case the application will start useContainerEventHandler.start(Context)
.- Specified by:
add
in interfaceContainerEventHandler
- Parameters:
context
- the added context
-
start
Description copied from interface:ContainerEventHandler
Indicates the specified web application context was started. This event triggers an ENABLE-APP command for the specified context.- Specified by:
start
in interfaceContainerEventHandler
- Parameters:
context
- the started context
-
stop
Description copied from interface:ContainerEventHandler
Indicates the specified web application context was stopped. This event triggers a STOP-APP command for the context started byContainerEventHandler.start(Context)
.- Specified by:
stop
in interfaceContainerEventHandler
- Parameters:
context
- the stopped context
-
remove
Description copied from interface:ContainerEventHandler
Indicates the undeployment of the specified context. This event triggers a REMOVE-APP command for the specified context.- Specified by:
remove
in interfaceContainerEventHandler
- Parameters:
context
- the removed context
-
removeAll
Sends REMOVE-APP *, if engine was initialized -
status
Description copied from interface:ContainerEventHandler
This is a periodic event that triggers a STATUS command containing newly calculated load factor. This event also processing of newly added/discovered proxies, and reset of any proxies in error.- Specified by:
status
in interfaceContainerEventHandler
- Parameters:
engine
- the engine to be processed
-
getLoadBalanceFactor
- Specified by:
getLoadBalanceFactor
in interfaceLoadBalanceFactorProvider
-
addProxy
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
-
removeProxy
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
-
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
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
-
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
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
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
-
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
-
refresh
public void refresh()Description copied from interface:ModClusterServiceMBean
Refresh configuration.- Specified by:
refresh
in interfaceModClusterServiceMBean
-
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
-
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
-
disableContext
Description copied from interface:ModClusterServiceMBean
Disables the webapp with the specified host and context path.- Specified by:
disableContext
in interfaceModClusterServiceMBean
- Parameters:
host
- host name of the target webapppath
- context path of the target webapp- Returns:
- true, if all proxies are responding normally, false otherwise
-
enableContext
Description copied from interface:ModClusterServiceMBean
Enables the webapp with the specified host and context path.- Specified by:
enableContext
in interfaceModClusterServiceMBean
- Parameters:
host
- host name of the target webapppath
- context path of the target webapp- Returns:
- true, if all proxies are responding normally, false otherwise
-
stop
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
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.
-