Class AbandonedTrace
java.lang.Object
org.datanucleus.store.rdbms.datasource.dbcp2.AbandonedTrace
- All Implemented Interfaces:
TrackedUse
- Direct Known Subclasses:
DelegatingConnection
,DelegatingResultSet
,DelegatingStatement
Tracks db connection usage for recovering and reporting abandoned db connections.
The JDBC Connection, Statement, and ResultSet classes extend this class.
- Since:
- 2.0
-
Field Summary
FieldsModifier and TypeFieldDescriptionprivate long
Last time this connection was used.private final List
<WeakReference<AbandonedTrace>> A list of objects created by children of this object. -
Constructor Summary
ConstructorsConstructorDescriptionCreates a new AbandonedTrace without config and without doing abandoned tracing.AbandonedTrace
(AbandonedTrace parent) Constructs a new AbandonedTrace with a parent object. -
Method Summary
Modifier and TypeMethodDescriptionprotected void
addTrace
(AbandonedTrace trace) Adds an object to the list of objects being traced.protected void
Clears the list of objects being traced by this object.long
Gets the last time this object was used in milliseconds.protected List
<AbandonedTrace> getTrace()
Gets a list of objects being traced by this object.private void
init
(AbandonedTrace parent) Initializes abandoned tracing for this object.protected void
removeThisTrace
(Object source) Removes this object the source object is tracing.protected void
removeTrace
(AbandonedTrace trace) Removes a child object this object is tracing.protected void
Sets the time this object was last used to the current time in milliseconds.protected void
setLastUsed
(long lastUsedMillis) Sets the time in milliseconds this object was last used.
-
Field Details
-
traceList
A list of objects created by children of this object. -
lastUsedMillis
private volatile long lastUsedMillisLast time this connection was used.
-
-
Constructor Details
-
AbandonedTrace
public AbandonedTrace()Creates a new AbandonedTrace without config and without doing abandoned tracing. -
AbandonedTrace
Constructs a new AbandonedTrace with a parent object.- Parameters:
parent
- AbandonedTrace parent object.
-
-
Method Details
-
init
Initializes abandoned tracing for this object.- Parameters:
parent
- AbandonedTrace parent object.
-
getLastUsed
public long getLastUsed()Gets the last time this object was used in milliseconds.- Specified by:
getLastUsed
in interfaceTrackedUse
- Returns:
- long time in milliseconds.
-
setLastUsed
protected void setLastUsed()Sets the time this object was last used to the current time in milliseconds. -
setLastUsed
protected void setLastUsed(long lastUsedMillis) Sets the time in milliseconds this object was last used.- Parameters:
lastUsedMillis
- time in milliseconds.
-
addTrace
Adds an object to the list of objects being traced.- Parameters:
trace
- AbandonedTrace object to add.
-
clearTrace
protected void clearTrace()Clears the list of objects being traced by this object. -
getTrace
Gets a list of objects being traced by this object.- Returns:
- List of objects.
-
removeTrace
Removes a child object this object is tracing.- Parameters:
trace
- AbandonedTrace object to remove.
-
removeThisTrace
Removes this object the source object is tracing.- Parameters:
source
- The object tracing- Since:
- 2.7.0
-