StuckThreadDetectionValve (Apache Tomcat 7.0.104 API Documentation)

org.apache.catalina.valves

## Class StuckThreadDetectionValve

- java.lang.Object
- - org.apache.catalina.util.LifecycleBase
  - - org.apache.catalina.util.LifecycleMBeanBase
    - - org.apache.catalina.valves.ValveBase
      - - org.apache.catalina.valves.StuckThreadDetectionValve

- All Implemented Interfaces:
    MBeanRegistration, Contained, JmxEnabled, Lifecycle, Valve

      public class StuckThreadDetectionValve
      extends ValveBase

  This valve allows to detect requests that take a long time to process, which might indicate that the thread that is processing it is stuck.

- - ### Nested Class Summary

    - ### Nested classes/interfaces inherited from interface org.apache.catalina.Lifecycle

      `Lifecycle.SingleUse`

  - ### Field Summary

    - ### Fields inherited from class org.apache.catalina.valves.ValveBase

      `asyncSupported, container, containerLog, next`

    - ### Fields inherited from class org.apache.catalina.util.LifecycleMBeanBase

      `mserver`

    - ### Fields inherited from interface org.apache.catalina.Lifecycle

      `AFTER_DESTROY_EVENT, AFTER_INIT_EVENT, AFTER_START_EVENT, AFTER_STOP_EVENT, BEFORE_DESTROY_EVENT, BEFORE_INIT_EVENT, BEFORE_START_EVENT, BEFORE_STOP_EVENT, CONFIGURE_START_EVENT, CONFIGURE_STOP_EVENT, PERIODIC_EVENT, START_EVENT, STOP_EVENT`

  - ### Constructor Summary

    Constructors
    Constructor and Description
    `StuckThreadDetectionValve()` Required to enable async support.

  - ### Method Summary

    Methods
    Modifier and Type | Method and Description
    --- | ---
    `void` | `backgroundProcess()` Execute a periodic task, such as reloading, etc.
    `String` | `getInfo()` Return descriptive information about this Valve implementation.
    `long` | `getInterruptedThreadsCount()`
    `int` | `getInterruptThreadThreshold()`
    `int` | `getStuckThreadCount()`
    `long[]` | `getStuckThreadIds()`
    `String[]` | `getStuckThreadNames()`
    `int` | `getThreshold()`
    `protected void` | `initInternal()` Sub-classes wishing to perform additional initialization should override this method, ensuring that super.initInternal() is the first call in the overriding method.
    `void` | `invoke(Request request, Response response)` The implementation-specific logic represented by this Valve.
    `void` | `setInterruptThreadThreshold(int interruptThreadThreshold)` Specifies the threshold (in seconds) before stuck threads are interrupted.
    `void` | `setThreshold(int threshold)` Specifies the threshold (in seconds) used when checking for stuck threads.

    - ### Methods inherited from class org.apache.catalina.valves.ValveBase

      `event, getContainer, getDomainInternal, getNext, getObjectNameKeyProperties, isAsyncSupported, setAsyncSupported, setContainer, setNext, startInternal, stopInternal, toString`

    - ### Methods inherited from class org.apache.catalina.util.LifecycleMBeanBase

      `destroyInternal, getDomain, getObjectName, postDeregister, postRegister, preDeregister, preRegister, register, setDomain, unregister`

    - ### Methods inherited from class org.apache.catalina.util.LifecycleBase

      `addLifecycleListener, destroy, findLifecycleListeners, fireLifecycleEvent, getState, getStateName, getThrowOnFailure, init, removeLifecycleListener, setState, setState, setThrowOnFailure, start, stop`

    - ### Methods inherited from class java.lang.Object

      `clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait`

- - ### Constructor Detail

    - #### StuckThreadDetectionValve

          public StuckThreadDetectionValve()

      Required to enable async support.

  - ### Method Detail

    - #### setThreshold

          public void setThreshold(int threshold)

      Specifies the threshold (in seconds) used when checking for stuck threads. If <=0, the detection is disabled. The default is 600 seconds.
      Parameters:
        `threshold` - The new threshold in seconds

    - #### getThreshold

          public int getThreshold()

      Returns:
        The current threshold in seconds
      See Also:
        `setThreshold(int)`

    - #### getInterruptThreadThreshold

          public int getInterruptThreadThreshold()

    - #### setInterruptThreadThreshold

          public void setInterruptThreadThreshold(int interruptThreadThreshold)

      Specifies the threshold (in seconds) before stuck threads are interrupted. If <=0, the interruption is disabled. The default is -1. If >=0, the value must actually be >= threshold.
      Parameters:
        `interruptThreadThreshold` - The new thread interruption threshold in seconds

    - #### initInternal

          protected void initInternal()
                               throws LifecycleException

      Description copied from class: `LifecycleMBeanBase`
      Sub-classes wishing to perform additional initialization should override this method, ensuring that super.initInternal() is the first call in the overriding method.
      Overrides:
        `initInternal` in class `ValveBase`
      Throws:
        `LifecycleException` - If the initialisation fails

    - #### getInfo

          public String getInfo()

      Return descriptive information about this Valve implementation.
      Specified by:
        `getInfo` in interface `Valve`
      Overrides:
        `getInfo` in class `ValveBase`
      Returns:
        descriptive information about this Valve implementation.

    - #### invoke

          public void invoke(Request request,
                    Response response)
                      throws IOException,
                             ServletException

      The implementation-specific logic represented by this Valve. See the Valve description for the normal design patterns for this method.

      This method MUST be provided by a subclass.

      Specified by:
        `invoke` in interface `Valve`
      Specified by:
        `invoke` in class `ValveBase`
      Parameters:
        `request` - The servlet request to be processed
        `response` - The servlet response to be created
      Throws:
        `IOException` - if an input/output error occurs
        `ServletException` - if a servlet error occurs

    - #### backgroundProcess

          public void backgroundProcess()

      Description copied from class: `ValveBase`
      Execute a periodic task, such as reloading, etc. This method will be invoked inside the classloading context of this container. Unexpected throwables will be caught and logged.
      Specified by:
        `backgroundProcess` in interface `Valve`
      Overrides:
        `backgroundProcess` in class `ValveBase`

    - #### getStuckThreadCount

          public int getStuckThreadCount()

    - #### getStuckThreadIds

          public long[] getStuckThreadIds()

    - #### getStuckThreadNames

          public String[] getStuckThreadNames()

    - #### getInterruptedThreadsCount

          public long getInterruptedThreadsCount()

Copyright © 2000-2020 Apache Software Foundation. All Rights Reserved.