Package com.oracle.bmc.http.internal
Class IdleConnectionMonitor
- java.lang.Object
-
- java.lang.Thread
-
- com.oracle.bmc.http.internal.IdleConnectionMonitor
-
-
Nested Class Summary
-
Nested classes/interfaces inherited from class java.lang.Thread
Thread.State, Thread.UncaughtExceptionHandler
-
-
Field Summary
-
Fields inherited from class java.lang.Thread
MAX_PRIORITY, MIN_PRIORITY, NORM_PRIORITY
-
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description protected static voidcleanStaleReferences()Remove stale references that have been garbage-collected already.voidcloseIdleConnections()Close idle connections.static IdleConnectionMonitorgetInstance()intgetWaitTimeInSeconds()protected static intidleConnectionMonitorThreadSize()static booleanregisterConnectionManager(org.apache.http.conn.HttpClientConnectionManager connectionManager, int waitTimeInSeconds, int idleTimeoutInSeconds)Registers the connection manager with the IdleConnectionMonitor thread;protected static voidregisterShutdownHook()Registers a shutdown hook with the Java Runtime to ensure that the IdleConnectionMonitor is properly shut down when the JVM exits.static booleanremoveConnectionManager(org.apache.http.conn.HttpClientConnectionManager connectionManager)Removes the connection manager from the IdleConnectionMonitor thread, and shuts down the thread if there is no connection manager left.voidrun()static booleanshutdown()Stops the execution of IdleConnectionMonitor thread by shutting down the thread and clears the connection managers in it.-
Methods inherited from class java.lang.Thread
activeCount, checkAccess, clone, countStackFrames, currentThread, dumpStack, enumerate, getAllStackTraces, getContextClassLoader, getDefaultUncaughtExceptionHandler, getId, getName, getPriority, getStackTrace, getState, getThreadGroup, getUncaughtExceptionHandler, holdsLock, interrupt, interrupted, isAlive, isDaemon, isInterrupted, join, join, join, onSpinWait, resume, setContextClassLoader, setDaemon, setDefaultUncaughtExceptionHandler, setName, setPriority, setUncaughtExceptionHandler, sleep, sleep, start, stop, suspend, toString, yield
-
-
-
-
Method Detail
-
registerConnectionManager
public static boolean registerConnectionManager(org.apache.http.conn.HttpClientConnectionManager connectionManager, int waitTimeInSeconds, int idleTimeoutInSeconds)Registers the connection manager with the IdleConnectionMonitor thread;- Parameters:
connectionManager- Connection manager to registerwaitTimeInSeconds- The maximum time interval after which the check and closing of expired/idle connections is performed; this may happen more oftenidleTimeoutInSeconds- The idle timeout - close connections that have been idle longer than idleTimeoutInSeconds seconds- Returns:
- true if the connection manager has been successfully registered; otherwise false.
-
removeConnectionManager
public static boolean removeConnectionManager(org.apache.http.conn.HttpClientConnectionManager connectionManager)
Removes the connection manager from the IdleConnectionMonitor thread, and shuts down the thread if there is no connection manager left.- Returns:
- true if the connection manager has been successfully removed; otherwise false.
-
closeIdleConnections
public void closeIdleConnections()
Close idle connections.As a side effect, updates the minimum wait time between checks.
-
registerShutdownHook
protected static void registerShutdownHook()
Registers a shutdown hook with the Java Runtime to ensure that the IdleConnectionMonitor is properly shut down when the JVM exits.The shutdown hook will invoke the
shutdown()method to stop the IdleConnectionMonitor thread and clear its connection managers.
-
cleanStaleReferences
protected static void cleanStaleReferences()
Remove stale references that have been garbage-collected already.
-
shutdown
public static boolean shutdown()
Stops the execution of IdleConnectionMonitor thread by shutting down the thread and clears the connection managers in it.- Returns:
- true if the shutdown process was initiated successfully, otherwise false.
-
idleConnectionMonitorThreadSize
protected static int idleConnectionMonitorThreadSize()
-
getWaitTimeInSeconds
public int getWaitTimeInSeconds()
-
getInstance
public static IdleConnectionMonitor getInstance()
-
-