Class Connection

java.lang.Object
com.emc.ecs.nfsclient.network.Connection

public class Connection extends Object
Each Connection instance manages a tcp connection. The class is used to send data and track the status of a connection.
  • Constructor Details

    • Connection

      public Connection(String remoteHost, int port, boolean usePrivilegedPort)
      Parameters:
      remoteHost - A unique name for the host to which the connection is being made.
      port - The remote host port being used for the connection.
      usePrivilegedPort -
      • If true, use a privileged port (below 1024) for RPC communication.
      • If false, use any non-privileged port for RPC communication.
  • Method Details

    • getRemoteAddress

      public InetSocketAddress getRemoteAddress()
      Convenience getter method.
      Returns:
      The remote server internet address.
    • getConnectionState

      public Connection.State getConnectionState()
      Convenience getter method.
      Returns:
      The state.
    • sendAndWait

      public Xdr sendAndWait(int timeout, Xdr xdrRequest) throws RpcException
      Send a RPC request and wait until a response is received or timeout. The function will not retry. It is the responsibility of the application to do retry. The behaviours: a. If the tcp connection is not established yet: (1). sendAndWait will wait until the connection is established or timeout or network error occurs. (2). Once the connection is established, sendAndWait can send data. b. If the tcp connection is established: (1). the request is put in the internal queue of netty. Netty will send it asap. If there are already lots of pending requests in the queue, sendAndWait return error. (2). sendAndWait will wait until it gets a response from NFS server or timeout. (3). If the tcp connection is broken, the function return error with network error. c. If the tcp connection is broken suddenly: (1) the old sendAndWait will get the network error or timeout (2) The new sendAndWait will follow (a).
      Parameters:
      timeout - The timeout in seconds.
      xdrRequest - The generic RPC data and protocol-specific data.
      Returns:
      The Xdr data for the response.
      Throws:
      RpcException
    • connect

      protected void connect() throws RpcException
      If there is no current connection, start a new tcp connection asynchronously.
      Throws:
      RpcException
    • shutdown

      protected void shutdown()
      This is called when the application is shutdown or the channel is closed.
    • close

      protected void close()
      This is called when the connection should be closed.
    • close

      protected void close(Throwable cause)
    • notifySender

      protected void notifySender(Integer xid, Xdr response)
      Update the response map with the response and notify the thread waiting for the response. Do nothing if the future has been removed.
    • notifyAllPendingSenders

      protected void notifyAllPendingSenders(String message)
      Notify all the senders of all pending requests