Class ModClusterService

java.lang.Object
org.jboss.modcluster.ModClusterService
All Implemented Interfaces:
ContainerEventHandler, LoadBalanceFactorProvider, ContextFilter, MCMPConnectionListener, ModClusterServiceMBean

  • Field Details

  • Constructor Details

  • Method Details

    • 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 the ContainerEventHandler.start(Server) event.
      Specified by:
      init in interface ContainerEventHandler
      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 interface ContextFilter
      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 interface ContextFilter
      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 in ContainerEventHandler.init(Server).
      Specified by:
      shutdown in interface ContainerEventHandler
    • 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 interface ContainerEventHandler
      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 interface ContainerEventHandler
      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 interface MCMPConnectionListener
    • connectionEstablished

      public void connectionEstablished(InetAddress localAddress)
      Specified by:
      connectionEstablished in interface MCMPConnectionListener
    • 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 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 use ContainerEventHandler.start(Context).
      Specified by:
      add in interface ContainerEventHandler
      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 interface ContainerEventHandler
      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 by ContainerEventHandler.start(Context).
      Specified by:
      stop in interface ContainerEventHandler
      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 interface ContainerEventHandler
      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 interface ContainerEventHandler
      Parameters:
      engine - the engine to be processed
    • getLoadBalanceFactor

      public int getLoadBalanceFactor(Engine engine)
      Specified by:
      getLoadBalanceFactor in interface LoadBalanceFactorProvider
    • 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 to MCMPHandler.status().
      Specified by:
      addProxy in interface ModClusterServiceMBean
      Parameters:
      host - the hostname of the proxy; a string suitable for passing to InetAddress.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 to MCMPHandler.status().
      Specified by:
      removeProxy in interface ModClusterServiceMBean
      Parameters:
      host - the hostname of the proxy; a string suitable for passing to InetAddress.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 a DUMP request to all proxies, returning the responses grouped by proxy address.
      Specified by:
      getProxyConfiguration in interface ModClusterServiceMBean
      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 an INFO request to all proxies, returning the responses grouped by proxy address.
      Specified by:
      getProxyInfo in interface ModClusterServiceMBean
      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 interface ModClusterServiceMBean
      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 interface ModClusterServiceMBean
      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 interface ModClusterServiceMBean
      Parameters:
      scheme - ajp, http or https
      host - 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 interface ModClusterServiceMBean
    • refresh

      public void refresh()
      Description copied from interface: ModClusterServiceMBean
      Refresh configuration.
      Specified by:
      refresh in interface ModClusterServiceMBean
    • disable

      public boolean disable()
      Description copied from interface: ModClusterServiceMBean
      Disable all webapps for all engines.
      Specified by:
      disable in interface ModClusterServiceMBean
      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 interface ModClusterServiceMBean
      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 interface ModClusterServiceMBean
      Parameters:
      host - host name of the target webapp
      path - 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 interface ModClusterServiceMBean
      Parameters:
      host - host name of the target webapp
      path - 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.
      1. Disables all contexts
      2. Waits for all sessions to drain
      3. Stops all contexts
      Specified by:
      stop in interface ModClusterServiceMBean
      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.
      1. Disables the specified context
      2. Waits for all sessions for the specified context to drain
      3. Stops the specified context
      Specified by:
      stopContext in interface ModClusterServiceMBean
      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.