Class AbsentResourceList


  • public class AbsentResourceList
    extends java.lang.Object
    Maintains a list of missing resources. Once added, a resource is considered absent until a specified time interval elapses. If marked absent a specified number of times, the resource is considered permanently absent until a second time interval expires -- the try-again interval -- at which time the resource is considered not absent, indicating that the caller may attempt to find the resource again. If the resource is subsequently marked absent, the cycle repeats.
    • Field Summary

      Fields 
      Modifier and Type Field Description
      protected static int DEFAULT_MAX_ABSENT_RESOURCE_TRIES
      The default number of times a resource is marked as absent before being marked as permanently absent.
      protected static int DEFAULT_MIN_ABSENT_RESOURCE_CHECK_INTERVAL
      The default interval to wait before indicating the resource is not absent.
      protected static int DEFAULT_TRY_AGAIN_INTERVAL
      The default interval at which a resources is marked as not absent after having been marked permanently absent.
      protected int maxTries
      The maximum number of times a resource is marked as absent before being marked as permanently absent.
      protected int minCheckInterval
      The interval to wait, in milliseconds, before indicating the resource is not absent.
      protected BasicSessionCache possiblyAbsent
      The map of absent resources.
      protected int tryAgainInterval
      The interval at which a resource is marked as not absent after having been marked as permanently absent.
    • Constructor Summary

      Constructors 
      Constructor Description
      AbsentResourceList()
      Construct an absent-resource list with default values for max tries (3), check interval (10 seconds) and try-again interval (60 seconds).
      AbsentResourceList​(int maxTries, int minCheckInterval)
      Construct an absent-resource list with a specified number of maximum tries and a check interval.
      AbsentResourceList​(java.lang.Integer cacheSize, int maxTries, int minCheckInterval, int tryAgainInterval)
      Construct an absent-resource list with a specified number of maximum tries, a check interval and a retry interval.
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      int getMaxTries()
      Indicates the maximum number of times a resource is marked as absent before being marked as permanently absent.
      int getMinCheckInterval()
      Indicates the time interval that must elapse before the resource is considered not absent if its max-tries has not been reached.
      int getTryAgainInterval()
      Indicates the time interval that must elapse before a resource marked as permanently absent is again considered not absent.
      boolean isResourceAbsent​(long resourceID)
      Indicates whether a resource is considered absent.
      boolean isResourceAbsent​(java.lang.String resourceID)
      Indicates whether a resource is considered absent.
      void markResourceAbsent​(long resourceID)
      Mark a specified resource as absent.
      void markResourceAbsent​(java.lang.String resourceID)
      Mark a specified resource as absent.
      void setMaxTries​(int maxTries)
      Specifies the maximum number of times a resource is marked as absent before being marked as permanently absent.
      void setMinCheckInterval​(int minCheckInterval)
      Specifies the time interval that must elapse before the resource is considered absent if its max-tries has not been reached.
      void setTryAgainInterval​(int tryAgainInterval)
      Specifies the time interval that must elapse before a resource marked as permanently absent is again considered not absent.
      void unmarkResourceAbsent​(long resourceID)
      Mark the resource as not-absent, effectively removing it from this absent-resource list.
      void unmarkResourceAbsent​(java.lang.String resourceID)
      Remove a resource from this absent-resource list if the resource is contained in the list.
      • Methods inherited from class java.lang.Object

        clone, equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Field Detail

      • DEFAULT_MAX_ABSENT_RESOURCE_TRIES

        protected static final int DEFAULT_MAX_ABSENT_RESOURCE_TRIES
        The default number of times a resource is marked as absent before being marked as permanently absent.
        See Also:
        Constant Field Values
      • DEFAULT_MIN_ABSENT_RESOURCE_CHECK_INTERVAL

        protected static final int DEFAULT_MIN_ABSENT_RESOURCE_CHECK_INTERVAL
        The default interval to wait before indicating the resource is not absent.
        See Also:
        Constant Field Values
      • DEFAULT_TRY_AGAIN_INTERVAL

        protected static final int DEFAULT_TRY_AGAIN_INTERVAL
        The default interval at which a resources is marked as not absent after having been marked permanently absent.
        See Also:
        Constant Field Values
      • maxTries

        protected int maxTries
        The maximum number of times a resource is marked as absent before being marked as permanently absent.
      • minCheckInterval

        protected int minCheckInterval
        The interval to wait, in milliseconds, before indicating the resource is not absent.
      • tryAgainInterval

        protected int tryAgainInterval
        The interval at which a resource is marked as not absent after having been marked as permanently absent.
      • possiblyAbsent

        protected BasicSessionCache possiblyAbsent
        The map of absent resources.
    • Constructor Detail

      • AbsentResourceList

        public AbsentResourceList()
        Construct an absent-resource list with default values for max tries (3), check interval (10 seconds) and try-again interval (60 seconds).
      • AbsentResourceList

        public AbsentResourceList​(int maxTries,
                                  int minCheckInterval)
        Construct an absent-resource list with a specified number of maximum tries and a check interval.
        Parameters:
        maxTries - the number of max tries. Must be greater than 0.
        minCheckInterval - the check interval. Must be greater than or equal to 0.
        Throws:
        java.lang.IllegalArgumentException - if max-tries is less than 1 or the minimum check interval is less than 0.
      • AbsentResourceList

        public AbsentResourceList​(java.lang.Integer cacheSize,
                                  int maxTries,
                                  int minCheckInterval,
                                  int tryAgainInterval)
        Construct an absent-resource list with a specified number of maximum tries, a check interval and a retry interval.
        Parameters:
        cacheSize - the maximum number of absent resources the list may hold. If this limit is exceeded, the oldest entries in the list are ejected and the resources they refer to are subsequently not considered to be absent resources.
        maxTries - the number of max tries. Must be greater than 0.
        minCheckInterval - the check interval. Must be greater than or equal to 0.
        tryAgainInterval - the try-again interval. Must be greater than or equal to 0.
        Throws:
        java.lang.IllegalArgumentException - if max-tries is less than 1 or if either the minimum check interval or try-again interval is less than 0.
    • Method Detail

      • getMaxTries

        public int getMaxTries()
        Indicates the maximum number of times a resource is marked as absent before being marked as permanently absent.
        Returns:
        the maximum number of absent markings.
      • setMaxTries

        public void setMaxTries​(int maxTries)
        Specifies the maximum number of times a resource is marked as absent before being marked as permanently absent.
        Parameters:
        maxTries - the number of max tries. Must be greater than 0.
        Throws:
        java.lang.IllegalArgumentException - if max-tries is less than 1.
      • getMinCheckInterval

        public int getMinCheckInterval()
        Indicates the time interval that must elapse before the resource is considered not absent if its max-tries has not been reached.
        Returns:
        the interval, in milliseconds.
      • setMinCheckInterval

        public void setMinCheckInterval​(int minCheckInterval)
        Specifies the time interval that must elapse before the resource is considered absent if its max-tries has not been reached.
        Parameters:
        minCheckInterval - the check interval. Must be greater than or equal to 0.
        Throws:
        java.lang.IllegalArgumentException - if the minimum check interval is less than 0.
      • getTryAgainInterval

        public int getTryAgainInterval()
        Indicates the time interval that must elapse before a resource marked as permanently absent is again considered not absent. This effectively expires the absent state of the resource.
        Returns:
        the interval, in milliseconds.
      • setTryAgainInterval

        public void setTryAgainInterval​(int tryAgainInterval)
        Specifies the time interval that must elapse before a resource marked as permanently absent is again considered not absent. This effectively expires the absent state of the resource.
        Parameters:
        tryAgainInterval - the try-again interval. Must be greater than or equal to 0.
        Throws:
        java.lang.IllegalArgumentException - if the try-again interval is less than 0.
      • markResourceAbsent

        public final void markResourceAbsent​(long resourceID)
        Mark a specified resource as absent. If the resource is already marked as absent, its max-tries value is incremented.
        Parameters:
        resourceID - the resource to mark as absent.
      • isResourceAbsent

        public final boolean isResourceAbsent​(long resourceID)
        Indicates whether a resource is considered absent.
        Parameters:
        resourceID - the resource in question.
        Returns:
        true if the resource is considered absent, otherwise false.
      • unmarkResourceAbsent

        public final void unmarkResourceAbsent​(long resourceID)
        Mark the resource as not-absent, effectively removing it from this absent-resource list.
        Parameters:
        resourceID - the resource to mark as not absent.
      • markResourceAbsent

        public final void markResourceAbsent​(java.lang.String resourceID)
        Mark a specified resource as absent. If the resource is already marked as absent, its max-tries value is incremented.
        Parameters:
        resourceID - the resource to mark as absent.
      • isResourceAbsent

        public final boolean isResourceAbsent​(java.lang.String resourceID)
        Indicates whether a resource is considered absent.
        Parameters:
        resourceID - the resource in question.
        Returns:
        true if the resource is considered absent, otherwise false.
      • unmarkResourceAbsent

        public final void unmarkResourceAbsent​(java.lang.String resourceID)
        Remove a resource from this absent-resource list if the resource is contained in the list.
        Parameters:
        resourceID - the resource to remove from this list.