Package org.apache.commons.pool2
Class PoolUtils.ErodingFactor
- java.lang.Object
-
- org.apache.commons.pool2.PoolUtils.ErodingFactor
-
- Enclosing class:
- PoolUtils
private static final class PoolUtils.ErodingFactor extends java.lang.ObjectEncapsulate the logic for when the next poolable object should be discarded. Each time update is called, the next time to shrink is recomputed, based on the float factor, number of idle instances in the pool and high water mark. Float factor is assumed to be between 0 and 1. Values closer to 1 cause less frequent erosion events. Erosion event timing also depends on numIdle. When this value is relatively high (close to previously established high water mark), erosion occurs more frequently.
-
-
Field Summary
Fields Modifier and Type Field Description private floatfactorDetermines frequency of "erosion" eventsprivate intidleHighWaterMarkHigh water mark - largest numIdle encounteredprivate java.util.concurrent.locks.ReentrantLocklockprivate static floatMAX_INTERVALprivate longnextShrinkMillisTime of next shrink event
-
Constructor Summary
Constructors Modifier Constructor Description privateErodingFactor(float factor)Creates a new ErodingFactor with the given erosion factor.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description private longgetNextShrink()Gets the time of the next erosion event.java.lang.StringtoString()voidupdate(long nowMillis, int numIdle)Updates internal state using the supplied time and numIdle.
-
-
-
Field Detail
-
MAX_INTERVAL
private static final float MAX_INTERVAL
- See Also:
- Constant Field Values
-
factor
private final float factor
Determines frequency of "erosion" events
-
nextShrinkMillis
private transient volatile long nextShrinkMillis
Time of next shrink event
-
idleHighWaterMark
private transient volatile int idleHighWaterMark
High water mark - largest numIdle encountered
-
lock
private final java.util.concurrent.locks.ReentrantLock lock
-
-
Method Detail
-
getNextShrink
private long getNextShrink()
Gets the time of the next erosion event.- Returns:
- next shrink time
-
toString
public java.lang.String toString()
- Overrides:
toStringin classjava.lang.Object
-
update
public void update(long nowMillis, int numIdle)Updates internal state using the supplied time and numIdle.- Parameters:
nowMillis- current timenumIdle- number of idle elements in the pool
-
-