Package org.apache.commons.pool2
Class PoolUtils.ErodingFactor
java.lang.Object
org.apache.commons.pool2.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 floatDetermines frequency of "erosion" eventsprivate intHigh water mark - largest numIdle encounteredprivate final ReentrantLockprivate static final floatprivate longTime of next shrink event -
Constructor Summary
ConstructorsModifierConstructorDescriptionprivateErodingFactor(float factor) Creates a new ErodingFactor with the given erosion factor. -
Method Summary
-
Field Details
-
MAX_INTERVAL
private static final float MAX_INTERVAL- See Also:
-
factor
private final float factorDetermines frequency of "erosion" events -
nextShrinkMillis
private transient volatile long nextShrinkMillisTime of next shrink event -
idleHighWaterMark
private transient volatile int idleHighWaterMarkHigh water mark - largest numIdle encountered -
lock
-
-
Constructor Details
-
ErodingFactor
private ErodingFactor(float factor) Creates a new ErodingFactor with the given erosion factor.- Parameters:
factor- erosion factor
-
-
Method Details
-
getNextShrink
private long getNextShrink()Gets the time of the next erosion event.- Returns:
- next shrink time
-
toString
-
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
-