Class AbandonedConfig

java.lang.Object
org.apache.tomcat.dbcp.pool2.impl.AbandonedConfig

public class AbandonedConfig extends Object
Configuration settings for abandoned object removal.
Since:
2.0
  • Constructor Summary

    Constructors
    Constructor
    Description
     
  • Method Summary

    Modifier and Type
    Method
    Description
    boolean
    Flag to log stack traces for application code which abandoned an object.
    Returns the log writer being used by this configuration to log information on abandoned objects.
    boolean
    Flag to remove abandoned objects if they exceed the removeAbandonedTimeout when borrowObject is invoked.
    boolean
    Flag to remove abandoned objects if they exceed the removeAbandonedTimeout when pool maintenance (the "evictor") runs.
    int
    Timeout in seconds before an abandoned object can be removed.
    boolean
    Indicates if full stack traces are required when logAbandoned is true.
    boolean
    If the pool implements UsageTracking, should the pool record a stack trace every time a method is called on a pooled object and retain the most recent stack trace to aid debugging of abandoned objects?
    void
    setLogAbandoned(boolean logAbandoned)
    Sets the flag to log stack traces for application code which abandoned an object.
    void
    Sets the log writer to be used by this configuration to log information on abandoned objects.
    void
    setRemoveAbandonedOnBorrow(boolean removeAbandonedOnBorrow)
    Flag to remove abandoned objects if they exceed the removeAbandonedTimeout when borrowObject is invoked.
    void
    setRemoveAbandonedOnMaintenance(boolean removeAbandonedOnMaintenance)
    Flag to remove abandoned objects if they exceed the removeAbandonedTimeout when pool maintenance runs.
    void
    setRemoveAbandonedTimeout(int removeAbandonedTimeout)
    Sets the timeout in seconds before an abandoned object can be removed
    void
    setRequireFullStackTrace(boolean requireFullStackTrace)
    Sets the flag to require full stack traces for logging abandoned connections when enabled.
    void
    setUseUsageTracking(boolean useUsageTracking)
    If the pool implements UsageTracking, configure whether the pool should record a stack trace every time a method is called on a pooled object and retain the most recent stack trace to aid debugging of abandoned objects.
     

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
  • Constructor Details

    • AbandonedConfig

      public AbandonedConfig()
  • Method Details

    • getRemoveAbandonedOnBorrow

      public boolean getRemoveAbandonedOnBorrow()

      Flag to remove abandoned objects if they exceed the removeAbandonedTimeout when borrowObject is invoked.

      The default value is false.

      If set to true, abandoned objects are removed by borrowObject if there are fewer than 2 idle objects available in the pool and getNumActive() > getMaxTotal() - 3

      Returns:
      true if abandoned objects are to be removed by borrowObject
    • setRemoveAbandonedOnBorrow

      public void setRemoveAbandonedOnBorrow(boolean removeAbandonedOnBorrow)

      Flag to remove abandoned objects if they exceed the removeAbandonedTimeout when borrowObject is invoked.

      Parameters:
      removeAbandonedOnBorrow - true means abandoned objects will be removed by borrowObject
      See Also:
    • getRemoveAbandonedOnMaintenance

      public boolean getRemoveAbandonedOnMaintenance()

      Flag to remove abandoned objects if they exceed the removeAbandonedTimeout when pool maintenance (the "evictor") runs.

      The default value is false.

      If set to true, abandoned objects are removed by the pool maintenance thread when it runs. This setting has no effect unless maintenance is enabled by setting timeBetweenEvictionRunsMillis to a positive number.

      Returns:
      true if abandoned objects are to be removed by the evictor
    • setRemoveAbandonedOnMaintenance

      public void setRemoveAbandonedOnMaintenance(boolean removeAbandonedOnMaintenance)

      Flag to remove abandoned objects if they exceed the removeAbandonedTimeout when pool maintenance runs.

      Parameters:
      removeAbandonedOnMaintenance - true means abandoned objects will be removed by pool maintenance
      See Also:
    • getRemoveAbandonedTimeout

      public int getRemoveAbandonedTimeout()

      Timeout in seconds before an abandoned object can be removed.

      The time of most recent use of an object is the maximum (latest) of TrackedUse.getLastUsed() (if this class of the object implements TrackedUse) and the time when the object was borrowed from the pool.

      The default value is 300 seconds.

      Returns:
      the abandoned object timeout in seconds
    • setRemoveAbandonedTimeout

      public void setRemoveAbandonedTimeout(int removeAbandonedTimeout)

      Sets the timeout in seconds before an abandoned object can be removed

      Setting this property has no effect if removeAbandonedOnBorrow and removeAbandonedOnMaintenance are both false.

      Parameters:
      removeAbandonedTimeout - new abandoned timeout in seconds
      See Also:
    • getLogAbandoned

      public boolean getLogAbandoned()
      Flag to log stack traces for application code which abandoned an object. Defaults to false. Logging of abandoned objects adds overhead for every object created because a stack trace has to be generated.
      Returns:
      boolean true if stack trace logging is turned on for abandoned objects
    • setLogAbandoned

      public void setLogAbandoned(boolean logAbandoned)
      Sets the flag to log stack traces for application code which abandoned an object.
      Parameters:
      logAbandoned - true turns on abandoned stack trace logging
      See Also:
    • getRequireFullStackTrace

      public boolean getRequireFullStackTrace()
      Indicates if full stack traces are required when logAbandoned is true. Defaults to true. Logging of abandoned objects requiring a full stack trace will generate an entire stack trace to generate for every object created. If this is disabled, a faster but less informative stack walking mechanism may be used if available.
      Returns:
      true if full stack traces are required for logging abandoned connections, or false if abbreviated stack traces are acceptable
      Since:
      2.5
      See Also:
    • setRequireFullStackTrace

      public void setRequireFullStackTrace(boolean requireFullStackTrace)
      Sets the flag to require full stack traces for logging abandoned connections when enabled.
      Parameters:
      requireFullStackTrace - indicates whether or not full stack traces are required in abandoned connection logs
      Since:
      2.5
      See Also:
    • getLogWriter

      public PrintWriter getLogWriter()
      Returns the log writer being used by this configuration to log information on abandoned objects. If not set, a PrintWriter based on System.out with the system default encoding is used.
      Returns:
      log writer in use
    • setLogWriter

      public void setLogWriter(PrintWriter logWriter)
      Sets the log writer to be used by this configuration to log information on abandoned objects.
      Parameters:
      logWriter - The new log writer
    • getUseUsageTracking

      public boolean getUseUsageTracking()
      If the pool implements UsageTracking, should the pool record a stack trace every time a method is called on a pooled object and retain the most recent stack trace to aid debugging of abandoned objects?
      Returns:
      true if usage tracking is enabled
    • setUseUsageTracking

      public void setUseUsageTracking(boolean useUsageTracking)
      If the pool implements UsageTracking, configure whether the pool should record a stack trace every time a method is called on a pooled object and retain the most recent stack trace to aid debugging of abandoned objects.
      Parameters:
      useUsageTracking - A value of true will enable the recording of a stack trace on every use of a pooled object
    • toString

      public String toString()
      Overrides:
      toString in class Object
      Since:
      2.4.3