Package org.apache.hadoop.ipc
Class RetryCache
java.lang.Object
org.apache.hadoop.ipc.RetryCache
Maintains a cache of non-idempotent requests that have been successfully
processed by the RPC server implementation, to handle the retries. A request
is uniquely identified by the unique client ID + call ID of the RPC request.
On receiving retried request, an entry will be found in the
RetryCache and the previous response is sent back to the request.
To look an implementation using this cache, see HDFS FSNamesystem class.
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic classCacheEntry is tracked using unique client ID and callId of the RPC request.static classCacheEntry with payload that tracks the previous response or parts of previous response to be used for generating response for retried requests. -
Field Summary
Fields -
Constructor Summary
ConstructorsConstructorDescriptionRetryCache(String cacheName, double percentage, long expirationTime) Constructor -
Method Summary
Modifier and TypeMethodDescriptionvoidaddCacheEntry(byte[] clientId, int callId) Add a new cache entry into the retry cache.voidaddCacheEntryWithPayload(byte[] clientId, int callId, Object payload) static voidclear(RetryCache cache) voidlock()static voidsetState(RetryCache.CacheEntry e, boolean success) static voidsetState(RetryCache.CacheEntryWithPayload e, boolean success, Object payload) voidunlock()static RetryCache.CacheEntrywaitForCompletion(RetryCache cache, byte[] clientId, int callId) Static method that provides null check for retryCache.waitForCompletion(RetryCache cache, Object payload, byte[] clientId, int callId) Static method that provides null check for retryCache.
-
Field Details
-
LOG
public static final org.slf4j.Logger LOG
-
-
Constructor Details
-
RetryCache
Constructor- Parameters:
cacheName- name to identify the cache bypercentage- percentage of total java heap space used by this cacheexpirationTime- time for an entry to expire in nanoseconds
-
-
Method Details
-
lock
public void lock() -
unlock
public void unlock() -
getCacheSet
@VisibleForTesting public LightWeightGSet<RetryCache.CacheEntry,RetryCache.CacheEntry> getCacheSet() -
getMetricsForTests
-
getCacheName
- Returns:
- This method returns cache name for metrics.
-
addCacheEntry
public void addCacheEntry(byte[] clientId, int callId) Add a new cache entry into the retry cache. The cache entry consists of clientId and callId extracted from editlog.- Parameters:
clientId- input clientId.callId- input callId.
-
addCacheEntryWithPayload
-
waitForCompletion
public static RetryCache.CacheEntry waitForCompletion(RetryCache cache, byte[] clientId, int callId) Static method that provides null check for retryCache.- Parameters:
cache- input Cache.clientId- client id of this requestcallId- client call id of this request- Returns:
- CacheEntry.
-
waitForCompletion
public static RetryCache.CacheEntryWithPayload waitForCompletion(RetryCache cache, Object payload, byte[] clientId, int callId) Static method that provides null check for retryCache.- Parameters:
cache- input cache.payload- input payload.clientId- client id of this requestcallId- client call id of this request- Returns:
- CacheEntryWithPayload.
-
setState
-
setState
-
clear
-