Package org.apache.accumulo.core.rpc
Class TTimeoutTransport
- java.lang.Object
-
- org.apache.accumulo.core.rpc.TTimeoutTransport
-
public class TTimeoutTransport extends Object
A utility class for setting up aTTransport
with various necessary configurations for ideal performance in Accumulo. These configurations include:- Setting SO_LINGER=false on the socket.
- Setting TCP_NO_DELAY=true on the socket.
- Setting timeouts on the I/OStreams.
-
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description static org.apache.thrift.transport.TTransport
create(SocketAddress addr, long timeoutMillis)
Creates a Thrift TTransport to the given address with the given timeout.static org.apache.thrift.transport.TTransport
create(HostAndPort addr, long timeoutMillis)
Creates a Thrift TTransport to the given address with the given timeout.protected org.apache.thrift.transport.TTransport
createInternal(SocketAddress addr, long timeoutMillis)
Opens a socket to the givenaddr
, configures the socket, and then creates a Thrift transport using the socket.protected Socket
openSocket(SocketAddress addr)
Opens and configures aSocket
for Accumulo RPC.protected Socket
openSocketChannel()
Opens a socket channel and returns the underlying socket.protected InputStream
wrapInputStream(Socket socket, long timeoutMillis)
protected OutputStream
wrapOutputStream(Socket socket, long timeoutMillis)
-
-
-
Method Detail
-
create
public static org.apache.thrift.transport.TTransport create(HostAndPort addr, long timeoutMillis) throws IOException
Creates a Thrift TTransport to the given address with the given timeout. All created resources are closed if an exception is thrown.- Parameters:
addr
- The address to connect the client totimeoutMillis
- The timeout in milliseconds for the connection- Returns:
- A TTransport connected to the given
addr
- Throws:
IOException
- If the transport fails to be created/connected
-
create
public static org.apache.thrift.transport.TTransport create(SocketAddress addr, long timeoutMillis) throws IOException
Creates a Thrift TTransport to the given address with the given timeout. All created resources are closed if an exception is thrown.- Parameters:
addr
- The address to connect the client totimeoutMillis
- The timeout in milliseconds for the connection- Returns:
- A TTransport connected to the given
addr
- Throws:
IOException
- If the transport fails to be created/connected
-
createInternal
protected org.apache.thrift.transport.TTransport createInternal(SocketAddress addr, long timeoutMillis) throws IOException
Opens a socket to the givenaddr
, configures the socket, and then creates a Thrift transport using the socket.- Parameters:
addr
- The address the socket should connecttimeoutMillis
- The socket timeout in milliseconds- Returns:
- A TTransport instance to the given
addr
- Throws:
IOException
- If the Thrift client is failed to be connected/created
-
wrapInputStream
protected InputStream wrapInputStream(Socket socket, long timeoutMillis) throws IOException
- Throws:
IOException
-
wrapOutputStream
protected OutputStream wrapOutputStream(Socket socket, long timeoutMillis) throws IOException
- Throws:
IOException
-
openSocket
protected Socket openSocket(SocketAddress addr) throws IOException
Opens and configures aSocket
for Accumulo RPC.- Parameters:
addr
- The address to connect the socket to- Returns:
- A socket connected to the given address, or null if the socket fails to connect
- Throws:
IOException
-
openSocketChannel
protected Socket openSocketChannel() throws IOException
Opens a socket channel and returns the underlying socket.- Throws:
IOException
-
-