public class Resizer extends TimerTask
Remove all invalid and idle resources, as a result one of the following may happen
i) equivalent to "pool-resize" quantity of resources are removed
ii) less than "pool-reize" quantity of resources are removed
remove more resources to match pool-resize quantity, atmost scale-down till steady-pool-size
iii) more than "pool-resize" quantity of resources are removed
(1) if pool-size is less than steady-pool-size, bring it back to steady-pool-size.
(2) if pool-size is greater than steady-pool-size, don't do anything.
Modifier and Type | Field and Description |
---|---|
protected static Logger |
_logger |
protected DataStructure |
ds |
protected ResourceHandler |
handler |
protected PoolProperties |
pool |
protected PoolInfo |
poolInfo |
protected boolean |
preferValidateOverRecreate |
Constructor and Description |
---|
Resizer(PoolInfo poolInfo,
DataStructure ds,
PoolProperties pp,
ResourceHandler handler,
boolean preferValidateOverRecreate) |
Modifier and Type | Method and Description |
---|---|
protected static void |
debug(String debugStatement) |
protected boolean |
isResourceEligibleForRemoval(ResourceHandle h,
int validConnectionsCounter) |
protected int |
removeIdleAndInvalidResources()
Get the free connections list from the pool, remove idle-timed-out resources
and then invalid resources.
|
void |
resizePool(boolean forced)
Resize the pool
|
void |
run() |
protected void |
scaleDownPool(int scaleDownQuantity,
boolean forced)
Scale down pool by a
size <= pool-resize-quantity |
protected int |
validateAndRemoveResource(ResourceHandle handle,
Set invalidConnections) |
cancel, scheduledExecutionTime
protected PoolInfo poolInfo
protected DataStructure ds
protected PoolProperties pool
protected ResourceHandler handler
protected boolean preferValidateOverRecreate
protected static final Logger _logger
public Resizer(PoolInfo poolInfo, DataStructure ds, PoolProperties pp, ResourceHandler handler, boolean preferValidateOverRecreate)
public void resizePool(boolean forced)
forced
- when force is true, scale down the pool.protected void scaleDownPool(int scaleDownQuantity, boolean forced)
size <= pool-resize-quantity
forced
- scale-down only when forcedscaleDownQuantity
- no. of resources to removeprotected int removeIdleAndInvalidResources()
protected static void debug(String debugStatement)
protected int validateAndRemoveResource(ResourceHandle handle, Set invalidConnections)
protected boolean isResourceEligibleForRemoval(ResourceHandle h, int validConnectionsCounter)
Copyright © 2018. All rights reserved.