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
Fields Modifier and Type Field Description static int
DEFAULT_PORT
-
Constructor Summary
Constructors Modifier Constructor Description ModClusterService(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
All Methods Instance Methods Concrete Methods Modifier and Type Method Description void
add(Context context)
Indicates the deployment of a new web application.void
addProxy(String host, int port)
Add a proxy to the list of those with which this handler communicates.protected void
config(Engine engine)
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)
Set<String>
getExcludedContexts(Host host)
Returns the contexts that will *not* be registered in any proxy for the given host.int
getLoadBalanceFactor(Engine engine)
Map<InetSocketAddress,String>
getProxyConfiguration()
Retrieves the full proxy configuration.Map<InetSocketAddress,String>
getProxyInfo()
Retrieves the full proxy info message.void
init(Server server)
Triggers the initialization of mod_cluster.boolean
isAutoEnableContexts()
Indicates when contexts should auto-enable by default.boolean
isEstablished()
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
remove(Context context)
Indicates the undeployment of the specified context.protected void
removeAll(Engine engine)
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
start(Context context)
Indicates the specified web application context was started.void
start(Server server)
Indicates the servlet container has been started.void
status(Engine engine)
This is a periodic event that triggers a STATUS command containing newly calculated load factor.boolean
stop(long timeout, TimeUnit unit)
Attempts to gracefully stops all web applications, within the specified timeout.void
stop(Context context)
Indicates the specified web application context was stopped.void
stop(Server server)
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 Detail
-
DEFAULT_PORT
public static final int DEFAULT_PORT
- See Also:
- Constant Field Values
-
-
Constructor Detail
-
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 Detail
-
init
public void init(Server server)
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
public Set<String> getExcludedContexts(Host host)
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
public void start(Server server)
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
public void stop(Server server)
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
protected void config(Engine engine)
Configures the specified engine. Sends CONFIG request.
-
isEstablished
public boolean isEstablished()
- Specified by:
isEstablished
in interfaceMCMPConnectionListener
-
connectionEstablished
public void connectionEstablished(InetAddress localAddress)
- Specified by:
connectionEstablished
in interfaceMCMPConnectionListener
-
establishJvmRoute
protected void establishJvmRoute(Engine engine)
-
add
public void add(Context context)
Description copied from interface:ContainerEventHandler
Indicates the deployment of a new web application. This event triggers a ENABLE-APP command for this context, if it is already started.- Specified by:
add
in interfaceContainerEventHandler
- Parameters:
context
- the added context
-
start
public void start(Context context)
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
public void stop(Context context)
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
public void remove(Context context)
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
protected void removeAll(Engine engine)
Sends REMOVE-APP *, if engine was initialized
-
status
public void status(Engine engine)
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
public int getLoadBalanceFactor(Engine engine)
- Specified by:
getLoadBalanceFactor
in interfaceLoadBalanceFactorProvider
-
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
-
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
-
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
-
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
-
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
public boolean disableContext(String host, String path)
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
public boolean enableContext(String host, String path)
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
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.
-
-