Package org.apache.commons.pool
Class PoolUtils.ErodingFactor
java.lang.Object
org.apache.commons.pool.PoolUtils.ErodingFactor
- Enclosing class:
- PoolUtils
Encapsulate 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
FieldsModifier and TypeFieldDescriptionprivate final float
Determines frequency of "erosion" eventsprivate int
High water mark - largest numIdle encounteredprivate long
Time of next shrink event -
Constructor Summary
ConstructorsConstructorDescriptionErodingFactor
(float factor) Create a new ErodingFactor with the given erosion factor. -
Method Summary
-
Field Details
-
factor
private final float factorDetermines frequency of "erosion" events -
nextShrink
private transient volatile long nextShrinkTime of next shrink event -
idleHighWaterMark
private transient volatile int idleHighWaterMarkHigh water mark - largest numIdle encountered
-
-
Constructor Details
-
ErodingFactor
public ErodingFactor(float factor) Create a new ErodingFactor with the given erosion factor.- Parameters:
factor
- erosion factor
-
-
Method Details
-
update
public void update(int numIdle) Updates internal state based on numIdle and the current time.- Parameters:
numIdle
- number of idle elements in the pool
-
update
public void update(long now, int numIdle) Updates internal state using the supplied time and numIdle.- Parameters:
now
- current timenumIdle
- number of idle elements in the pool
-
getNextShrink
public long getNextShrink()Returns the time of the next erosion event.- Returns:
- next shrink time
-
toString
-