Package org.jgroups.util
Class SuppressCache<T>
- java.lang.Object
-
- org.jgroups.util.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
-
Field Summary
Fields Modifier and Type Field Description protected java.util.concurrent.ConcurrentMap<T,SuppressCache.Value>
map
protected T
NULL_KEY
-
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 valuesjava.lang.String
toString()
-
-
-
Field Detail
-
map
protected final java.util.concurrent.ConcurrentMap<T,SuppressCache.Value> map
-
NULL_KEY
protected final T NULL_KEY
-
-
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 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
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 classjava.lang.Object
-
-