public class AbandonedConnectionCleanupThread
extends java.lang.Object
implements java.lang.Runnable
| Modifier and Type | Class and Description |
|---|---|
private static class |
AbandonedConnectionCleanupThread.ConnectionFinalizerPhantomReference
PhantomReference subclass to track MysqlConnection objects finalization. |
| Modifier and Type | Field and Description |
|---|---|
private static boolean |
abandonedConnectionCleanupDisabled |
private static java.util.concurrent.ExecutorService |
cleanupThreadExecutorService |
private static java.util.Set<AbandonedConnectionCleanupThread.ConnectionFinalizerPhantomReference> |
connectionFinalizerPhantomRefs |
private static java.lang.ref.ReferenceQueue<MysqlConnection> |
referenceQueue |
private static java.lang.Thread |
threadRef |
private static java.util.concurrent.locks.Lock |
threadRefLock |
| Modifier | Constructor and Description |
|---|---|
private |
AbandonedConnectionCleanupThread() |
| Modifier and Type | Method and Description |
|---|---|
static void |
checkedShutdown()
Performs a checked shutdown, i.e., the context ClassLoaders from this and the caller thread are checked for consistency prior to performing the shutdown
operation.
|
private void |
checkThreadContextClassLoader()
Checks if the thread's context ClassLoader is active.
|
private static boolean |
consistentClassLoaders()
Checks if the context ClassLoaders from this and the caller thread are the same.
|
private static void |
finalizeResource(AbandonedConnectionCleanupThread.ConnectionFinalizerPhantomReference reference)
Release resources from the given
AbandonedConnectionCleanupThread.ConnectionFinalizerPhantomReference and remove it from the references set. |
static boolean |
isAlive()
Returns true if the working thread is alive.
|
void |
run() |
private static void |
shutdown(boolean checked)
Shuts down this thread either checking or not the context ClassLoaders from the involved threads.
|
protected static void |
trackConnection(MysqlConnection conn,
NetworkResources io)
Tracks the finalization of a
MysqlConnection object and keeps a reference to its NetworkResources so that they can be later released. |
static void |
uncheckedShutdown()
Performs an unchecked shutdown, i.e., the shutdown is performed independently of the context ClassLoaders from the involved threads.
|
private static final java.util.Set<AbandonedConnectionCleanupThread.ConnectionFinalizerPhantomReference> connectionFinalizerPhantomRefs
private static final java.lang.ref.ReferenceQueue<MysqlConnection> referenceQueue
private static final java.util.concurrent.ExecutorService cleanupThreadExecutorService
private static java.lang.Thread threadRef
private static java.util.concurrent.locks.Lock threadRefLock
private static boolean abandonedConnectionCleanupDisabled
public void run()
run in interface java.lang.Runnableprivate void checkThreadContextClassLoader()
private static boolean consistentClassLoaders()
private static void shutdown(boolean checked)
checked - does a checked shutdown if true, unchecked otherwisepublic static void checkedShutdown()
public static void uncheckedShutdown()
public static boolean isAlive()
protected static void trackConnection(MysqlConnection conn, NetworkResources io)
MysqlConnection object and keeps a reference to its NetworkResources so that they can be later released.conn - the Connection object to track for finalizationio - the network resources to close on the connection finalizationprivate static void finalizeResource(AbandonedConnectionCleanupThread.ConnectionFinalizerPhantomReference reference)
AbandonedConnectionCleanupThread.ConnectionFinalizerPhantomReference and remove it from the references set.reference - the AbandonedConnectionCleanupThread.ConnectionFinalizerPhantomReference to finalize.