Class ConnectionPoolMetrics

java.lang.Object
com.loomcache.client.ConnectionPoolMetrics

public class ConnectionPoolMetrics extends Object
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.

  • 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.