Class Connection
java.lang.Object
com.emc.ecs.nfsclient.network.Connection
Each Connection instance manages a tcp connection. The class is used to send data and track the
status of a connection.
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic enumSimple enums for communicating connection states. -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionprotected voidclose()This is called when the connection should be closed.protected voidprotected voidconnect()If there is no current connection, start a new tcp connection asynchronously.Convenience getter method.Convenience getter method.protected voidnotifyAllPendingSenders(String message) Notify all the senders of all pending requestsprotected voidnotifySender(Integer xid, Xdr response) Update the response map with the response and notify the thread waiting for the response.sendAndWait(int timeout, Xdr xdrRequest) Send a RPC request and wait until a response is received or timeout.protected voidshutdown()This is called when the application is shutdown or the channel is closed.
-
Constructor Details
-
Connection
- 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.
- If
-
-
Method Details
-
getRemoteAddress
Convenience getter method.- Returns:
- The remote server internet address.
-
getConnectionState
-
sendAndWait
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
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
-
notifySender
-
notifyAllPendingSenders
Notify all the senders of all pending requests
-