java.net
Class NegativeCache<K,V>
java.lang.Object
java.util.AbstractMap<K,V>
java.util.HashMap<K,V>
java.util.LinkedHashMap<K,V>
java.net.NegativeCache<K,V>
- All Implemented Interfaces:
- Serializable, Cloneable, Map<K,V>
class NegativeCache<K,V>
- extends LinkedHashMap<K,V>
This class is used to manage the negative name lookup cache.
|
Constructor Summary |
NegativeCache(int initialCapacity,
float loadFactor,
boolean accessOrder)
Returns the hostname for the cache element |
|
Method Summary |
(package private) static void |
checkCacheExists()
This method checks if we have created the cache and if not creates it |
(package private) static String |
getFailedMessage(String hostName)
Returns the message that occurred when we failed to lookup the host if
such a failure is within the cache and the entry has not yet expired |
(package private) static void |
put(String hostName,
String failedMessage)
Adds the host name and the corresponding name lookup fail message to the
cache |
protected boolean |
removeEldestEntry(Map.Entry<K,V> eldest)
Returns if we should remove the Eldest entry. |
negCache
static NegativeCache<String,NegCacheElement> negCache
MAX_NEGATIVE_ENTRIES
static final int MAX_NEGATIVE_ENTRIES
- See Also:
- Constant Field Values
LOADING
static final float LOADING
- See Also:
- Constant Field Values
NegativeCache
NegativeCache(int initialCapacity,
float loadFactor,
boolean accessOrder)
- Returns the hostname for the cache element
removeEldestEntry
protected boolean removeEldestEntry(Map.Entry<K,V> eldest)
- Returns if we should remove the Eldest entry. We remove the eldest entry
if the size has grown beyond the maximum size allowed for the cache. We
create the LinkedHashMap such that this deletes the least recently used
entry
- Overrides:
removeEldestEntry in class LinkedHashMap<K,V>
- Parameters:
eldest - the map entry which will be deleted if we return true
- Returns:
- true if the eldest member should be removed
put
static void put(String hostName,
String failedMessage)
- Adds the host name and the corresponding name lookup fail message to the
cache
- Parameters:
hostName - the name of the host for which the lookup failedfailedMessage - the message returned when we failed the lookup
getFailedMessage
static String getFailedMessage(String hostName)
- Returns the message that occurred when we failed to lookup the host if
such a failure is within the cache and the entry has not yet expired
- Parameters:
hostName - the name of the host for which we are looking for an entry
- Returns:
- the message which was returned when the host failed to be looked
up if there is still a valid entry within the cache
checkCacheExists
static void checkCacheExists()
- This method checks if we have created the cache and if not creates it
Please submit a feedback, bug or feature