Build 1.0_r1(from source)

java.net
Class NegativeCache<K,V>

java.lang.Object
  extended by java.util.AbstractMap<K,V>
      extended by java.util.HashMap<K,V>
          extended by java.util.LinkedHashMap<K,V>
              extended by 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.


Field Summary
(package private) static float LOADING
           
(package private) static int MAX_NEGATIVE_ENTRIES
           
(package private) static NegativeCache<String,NegCacheElement> negCache
           
 
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.
 
Methods inherited from class java.util.LinkedHashMap
clear, entrySet, get, keySet, put, remove, values
 
Methods inherited from class java.util.HashMap
clone, containsKey, containsValue, isEmpty, putAll, size
 
Methods inherited from class java.util.AbstractMap
equals, hashCode, toString
 
Methods inherited from class java.lang.Object
finalize, getClass, notify, notifyAll, wait, wait, wait
 
Methods inherited from interface java.util.Map
equals, hashCode
 

Field Detail

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
Constructor Detail

NegativeCache

NegativeCache(int initialCapacity,
              float loadFactor,
              boolean accessOrder)
Returns the hostname for the cache element

Method Detail

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 failed
failedMessage - 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


Build 1.0_r1(from source)

Please submit a feedback, bug or feature