Class 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
    1. equivalent to "pool-resize" quantity of resources are removed
    2. less than "pool-reize" quantity of resources are removed remove more resources to match pool-resize quantity, atmost scale-down till steady-pool-size
    3. 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.
    Author:
    Jagadish Ramu
    • 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 a size <= pool-resize-quantity
        Parameters:
        forced - scale-down only when forced
        scaleDownQuantity - 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)