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
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
map
protected final java.util.concurrent.ConcurrentMap<T,SuppressCache.Value> map
SuppressCache
public SuppressCache()
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 class java.lang.Object
Copyright © 1998-2012 Bela Ban / Red Hat. All Rights Reserved.