Record Class BufferPoolMetrics

java.lang.Object
java.lang.Record
express.mvp.myra.transport.buffer.BufferPoolMetrics
Record Components:
totalAcquisitions - total number of acquisition attempts (successful + failed)
successfulAcquisitions - number of acquisitions that succeeded
failedAcquisitions - number of acquisitions that timed out or failed
avgWaitTimeNanos - average wait time in nanoseconds for successful acquisitions
maxWaitTimeNanos - maximum wait time observed in nanoseconds
currentAvailable - number of buffers currently available in the pool
poolSize - total capacity of the pool

public record BufferPoolMetrics(long totalAcquisitions, long successfulAcquisitions, long failedAcquisitions, long avgWaitTimeNanos, long maxWaitTimeNanos, int currentAvailable, int poolSize) extends Record
Immutable snapshot of buffer pool performance metrics.

This record captures acquisition statistics and pool state at a point in time, useful for monitoring, debugging, and performance tuning.

Metric Categories

  • Acquisition counts: Track success/failure rates
  • Wait times: Measure contention and timeout behavior
  • Pool state: Current availability and capacity

Usage Example

TimedBufferPool pool = new TimedBufferPool(256, 65536);
// ... use pool ...

BufferPoolMetrics metrics = pool.metrics();
System.out.printf("Success rate: %.2f%%%n",
    100.0 * metrics.successfulAcquisitions() / metrics.totalAcquisitions());
System.out.printf("Avg wait: %.2f ms%n",
    metrics.avgWaitTimeNanos() / 1_000_000.0);

Thread Safety

This record is immutable and safe to share across threads. However, the metrics represent a snapshot and may be stale immediately after retrieval.

See Also:
  • Constructor Details

    • BufferPoolMetrics

      public BufferPoolMetrics(long totalAcquisitions, long successfulAcquisitions, long failedAcquisitions, long avgWaitTimeNanos, long maxWaitTimeNanos, int currentAvailable, int poolSize)
      Creates an instance of a BufferPoolMetrics record class.
      Parameters:
      totalAcquisitions - the value for the totalAcquisitions record component
      successfulAcquisitions - the value for the successfulAcquisitions record component
      failedAcquisitions - the value for the failedAcquisitions record component
      avgWaitTimeNanos - the value for the avgWaitTimeNanos record component
      maxWaitTimeNanos - the value for the maxWaitTimeNanos record component
      currentAvailable - the value for the currentAvailable record component
      poolSize - the value for the poolSize record component
  • Method Details

    • successRate

      public double successRate()
      Returns the success rate as a ratio between 0.0 and 1.0.
      Returns:
      success rate (0.0 if no acquisitions attempted)
    • failureRate

      public double failureRate()
      Returns the failure rate as a ratio between 0.0 and 1.0.
      Returns:
      failure rate (0.0 if no acquisitions attempted)
    • utilization

      public double utilization()
      Returns the pool utilization as a ratio between 0.0 and 1.0.

      Higher values indicate more buffers are in use.

      Returns:
      utilization ratio (1.0 - available/poolSize)
    • avgWaitTimeMillis

      public double avgWaitTimeMillis()
      Returns the average wait time in milliseconds.
      Returns:
      average wait time in milliseconds
    • maxWaitTimeMillis

      public double maxWaitTimeMillis()
      Returns the maximum wait time in milliseconds.
      Returns:
      maximum wait time in milliseconds
    • toString

      public String toString()
      Returns a string representation of this record class. The representation contains the name of the class, followed by the name and value of each of the record components.
      Specified by:
      toString in class Record
      Returns:
      a string representation of this object
    • hashCode

      public final int hashCode()
      Returns a hash code value for this object. The value is derived from the hash code of each of the record components.
      Specified by:
      hashCode in class Record
      Returns:
      a hash code value for this object
    • equals

      public final boolean equals(Object o)
      Indicates whether some other object is "equal to" this one. The objects are equal if the other object is of the same class and if all the record components are equal. All components in this record class are compared with the compare method from their corresponding wrapper classes.
      Specified by:
      equals in class Record
      Parameters:
      o - the object with which to compare
      Returns:
      true if this object is the same as the o argument; false otherwise.
    • totalAcquisitions

      public long totalAcquisitions()
      Returns the value of the totalAcquisitions record component.
      Returns:
      the value of the totalAcquisitions record component
    • successfulAcquisitions

      public long successfulAcquisitions()
      Returns the value of the successfulAcquisitions record component.
      Returns:
      the value of the successfulAcquisitions record component
    • failedAcquisitions

      public long failedAcquisitions()
      Returns the value of the failedAcquisitions record component.
      Returns:
      the value of the failedAcquisitions record component
    • avgWaitTimeNanos

      public long avgWaitTimeNanos()
      Returns the value of the avgWaitTimeNanos record component.
      Returns:
      the value of the avgWaitTimeNanos record component
    • maxWaitTimeNanos

      public long maxWaitTimeNanos()
      Returns the value of the maxWaitTimeNanos record component.
      Returns:
      the value of the maxWaitTimeNanos record component
    • currentAvailable

      public int currentAvailable()
      Returns the value of the currentAvailable record component.
      Returns:
      the value of the currentAvailable record component
    • poolSize

      public int poolSize()
      Returns the value of the poolSize record component.
      Returns:
      the value of the poolSize record component