Package org.jgroups.util
Class SuppressCache<T>
java.lang.Object
org.jgroups.util.SuppressCache<T>
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
-
Nested Class Summary
Nested Classes -
Field Summary
FieldsModifier and TypeFieldDescriptionprotected final ConcurrentMap<T, SuppressCache.Value> protected final T -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoidclear()putIfAbsent(T key, long expiry_time) Adds a new key to the hashmap, or updates the value associated with the existing key if present.voidremoveAll(Collection<T> list) voidremoveExpired(long expiry_time) voidretainAll(Collection<T> list) intsize()Returns the total count of all valuestoString()
-
Field Details
-
map
-
NULL_KEY
-
-
Constructor Details
-
SuppressCache
public SuppressCache()
-
-
Method Details
-
putIfAbsent
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 keyexpiry_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
-
removeAll
-
removeExpired
public void removeExpired(long expiry_time) -
size
public int size()Returns the total count of all values -
toString
-