Class PoolUtils.ErodingFactor
- java.lang.Object
-
- org.datanucleus.store.rdbms.datasource.dbcp2.pool2.PoolUtils.ErodingFactor
-
- Enclosing class:
- PoolUtils
private static final class PoolUtils.ErodingFactor extends java.lang.Object
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
Fields Modifier and Type Field Description private float
factor
Determines frequency of "erosion" eventsprivate int
idleHighWaterMark
High water mark - largest numIdle encounteredprivate long
nextShrink
Time of next shrink event
-
Constructor Summary
Constructors Constructor Description ErodingFactor(float factor)
Creates a new ErodingFactor with the given erosion factor.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description long
getNextShrink()
Returns the time of the next erosion event.java.lang.String
toString()
void
update(long now, int numIdle)
Updates internal state using the supplied time and numIdle.
-
-
-
Method Detail
-
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
public java.lang.String toString()
- Overrides:
toString
in classjava.lang.Object
-
-