Class SuppressCache<T>


  • public class SuppressCache<T>
    extends java.lang.Object
    Cache which keeps a timestamp and counter for every key. When a timestamp has expired (based on an expiry time), the corresponding key is removed.

    This cache is mainly used to suppress identical warning messages (in TP), e.g. if we get 1000 warnings about reception of messages from P (who's not in our cluster), we can print such a message only every 60 seconds (expiry time = 60 secs).

    Since:
    3.2
    Author:
    Bela Ban
    • Nested Class Summary

      Nested Classes 
      Modifier and Type Class Description
      static class  SuppressCache.Value  
    • Constructor Summary

      Constructors 
      Constructor Description
      SuppressCache()  
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      void clear()  
      SuppressCache.Value putIfAbsent​(T key, long expiry_time)
      Adds a new key to the hashmap, or updates the Value associated with the existing key if present.
      void removeAll​(java.util.Collection<T> list)  
      void removeExpired​(long expiry_time)  
      void retainAll​(java.util.Collection<T> list)  
      int size()
      Returns the total count of all values
      java.lang.String toString()  
      • Methods inherited from class java.lang.Object

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

      • NULL_KEY

        protected final T NULL_KEY
    • Constructor Detail

      • SuppressCache

        public SuppressCache()
    • Method Detail

      • putIfAbsent

        public SuppressCache.Value putIfAbsent​(T key,
                                               long expiry_time)
        Adds a new key to the hashmap, or updates the Value associated with the existing key if present. If expiry_time is greater than the age of the Value, the key will be removed.
        Parameters:
        key - The key
        expiry_time - Expiry time (in ms)
        Returns:
        Null if the key was present and not expired, or the Value associated with the existing key (its count incremented)
      • clear

        public void clear()
      • retainAll

        public void retainAll​(java.util.Collection<T> list)
      • removeAll

        public void removeAll​(java.util.Collection<T> list)
      • removeExpired

        public void removeExpired​(long expiry_time)
      • size

        public int size()
        Returns the total count of all values
      • toString

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