Class ConnectionPoolMetrics
java.lang.Object
com.loomcache.client.ConnectionPoolMetrics
Connection pool performance and health metrics.
Tracks and exposes statistics for connection pools including active/idle counts, lifetime connection creation/destruction, wait times, and connection errors. All metrics are thread-safe using AtomicLong and LongAdder.
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic final recordImmutable snapshot of connection pool metrics at a point in time. -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoidDecrement the count of threads currently waiting for a connection.longGet the current number of active connections.doubleGet the average wait time for acquiring a connection in milliseconds.longGet the total number of connection creation errors.longGet the current number of threads waiting for a connection.longGet the current number of idle connections.Return a snapshot of all metrics.longGet the total number of connections created.longGet the total number of connections destroyed.longGet the total number of times threads waited for a connection.longGet the total cumulative wait time in milliseconds.voidIncrement the count of threads currently waiting for a connection.voidRecord a new connection creation.voidRecord a connection destruction.voidRecord a connection creation error.voidrecordWaitTime(long waitTimeMs) Record the time spent waiting for a connection in milliseconds.voidsetActiveConnections(long count) Set the number of currently active (in-use) connections.voidsetIdleConnections(long count) Set the number of currently idle (available) connections.
-
Constructor Details
-
ConnectionPoolMetrics
public ConnectionPoolMetrics()
-
-
Method Details
-
setActiveConnections
public void setActiveConnections(long count) Set the number of currently active (in-use) connections. Thread-safe operation using atomic operations.- Parameters:
count- the number of active connections (must be non-negative)
-
setIdleConnections
public void setIdleConnections(long count) Set the number of currently idle (available) connections. Thread-safe operation using atomic operations.- Parameters:
count- the number of idle connections (must be non-negative)
-
recordConnectionCreated
public void recordConnectionCreated()Record a new connection creation. Thread-safe operation using LongAdder for high-performance counting. -
recordConnectionDestroyed
public void recordConnectionDestroyed()Record a connection destruction. Thread-safe operation using LongAdder for high-performance counting. -
incrementWaitCount
public void incrementWaitCount()Increment the count of threads currently waiting for a connection. Thread-safe operation using atomic operations and LongAdder. -
decrementWaitCount
public void decrementWaitCount()Decrement the count of threads currently waiting for a connection. Thread-safe operation using atomic operations. -
recordWaitTime
public void recordWaitTime(long waitTimeMs) Record the time spent waiting for a connection in milliseconds. Thread-safe operation using LongAdder for high-performance counting.- Parameters:
waitTimeMs- the wait time in milliseconds (must be non-negative)
-
recordConnectionError
public void recordConnectionError()Record a connection creation error. Thread-safe operation using LongAdder for high-performance counting. -
getActiveConnections
public long getActiveConnections()Get the current number of active connections. -
getIdleConnections
public long getIdleConnections()Get the current number of idle connections. -
getTotalCreated
public long getTotalCreated()Get the total number of connections created. -
getTotalDestroyed
public long getTotalDestroyed()Get the total number of connections destroyed. -
getCurrentWaitCount
public long getCurrentWaitCount()Get the current number of threads waiting for a connection. -
getAverageWaitTime
public double getAverageWaitTime()Get the average wait time for acquiring a connection in milliseconds. -
getConnectionErrors
public long getConnectionErrors()Get the total number of connection creation errors. -
getTotalWaitCount
public long getTotalWaitCount()Get the total number of times threads waited for a connection. -
getTotalWaitTime
public long getTotalWaitTime()Get the total cumulative wait time in milliseconds. -
getMetrics
Return a snapshot of all metrics.
-