Interface PoolMetrics
- All Known Implementing Classes:
DefaultPoolMetrics
public interface PoolMetrics
PoolMetrics - Pool Metrics Interface
PoolMetrics - 池指标接口
Interface for accessing pool performance metrics and statistics.
访问池性能指标和统计信息的接口。
Features | 主要功能:
- Borrow/return counters - 借用/归还计数器
- Create/destroy counters - 创建/销毁计数器
- Duration statistics - 时长统计
- Snapshot capability - 快照能力
Usage Examples | 使用示例:
PoolMetrics metrics = pool.getMetrics();
System.out.println("Borrow count: " + metrics.getBorrowCount());
System.out.println("Avg wait: " + metrics.getAverageWaitDuration().toMillis() + "ms");
MetricsSnapshot snapshot = metrics.snapshot();
// Export or log the snapshot
Security | 安全性:
- Thread-safe: Implementation dependent - 线程安全: 取决于实现
- Null-safe: No - 空值安全: 否
- Since:
- JDK 25, opencode-base-pool V1.0.0
- Author:
- Leon Soo www.LeonSoo.com
- See Also:
-
Method Summary
Modifier and TypeMethodDescriptionGets the average borrow duration.Gets the average wait duration.longGets the total borrow count.longGets the total created count.longGets the total destroyed count.Gets the maximum borrow duration.longGets the total return count.snapshot()Creates a snapshot of current metrics.
-
Method Details
-
getBorrowCount
long getBorrowCount()Gets the total borrow count. 获取总借用次数。- Returns:
- the borrow count - 借用次数
-
getReturnCount
long getReturnCount()Gets the total return count. 获取总归还次数。- Returns:
- the return count - 归还次数
-
getCreatedCount
long getCreatedCount()Gets the total created count. 获取总创建次数。- Returns:
- the created count - 创建次数
-
getDestroyedCount
long getDestroyedCount()Gets the total destroyed count. 获取总销毁次数。- Returns:
- the destroyed count - 销毁次数
-
getAverageBorrowDuration
Duration getAverageBorrowDuration()Gets the average borrow duration. 获取平均借用时长。- Returns:
- the average borrow duration - 平均借用时长
-
getMaxBorrowDuration
Duration getMaxBorrowDuration()Gets the maximum borrow duration. 获取最大借用时长。- Returns:
- the maximum borrow duration - 最大借用时长
-
getAverageWaitDuration
Duration getAverageWaitDuration()Gets the average wait duration. 获取平均等待时长。- Returns:
- the average wait duration - 平均等待时长
-
snapshot
MetricsSnapshot snapshot()Creates a snapshot of current metrics. 创建当前指标的快照。- Returns:
- the metrics snapshot - 指标快照
-