Class RpcCallCache

java.lang.Object
org.apache.hadoop.oncrpc.RpcCallCache

public class RpcCallCache extends Object
This class is used for handling the duplicate non-idempotenty Rpc calls. A non-idempotent request is processed as follows:
  • 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.
  • Constructor Details

    • RpcCallCache

      public RpcCallCache(String program, int maxEntries)
  • Method Details

    • getProgram

      public String getProgram()
      Return the program name.
      Returns:
      RPC program name
    • callCompleted

      public void callCompleted(InetAddress clientId, int xid, RpcResponse response)
      Mark a request as completed and add corresponding response to the cache.
      Parameters:
      clientId - client IP address
      xid - transaction id
      response - RPC response
    • checkOrAddToCache

      public RpcCallCache.CacheEntry checkOrAddToCache(InetAddress clientId, int xid)
      Check the cache for an entry. If it does not exist, add the request as in progress.
      Parameters:
      clientId - client IP address
      xid - 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