Class RpcWrapper<S extends NfsRequestBase, T extends NfsResponseBase>

java.lang.Object
com.emc.ecs.nfsclient.rpc.RpcWrapper<S,T>

public class RpcWrapper<S extends NfsRequestBase, T extends NfsResponseBase> extends Object
Wrapper for NFS Server RPC calls, to handle unmarshalling, retries, and status checking.
  • Constructor Summary

    Constructors
    Constructor
    Description
    RpcWrapper(String server, int port, int retryWait, int maximumRetries, int maximumRequestSize, int rpcTimeout)
     
  • Method Summary

    Modifier and Type
    Method
    Description
    callRpc(String serverIP, Xdr xdrRequest, boolean usePrivilegedPort)
    Basic RPC call functionality only.
    void
    callRpcChecked(S request, RpcResponseHandler<? extends T> responseHandler)
    Convenience wrapper for NFS RPC calls where the IP is determined by a byte[] key.
    void
    callRpcNaked(S request, T response)
    Make the call using the Request ip key to determine the IP address for communication.
    void
    callRpcNaked(S request, T response, String ipAddress)
    Make the call to a specified IP address.
    void
    callRpcWrapped(S request, RpcResponseHandler<? extends T> responseHandler)
    Make the wrapped call and unmarshall the returned Xdr to a response, getting the IP key from the request.
    void
    callRpcWrapped(S request, RpcResponseHandler<? extends T> responseHandler, String ip)
    Make the wrapped call and unmarshall the returned Xdr to a response, using the given ip .
    chooseIP(byte[] key)
    Select an IP address to use for communication, based on the key and policy .
    void
    setPort(int port)
    Reset the port as necessary - used if the port changes.

    Methods inherited from class Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Constructor Details

    • RpcWrapper

      public RpcWrapper(String server, int port, int retryWait, int maximumRetries, int maximumRequestSize, int rpcTimeout)
      Parameters:
      server - The remote server being called.
      port - The port on the remote server being used for this communication.
      retryWait - The wait in milliseconds.
      maximumRetries - The maximum number of retries.
      maximumRequestSize - The maximum request size in bytes.
      rpcTimeout - The timeout in seconds.
  • Method Details

    • setPort

      public void setPort(int port)
      Reset the port as necessary - used if the port changes.
      Parameters:
      port - The port on the remote server being used for this communication.
    • callRpcWrapped

      public void callRpcWrapped(S request, RpcResponseHandler<? extends T> responseHandler) throws IOException
      Make the wrapped call and unmarshall the returned Xdr to a response, getting the IP key from the request. If an RPC Exception is being thrown, and retries remain, then log the exception and retry.
      Parameters:
      request - The request to send.
      responseHandler - A response handler.
      Throws:
      IOException
    • callRpcWrapped

      public void callRpcWrapped(S request, RpcResponseHandler<? extends T> responseHandler, String ip) throws IOException
      Make the wrapped call and unmarshall the returned Xdr to a response, using the given ip . If an RPC Exception is being thrown, and retries remain, then log the exception and retry.
      Parameters:
      request - The request to send.
      responseHandler - A response handler.
      ip - The IP address to use for communication.
      Throws:
      IOException
    • callRpcChecked

      public void callRpcChecked(S request, RpcResponseHandler<? extends T> responseHandler) throws IOException
      Convenience wrapper for NFS RPC calls where the IP is determined by a byte[] key. This method just determines the IP address and calls the basic method.
      Parameters:
      request - The request to send.
      responseHandler - A response handler.
      Throws:
      IOException
    • callRpcNaked

      public void callRpcNaked(S request, T response) throws IOException
      Make the call using the Request ip key to determine the IP address for communication.
      Parameters:
      request - The request to send.
      response - A response to hold the returned data.
      Throws:
      IOException
    • callRpcNaked

      public void callRpcNaked(S request, T response, String ipAddress) throws RpcException
      Make the call to a specified IP address.
      Parameters:
      request - The request to send.
      response - A response to hold the returned data.
      ipAddress - The IP address to use for communication.
      Throws:
      RpcException
    • callRpc

      public Xdr callRpc(String serverIP, Xdr xdrRequest, boolean usePrivilegedPort) throws RpcException
      Basic RPC call functionality only.
      Parameters:
      serverIP - The endpoint of the server being called.
      xdrRequest - The Xdr data for the request.
      usePrivilegedPort -
      • If true, use a privileged local port (below 1024) for RPC communication.
      • If false, use any non-privileged local port for RPC communication.
      Returns:
      The Xdr data for the response.
      Throws:
      RpcException
    • chooseIP

      public String chooseIP(byte[] key) throws IOException
      Select an IP address to use for communication, based on the key and policy .
      Parameters:
      key - The key to use when selecting an IP address.
      Returns:
      The IP address to use for communication.
      Throws:
      IOException