Class IdlePruneStrategy

  • All Implemented Interfaces:
    java.util.function.Function<PooledConnectionProxy,​java.lang.Boolean>, PruneStrategy

    public class IdlePruneStrategy
    extends java.lang.Object
    implements PruneStrategy
    Removes connections from the pool based on how long they have been idle in the available queue. By default this implementation executes every 5 minutes and prunes connections that have been idle for more than 10 minutes.
    Author:
    Middleware Services
    • Field Summary

      Fields 
      Modifier and Type Field Description
      protected org.slf4j.Logger logger
      Logger for this class.
    • Constructor Summary

      Constructors 
      Constructor Description
      IdlePruneStrategy()
      Creates a new idle prune strategy.
      IdlePruneStrategy​(java.time.Duration idle)
      Creates a new idle prune strategy.
      IdlePruneStrategy​(java.time.Duration period, java.time.Duration idle)
      Creates a new idle prune strategy.
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      java.lang.Boolean apply​(PooledConnectionProxy conn)  
      java.time.Duration getIdleTime()
      Returns the idle time.
      java.time.Duration getPrunePeriod()
      Returns the interval at which the prune task will be executed.
      int getStatisticsSize()
      Returns the number of statistics to store for this prune strategy.
      void setIdleTime​(java.time.Duration time)
      Sets the idle time.
      void setPrunePeriod​(java.time.Duration period)
      Sets the prune period.
      java.lang.String toString()  
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
      • Methods inherited from interface java.util.function.Function

        andThen, compose
    • Field Detail

      • logger

        protected final org.slf4j.Logger logger
        Logger for this class.
    • Constructor Detail

      • IdlePruneStrategy

        public IdlePruneStrategy()
        Creates a new idle prune strategy.
      • IdlePruneStrategy

        public IdlePruneStrategy​(java.time.Duration idle)
        Creates a new idle prune strategy. Sets the prune period to half of the supplied idle time.
        Parameters:
        idle - time at which a connection should be pruned
      • IdlePruneStrategy

        public IdlePruneStrategy​(java.time.Duration period,
                                 java.time.Duration idle)
        Creates a new idle prune strategy.
        Parameters:
        period - to execute the prune task
        idle - time at which a connection should be pruned
    • Method Detail

      • getPrunePeriod

        public java.time.Duration getPrunePeriod()
        Description copied from interface: PruneStrategy
        Returns the interval at which the prune task will be executed.
        Specified by:
        getPrunePeriod in interface PruneStrategy
        Returns:
        prune period
      • setPrunePeriod

        public void setPrunePeriod​(java.time.Duration period)
        Sets the prune period.
        Parameters:
        period - to set
      • getIdleTime

        public java.time.Duration getIdleTime()
        Returns the idle time.
        Returns:
        idle time
      • setIdleTime

        public void setIdleTime​(java.time.Duration time)
        Sets the idle time.
        Parameters:
        time - that a connection has been idle and should be pruned
      • toString

        public java.lang.String toString()
        Overrides:
        toString in class java.lang.Object