Package org.apache.hadoop.oncrpc
Class RpcCallCache
java.lang.Object
org.apache.hadoop.oncrpc.RpcCallCache
This class is used for handling the duplicate non-idempotenty Rpc
calls. A non-idempotent request is processed as follows:
A request is identified by the client ID (address of the client) and transaction ID (xid) from the Rpc call.
- If the request is being processed for the first time, its state is in-progress in cache.
- If the request is retransimitted and is in-progress state, it is ignored.
- If the request is retransimitted and is completed, the previous response from the cache is sent back to the client.
A request is identified by the client ID (address of the client) and transaction ID (xid) from the Rpc call.
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic classstatic classCall that is used to track a client in theRpcCallCache -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoidcallCompleted(InetAddress clientId, int xid, RpcResponse response) Mark a request as completed and add corresponding response to the cache.checkOrAddToCache(InetAddress clientId, int xid) Check the cache for an entry.Return the program name.iterator()Iterator to the cache entries.intsize()Return number of cached entries.
-
Constructor Details
-
RpcCallCache
-
-
Method Details
-
getProgram
Return the program name.- Returns:
- RPC program name
-
callCompleted
Mark a request as completed and add corresponding response to the cache.- Parameters:
clientId- client IP addressxid- transaction idresponse- RPC response
-
checkOrAddToCache
Check the cache for an entry. If it does not exist, add the request as in progress.- Parameters:
clientId- client IP addressxid- transaction id- Returns:
- cached entry
-
size
public int size()Return number of cached entries.- Returns:
- cache size
-
iterator
@VisibleForTesting public Iterator<Map.Entry<RpcCallCache.ClientRequest,RpcCallCache.CacheEntry>> iterator()Iterator to the cache entries.- Returns:
- iterator cache iterator
-