public class NettyTransceiver
extends org.apache.avro.ipc.Transceiver
Transceiver
implementation.Modifier and Type | Class and Description |
---|---|
protected class |
NettyTransceiver.NettyClientAvroHandler
Avro client handler for the Netty transport
|
protected static class |
NettyTransceiver.NettyTransceiverThreadFactory
Creates threads with unique names based on a specified name prefix.
|
protected static class |
NettyTransceiver.WriteFutureListener
A ChannelFutureListener for channel write operations that notifies a
Callback if an error occurs while writing to the channel. |
Modifier and Type | Field and Description |
---|---|
static int |
DEFAULT_CONNECTION_TIMEOUT_MILLIS
If 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.
|
org.apache.avro.Protocol |
getRemote() |
String |
getRemoteName() |
boolean |
isConnected() |
void |
lockChannel()
Netty channels are thread-safe, so there is no need to acquire locks.
|
List<ByteBuffer> |
readBuffers() |
void |
setRemote(org.apache.avro.Protocol protocol) |
List<ByteBuffer> |
transceive(List<ByteBuffer> request)
Override as non-synchronized method because the method is thread safe.
|
void |
transceive(List<ByteBuffer> request,
org.apache.avro.ipc.Callback<List<ByteBuffer>> callback) |
void |
unlockChannel()
Netty channels are thread-safe, so there is no need to acquire locks.
|
void |
writeBuffers(List<ByteBuffer> buffers) |
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 org.apache.avro.ipc.Transceiver
public void unlockChannel()
unlockChannel
in class org.apache.avro.ipc.Transceiver
public void close()
close
in interface Closeable
close
in interface AutoCloseable
close
in class org.apache.avro.ipc.Transceiver
public void close(boolean awaitCompletion)
awaitCompletion
- if true, will block until the close has completed.public String getRemoteName() throws IOException
getRemoteName
in class org.apache.avro.ipc.Transceiver
IOException
public List<ByteBuffer> transceive(List<ByteBuffer> request) throws IOException
transceive
in class org.apache.avro.ipc.Transceiver
IOException
public void transceive(List<ByteBuffer> request, org.apache.avro.ipc.Callback<List<ByteBuffer>> callback) throws IOException
transceive
in class org.apache.avro.ipc.Transceiver
IOException
public void writeBuffers(List<ByteBuffer> buffers) throws IOException
writeBuffers
in class org.apache.avro.ipc.Transceiver
IOException
public List<ByteBuffer> readBuffers() throws IOException
readBuffers
in class org.apache.avro.ipc.Transceiver
IOException
public org.apache.avro.Protocol getRemote()
getRemote
in class org.apache.avro.ipc.Transceiver
public boolean isConnected()
isConnected
in class org.apache.avro.ipc.Transceiver
public void setRemote(org.apache.avro.Protocol protocol)
setRemote
in class org.apache.avro.ipc.Transceiver
Copyright © 2009–2023 The Apache Software Foundation. All rights reserved.