Class Resizer
- java.lang.Object
-
- java.util.TimerTask
-
- com.sun.enterprise.resource.pool.resizer.Resizer
-
- All Implemented Interfaces:
Runnable
- Direct Known Subclasses:
AssocWithThreadPoolResizer
public class Resizer extends TimerTask
Resizer to remove unusable connections, maintain steady-pool
Remove all invalid and idle resources, as a result one of the following may happen
- equivalent to "pool-resize" quantity of resources are removed
- less than "pool-reize" quantity of resources are removed remove more resources to match pool-resize quantity, atmost scale-down till steady-pool-size
- more than "pool-resize" quantity of resources are removed
- if pool-size is less than steady-pool-size, bring it back to steady-pool-size.
- if pool-size is greater than steady-pool-size, don't do anything.
- if pool-size is less than steady-pool-size, bring it back to steady-pool-size.
- Author:
- Jagadish Ramu
-
-
Field Summary
Fields Modifier and Type Field Description protected static Logger
_logger
protected DataStructure
dataStructure
protected ResourceHandler
handler
protected PoolProperties
pool
protected PoolInfo
poolInfo
protected boolean
preferValidateOverRecreate
-
Constructor Summary
Constructors Constructor Description Resizer(PoolInfo poolInfo, DataStructure dataStructure, PoolProperties pp, ResourceHandler handler, boolean preferValidateOverRecreate)
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method 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 poolvoid
run()
protected void
scaleDownPool(int scaleDownQuantity, boolean forced)
Scale down pool by asize <= pool-resize-quantity
protected int
validateAndRemoveResource(ResourceHandle handle, Set invalidConnections)
-
Methods inherited from class java.util.TimerTask
cancel, scheduledExecutionTime
-
-
-
-
Field Detail
-
poolInfo
protected PoolInfo poolInfo
-
dataStructure
protected DataStructure dataStructure
-
pool
protected PoolProperties pool
-
handler
protected ResourceHandler handler
-
preferValidateOverRecreate
protected boolean preferValidateOverRecreate
-
_logger
protected static final Logger _logger
-
-
Constructor Detail
-
Resizer
public Resizer(PoolInfo poolInfo, DataStructure dataStructure, PoolProperties pp, ResourceHandler handler, boolean preferValidateOverRecreate)
-
-
Method Detail
-
resizePool
public void resizePool(boolean forced)
Resize the pool- Parameters:
forced
- when force is true, scale down the pool.
-
scaleDownPool
protected void scaleDownPool(int scaleDownQuantity, boolean forced)
Scale down pool by asize <= pool-resize-quantity
- Parameters:
forced
- scale-down only when forcedscaleDownQuantity
- no. of resources to remove
-
removeIdleAndInvalidResources
protected int removeIdleAndInvalidResources()
Get the free connections list from the pool, remove idle-timed-out resources and then invalid resources.- Returns:
- int number of resources removed
-
debug
protected static void debug(String debugStatement)
-
validateAndRemoveResource
protected int validateAndRemoveResource(ResourceHandle handle, Set invalidConnections)
-
isResourceEligibleForRemoval
protected boolean isResourceEligibleForRemoval(ResourceHandle h, int validConnectionsCounter)
-
-