Record Class EvictionContext
java.lang.Object
java.lang.Record
cloud.opencode.base.pool.policy.EvictionContext
- Record Components:
currentIdleCount- the current idle object count - 当前空闲对象数currentActiveCount- the current active object count - 当前活跃对象数maxTotal- the maximum total objects - 最大对象总数evictionTime- the eviction time - 驱逐时间
public record EvictionContext(int currentIdleCount, int currentActiveCount, int maxTotal, Instant evictionTime)
extends Record
EvictionContext - Eviction Context Record (JDK 25 Record)
EvictionContext - 驱逐上下文记录 (JDK 25 Record)
Provides contextual information for eviction policy decisions.
为驱逐策略决策提供上下文信息。
Features | 主要功能:
- Pool state information - 池状态信息
- Immutable record type - 不可变记录类型
- Eviction timing info - 驱逐时间信息
Usage Examples | 使用示例:
EvictionContext ctx = new EvictionContext(5, 3, 10, Instant.now());
if (ctx.currentIdleCount() > ctx.maxTotal() / 2) {
// trigger aggressive eviction
}
Security | 安全性:
- Thread-safe: Yes (immutable record) - 线程安全: 是(不可变记录)
- Null-safe: No - 空值安全: 否
- Since:
- JDK 25, opencode-base-pool V1.0.0
- Author:
- Leon Soo www.LeonSoo.com
- See Also:
-
Constructor Summary
ConstructorsConstructorDescriptionEvictionContext(int currentIdleCount, int currentActiveCount, int maxTotal, Instant evictionTime) Creates an instance of aEvictionContextrecord class. -
Method Summary
Modifier and TypeMethodDescriptionintReturns the value of thecurrentActiveCountrecord component.intReturns the value of thecurrentIdleCountrecord component.final booleanIndicates whether some other object is "equal to" this one.Returns the value of theevictionTimerecord component.final inthashCode()Returns a hash code value for this object.doubleGets the idle ratio.booleanChecks if the pool is at capacity.intmaxTotal()Returns the value of themaxTotalrecord component.final StringtoString()Returns a string representation of this record class.intGets the total object count.
-
Constructor Details
-
EvictionContext
public EvictionContext(int currentIdleCount, int currentActiveCount, int maxTotal, Instant evictionTime) Creates an instance of aEvictionContextrecord class.- Parameters:
currentIdleCount- the value for thecurrentIdleCountrecord componentcurrentActiveCount- the value for thecurrentActiveCountrecord componentmaxTotal- the value for themaxTotalrecord componentevictionTime- the value for theevictionTimerecord component
-
-
Method Details
-
totalCount
public int totalCount()Gets the total object count. 获取对象总数。- Returns:
- the total count - 总数
-
isAtCapacity
public boolean isAtCapacity()Checks if the pool is at capacity. 检查池是否已满。- Returns:
- true if at capacity - 如果已满返回true
-
idleRatio
public double idleRatio()Gets the idle ratio. 获取空闲比率。- Returns:
- the idle ratio (0.0 to 1.0) - 空闲比率 (0.0到1.0)
-
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. Reference components are compared withObjects::equals(Object,Object); primitive components are compared with thecomparemethod from their corresponding wrapper classes. -
currentIdleCount
public int currentIdleCount()Returns the value of thecurrentIdleCountrecord component.- Returns:
- the value of the
currentIdleCountrecord component
-
currentActiveCount
public int currentActiveCount()Returns the value of thecurrentActiveCountrecord component.- Returns:
- the value of the
currentActiveCountrecord component
-
maxTotal
-
evictionTime
Returns the value of theevictionTimerecord component.- Returns:
- the value of the
evictionTimerecord component
-