public class NettyTransceiver extends Transceiver
Transceiver implementation.| Modifier and Type | Class and Description | 
|---|---|
| protected class  | NettyTransceiver.NettyClientAvroHandlerAvro client handler for the Netty transport | 
| protected static class  | NettyTransceiver.NettyTransceiverThreadFactoryCreates threads with unique names based on a specified name prefix. | 
| protected static class  | NettyTransceiver.WriteFutureListenerA ChannelFutureListener for channel write operations that notifies a
  Callbackif an error occurs while writing to the channel. | 
| Modifier and Type | Field and Description | 
|---|---|
| static int | DEFAULT_CONNECTION_TIMEOUT_MILLISIf not specified, the default connection timeout will be used (60 sec). | 
| static boolean | DEFAULT_TCP_NODELAY_VALUE | 
| static String | NETTY_CONNECT_TIMEOUT_OPTION | 
| static String | NETTY_KEEPALIVE_OPTION | 
| static String | NETTY_TCP_NODELAY_OPTION | 
| Constructor and Description | 
|---|
| NettyTransceiver(InetSocketAddress addr)Creates a NettyTransceiver, and attempts to connect to the given address. | 
| NettyTransceiver(InetSocketAddress addr,
                Consumer<io.netty.channel.socket.SocketChannel> initializer)Creates a NettyTransceiver, and attempts to connect to the given address. | 
| NettyTransceiver(InetSocketAddress addr,
                Integer connectTimeoutMillis)Creates a NettyTransceiver, and attempts to connect to the given address. | 
| NettyTransceiver(InetSocketAddress addr,
                Integer connectTimeoutMillis,
                Consumer<io.netty.channel.socket.SocketChannel> initializer)Creates a NettyTransceiver, and attempts to connect to the given address. | 
| NettyTransceiver(InetSocketAddress addr,
                Integer connectTimeoutMillis,
                Consumer<io.netty.channel.socket.SocketChannel> initializer,
                Consumer<io.netty.bootstrap.Bootstrap> bootStrapInitialzier)Creates a NettyTransceiver, and attempts to connect to the given address. | 
| Modifier and Type | Method and Description | 
|---|---|
| void | close()Closes this transceiver and disconnects from the remote peer. | 
| void | close(boolean awaitCompletion)Closes this transceiver and disconnects from the remote peer. | 
| protected io.netty.channel.ChannelInboundHandler | createNettyClientAvroHandler()Creates a Netty ChannelUpstreamHandler for handling events on the Netty
 client channel. | 
| Protocol | getRemote()Returns the protocol passed to  Transceiver.setRemote(Protocol). | 
| String | getRemoteName() | 
| boolean | isConnected()True if a handshake has been completed for this connection. | 
| void | lockChannel()Netty channels are thread-safe, so there is no need to acquire locks. | 
| List<ByteBuffer> | readBuffers()Called by the default definition of  Transceiver.transceive(List). | 
| void | setRemote(Protocol protocol)Called with the remote protocol when a handshake has been completed. | 
| List<ByteBuffer> | transceive(List<ByteBuffer> request)Override as non-synchronized method because the method is thread safe. | 
| void | transceive(List<ByteBuffer> request,
          Callback<List<ByteBuffer>> callback)Called by  Requestor.request(String,Object,Callback)for two-way
 messages using callbacks. | 
| void | unlockChannel()Netty channels are thread-safe, so there is no need to acquire locks. | 
| void | writeBuffers(List<ByteBuffer> buffers)Called by  Requestor.request(String,Object)for one-way messages. | 
public static final int DEFAULT_CONNECTION_TIMEOUT_MILLIS
public static final String NETTY_CONNECT_TIMEOUT_OPTION
public static final String NETTY_TCP_NODELAY_OPTION
public static final String NETTY_KEEPALIVE_OPTION
public static final boolean DEFAULT_TCP_NODELAY_VALUE
public NettyTransceiver(InetSocketAddress addr) throws IOException
DEFAULT_CONNECTION_TIMEOUT_MILLIS is used for the connection
 timeout.addr - the address to connect to.IOException - if an error occurs connecting to the given address.public NettyTransceiver(InetSocketAddress addr, Integer connectTimeoutMillis) throws IOException
addr - the address to connect to.connectTimeoutMillis - maximum amount of time to wait for connection
                             establishment in milliseconds, or null to use
                             DEFAULT_CONNECTION_TIMEOUT_MILLIS.IOException - if an error occurs connecting to the given address.public NettyTransceiver(InetSocketAddress addr, Consumer<io.netty.channel.socket.SocketChannel> initializer) throws IOException
addr - the address to connect to.initializer - Consumer function to apply initial setup to the
                    SocketChannel. Useablet to set things like SSL
                    requirements, compression, etc...IOException - if an error occurs connecting to the given address.public NettyTransceiver(InetSocketAddress addr, Integer connectTimeoutMillis, Consumer<io.netty.channel.socket.SocketChannel> initializer) throws IOException
addr - the address to connect to.connectTimeoutMillis - maximum amount of time to wait for connection
                             establishment in milliseconds, or null to use
                             DEFAULT_CONNECTION_TIMEOUT_MILLIS.initializer - Consumer function to apply initial setup to the
                             SocketChannel. Usable to set things like SSL
                             requirements, compression, etc...IOException - if an error occurs connecting to the given address.public NettyTransceiver(InetSocketAddress addr, Integer connectTimeoutMillis, Consumer<io.netty.channel.socket.SocketChannel> initializer, Consumer<io.netty.bootstrap.Bootstrap> bootStrapInitialzier) throws IOException
addr - the address to connect to.connectTimeoutMillis - maximum amount of time to wait for connection
                             establishment in milliseconds, or null to use
                             DEFAULT_CONNECTION_TIMEOUT_MILLIS.initializer - Consumer function to apply initial setup to the
                             SocketChannel. Usable to set things like SSL
                             requirements, compression, etc...bootStrapInitialzier - Consumer function to apply initial setup to the
                             Bootstrap. Usable to set things like tcp
                             connection properties, nagle algorithm, etc...IOException - if an error occurs connecting to the given address.protected io.netty.channel.ChannelInboundHandler createNettyClientAvroHandler()
public void lockChannel()
lockChannel in class Transceiverpublic void unlockChannel()
unlockChannel in class Transceiverpublic void close()
close in interface Closeableclose in interface AutoCloseableclose in class Transceiverpublic void close(boolean awaitCompletion)
awaitCompletion - if true, will block until the close has completed.public String getRemoteName() throws IOException
getRemoteName in class TransceiverIOExceptionpublic List<ByteBuffer> transceive(List<ByteBuffer> request) throws IOException
transceive in class TransceiverIOExceptionpublic void transceive(List<ByteBuffer> request, Callback<List<ByteBuffer>> callback) throws IOException
TransceiverRequestor.request(String,Object,Callback) for two-way
 messages using callbacks.transceive in class TransceiverIOExceptionpublic void writeBuffers(List<ByteBuffer> buffers) throws IOException
TransceiverRequestor.request(String,Object) for one-way messages.writeBuffers in class TransceiverIOExceptionpublic List<ByteBuffer> readBuffers() throws IOException
TransceiverTransceiver.transceive(List).readBuffers in class TransceiverIOExceptionpublic Protocol getRemote()
TransceiverTransceiver.setRemote(Protocol). Throws
 IllegalStateException by default.getRemote in class Transceiverpublic boolean isConnected()
TransceiverisConnected in class Transceiverpublic void setRemote(Protocol protocol)
TransceiverTransceiver.isConnected() should return true and #getRemote() should return this
 protocol. Does nothing by default.setRemote in class TransceiverCopyright © 2009–2020 The Apache Software Foundation. All rights reserved.