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 succeededfailedAcquisitions- number of acquisitions that timed out or failedavgWaitTimeNanos- average wait time in nanoseconds for successful acquisitionsmaxWaitTimeNanos- maximum wait time observed in nanosecondscurrentAvailable- number of buffers currently available in the poolpoolSize- 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 Summary
ConstructorsConstructorDescriptionBufferPoolMetrics(long totalAcquisitions, long successfulAcquisitions, long failedAcquisitions, long avgWaitTimeNanos, long maxWaitTimeNanos, int currentAvailable, int poolSize) Creates an instance of aBufferPoolMetricsrecord class. -
Method Summary
Modifier and TypeMethodDescriptiondoubleReturns the average wait time in milliseconds.longReturns the value of theavgWaitTimeNanosrecord component.intReturns the value of thecurrentAvailablerecord component.final booleanIndicates whether some other object is "equal to" this one.longReturns the value of thefailedAcquisitionsrecord component.doubleReturns the failure rate as a ratio between 0.0 and 1.0.final inthashCode()Returns a hash code value for this object.doubleReturns the maximum wait time in milliseconds.longReturns the value of themaxWaitTimeNanosrecord component.intpoolSize()Returns the value of thepoolSizerecord component.longReturns the value of thesuccessfulAcquisitionsrecord component.doubleReturns the success rate as a ratio between 0.0 and 1.0.toString()Returns a string representation of this record class.longReturns the value of thetotalAcquisitionsrecord component.doubleReturns the pool utilization as a ratio between 0.0 and 1.0.
-
Constructor Details
-
BufferPoolMetrics
public BufferPoolMetrics(long totalAcquisitions, long successfulAcquisitions, long failedAcquisitions, long avgWaitTimeNanos, long maxWaitTimeNanos, int currentAvailable, int poolSize) Creates an instance of aBufferPoolMetricsrecord class.- Parameters:
totalAcquisitions- the value for thetotalAcquisitionsrecord componentsuccessfulAcquisitions- the value for thesuccessfulAcquisitionsrecord componentfailedAcquisitions- the value for thefailedAcquisitionsrecord componentavgWaitTimeNanos- the value for theavgWaitTimeNanosrecord componentmaxWaitTimeNanos- the value for themaxWaitTimeNanosrecord componentcurrentAvailable- the value for thecurrentAvailablerecord componentpoolSize- the value for thepoolSizerecord 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
-
hashCode
-
equals
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 thecomparemethod from their corresponding wrapper classes. -
totalAcquisitions
public long totalAcquisitions()Returns the value of thetotalAcquisitionsrecord component.- Returns:
- the value of the
totalAcquisitionsrecord component
-
successfulAcquisitions
public long successfulAcquisitions()Returns the value of thesuccessfulAcquisitionsrecord component.- Returns:
- the value of the
successfulAcquisitionsrecord component
-
failedAcquisitions
public long failedAcquisitions()Returns the value of thefailedAcquisitionsrecord component.- Returns:
- the value of the
failedAcquisitionsrecord component
-
avgWaitTimeNanos
public long avgWaitTimeNanos()Returns the value of theavgWaitTimeNanosrecord component.- Returns:
- the value of the
avgWaitTimeNanosrecord component
-
maxWaitTimeNanos
public long maxWaitTimeNanos()Returns the value of themaxWaitTimeNanosrecord component.- Returns:
- the value of the
maxWaitTimeNanosrecord component
-
currentAvailable
public int currentAvailable()Returns the value of thecurrentAvailablerecord component.- Returns:
- the value of the
currentAvailablerecord component
-
poolSize
-