Top Description Fields Constructors Methods
org.apache.commons.pool2.impl

public Class AbandonedConfig

extends Object
Class Inheritance
Imports
java.io.OutputStreamWriter, .PrintWriter, java.nio.charset.Charset, java.time.Duration, org.apache.commons.pool2.TrackedUse, .UsageTracking

Configuration settings for abandoned object removal.
Since
2.0

Field Summary

Modifier and TypeField and Description
private static final Duration
private boolean
logAbandoned

Determines whether or not to log stack traces for application code which abandoned an object.

private PrintWriter
logWriter

PrintWriter to use to log information on abandoned objects.

private boolean
removeAbandonedOnBorrow

Whether or not borrowObject performs abandoned object removal.

private boolean
removeAbandonedOnMaintenance

Whether or not pool maintenance (evictor) performs abandoned object removal.

private Duration
removeAbandonedTimeoutDuration

Timeout before an abandoned object can be removed.

private boolean
requireFullStackTrace

Determines whether or not to log full stack traces when logAbandoned is true.

private boolean
useUsageTracking

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?

Constructor Summary

AccessConstructor and Description
public
AbandonedConfig()

Creates a new instance.

private
AbandonedConfig(final AbandonedConfig
the source.
abandonedConfig
)

Creates a new instance with values from the given instance.

Method Summary

Modifier and TypeMethod and Description
public static AbandonedConfig

Returns:

A new instance or null if the input is null.
copy
(final AbandonedConfig
the source, may be null.
abandonedConfig
)

Creates a new instance with values from the given instance.

public boolean

Returns:

boolean true if stack trace logging is turned on for abandoned objects
getLogAbandoned
()

Flag to log stack traces for application code which abandoned an object.

public PrintWriter

Returns:

log writer in use
getLogWriter
()

Gets the log writer being used by this configuration to log information on abandoned objects.

public boolean

Returns:

true if abandoned objects are to be removed by borrowObject
getRemoveAbandonedOnBorrow
()

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

public boolean

Returns:

true if abandoned objects are to be removed by the evictor
getRemoveAbandonedOnMaintenance
()

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

public int

Returns:

the abandoned object timeout in seconds.
getRemoveAbandonedTimeout
()

Timeout in seconds before an abandoned object can be removed.

public Duration

Returns:

the abandoned object timeout.
getRemoveAbandonedTimeoutDuration
()

Timeout before an abandoned object can be removed.

public boolean

Returns:

true if full stack traces are required for logging abandoned connections, or false if abbreviated stack traces are acceptable
getRequireFullStackTrace
()

Indicates if full stack traces are required when logAbandoned is true.

public boolean

Returns:

true if usage tracking is enabled
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?

public void
setLogAbandoned(final boolean
true turns on abandoned stack trace logging
logAbandoned
)

Sets the flag to log stack traces for application code which abandoned an object.

public void
setLogWriter(final PrintWriter
The new log writer
logWriter
)

Sets the log writer to be used by this configuration to log information on abandoned objects.

public void
setRemoveAbandonedOnBorrow(final boolean
true means abandoned objects will be removed by borrowObject
removeAbandonedOnBorrow
)

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

public void
setRemoveAbandonedOnMaintenance(final boolean
true means abandoned objects will be removed by pool maintenance
removeAbandonedOnMaintenance
)

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

public void
setRemoveAbandonedTimeout(final Duration
new abandoned timeout
removeAbandonedTimeout
)

Sets the timeout before an abandoned object can be removed.

public void
setRemoveAbandonedTimeout(final int
new abandoned timeout in seconds
removeAbandonedTimeoutSeconds
)

Sets the timeout in seconds before an abandoned object can be removed.
public void
setRequireFullStackTrace(final boolean
indicates whether or not full stack traces are required in abandoned connection logs
requireFullStackTrace
)

Sets the flag to require full stack traces for logging abandoned connections when enabled.

public void
setUseUsageTracking(final boolean
A value of true will enable the recording of a stack trace on every use of a pooled object
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.

public String
toString()

Overrides java.lang.Object.toString.

Returns a string representation of the object.
Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAllwaitwaitwait

Field Detail

DEFAULT_REMOVE_ABANDONED_TIMEOUT_DURATIONback to summary
private static final Duration DEFAULT_REMOVE_ABANDONED_TIMEOUT_DURATION

The 5 minutes Duration.

logAbandonedback to summary
private boolean logAbandoned

Determines whether or not to log stack traces for application code which abandoned an object.

logWriterback to summary
private PrintWriter logWriter

PrintWriter to use to log information on abandoned objects. Use of default system encoding is deliberate.

removeAbandonedOnBorrowback to summary
private boolean removeAbandonedOnBorrow

Whether or not borrowObject performs abandoned object removal.

removeAbandonedOnMaintenanceback to summary
private boolean removeAbandonedOnMaintenance

Whether or not pool maintenance (evictor) performs abandoned object removal.

removeAbandonedTimeoutDurationback to summary
private Duration removeAbandonedTimeoutDuration

Timeout before an abandoned object can be removed.

requireFullStackTraceback to summary
private boolean requireFullStackTrace

Determines whether or not to log full stack traces when logAbandoned is true. If disabled, then a faster method for logging stack traces with only class data may be used if possible.

Since
2.5
useUsageTrackingback to summary
private boolean useUsageTracking

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?

Constructor Detail

AbandonedConfigback to summary
public AbandonedConfig()

Creates a new instance.

AbandonedConfigback to summary
private AbandonedConfig(final AbandonedConfig abandonedConfig)

Creates a new instance with values from the given instance.

Parameters
abandonedConfig:AbandonedConfig

the source.

Annotations
@SuppressWarnings:resource

Method Detail

copyback to summary
public static AbandonedConfig copy(final AbandonedConfig abandonedConfig)

Creates a new instance with values from the given instance.

Parameters
abandonedConfig:AbandonedConfig

the source, may be null.

Returns:AbandonedConfig

A new instance or null if the input is null.

Since
2.11.0
getLogAbandonedback to summary
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

boolean true if stack trace logging is turned on for abandoned objects

getLogWriterback to summary
public PrintWriter getLogWriter()

Gets 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:PrintWriter

log writer in use

getRemoveAbandonedOnBorrowback to summary
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:boolean

true if abandoned objects are to be removed by borrowObject

getRemoveAbandonedOnMaintenanceback to summary
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 GenericObjectPool#getTimeBetweenEvictionRunsMillis() to a positive number.

Returns:boolean

true if abandoned objects are to be removed by the evictor

getRemoveAbandonedTimeoutback to summary
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#getLastUsedInstant() (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:int

the abandoned object timeout in seconds.

Annotations
@Deprecated
getRemoveAbandonedTimeoutDurationback to summary
public Duration getRemoveAbandonedTimeoutDuration()

Timeout before an abandoned object can be removed.

The time of most recent use of an object is the maximum (latest) of TrackedUse#getLastUsedInstant() (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:Duration

the abandoned object timeout.

Since
2.10.0
getRequireFullStackTraceback to summary
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:boolean

true if full stack traces are required for logging abandoned connections, or false if abbreviated stack traces are acceptable

Since
2.5
See Also
CallStack
getUseUsageTrackingback to summary
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:boolean

true if usage tracking is enabled

setLogAbandonedback to summary
public void setLogAbandoned(final boolean logAbandoned)

Sets the flag to log stack traces for application code which abandoned an object.

Parameters
logAbandoned:boolean

true turns on abandoned stack trace logging

See Also
getLogAbandoned()
setLogWriterback to summary
public void setLogWriter(final PrintWriter logWriter)

Sets the log writer to be used by this configuration to log information on abandoned objects.

Parameters
logWriter:PrintWriter

The new log writer

setRemoveAbandonedOnBorrowback to summary
public void setRemoveAbandonedOnBorrow(final boolean removeAbandonedOnBorrow)

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

Parameters
removeAbandonedOnBorrow:boolean

true means abandoned objects will be removed by borrowObject

See Also
getRemoveAbandonedOnBorrow()
setRemoveAbandonedOnMaintenanceback to summary
public void setRemoveAbandonedOnMaintenance(final boolean removeAbandonedOnMaintenance)

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

Parameters
removeAbandonedOnMaintenance:boolean

true means abandoned objects will be removed by pool maintenance

See Also
getRemoveAbandonedOnMaintenance
setRemoveAbandonedTimeoutback to summary
public void setRemoveAbandonedTimeout(final Duration removeAbandonedTimeout)

Sets the timeout before an abandoned object can be removed.

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

Parameters
removeAbandonedTimeout:Duration

new abandoned timeout

Since
2.10.0
See Also
getRemoveAbandonedTimeoutDuration()
setRemoveAbandonedTimeoutback to summary
public void setRemoveAbandonedTimeout(final int removeAbandonedTimeoutSeconds)

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
removeAbandonedTimeoutSeconds:int

new abandoned timeout in seconds

Annotations
@Deprecated
See Also
getRemoveAbandonedTimeoutDuration()
setRequireFullStackTraceback to summary
public void setRequireFullStackTrace(final boolean requireFullStackTrace)

Sets the flag to require full stack traces for logging abandoned connections when enabled.

Parameters
requireFullStackTrace:boolean

indicates whether or not full stack traces are required in abandoned connection logs

Since
2.5
See Also
CallStack, getRequireFullStackTrace()
setUseUsageTrackingback to summary
public void setUseUsageTracking(final 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:boolean

A value of true will enable the recording of a stack trace on every use of a pooled object

toStringback to summary
public String toString()

Overrides java.lang.Object.toString.

Doc from java.lang.Object.toString.

Returns a string representation of the object.

Returns:String

a string representation of the object.

Annotations
@Override
Since
2.4.3