public class NettyTcpTransport extends Object implements Transport
| Modifier and Type | Class and Description |
|---|---|
protected class |
NettyTcpTransport.NettyDefaultHandler<E> |
protected class |
NettyTcpTransport.NettyTcpTransportHandler |
| Modifier and Type | Field and Description |
|---|---|
protected io.netty.bootstrap.Bootstrap |
bootstrap |
protected io.netty.channel.Channel |
channel |
static int |
DEFAULT_MAX_FRAME_SIZE |
protected io.netty.channel.EventLoopGroup |
group |
protected ThreadFactory |
ioThreadfactory |
protected TransportListener |
listener |
protected int |
maxFrameSize |
static int |
SHUTDOWN_TIMEOUT |
| Constructor and Description |
|---|
NettyTcpTransport(TransportListener listener,
URI remoteLocation,
TransportOptions options,
boolean secure)
Create a new transport instance
|
NettyTcpTransport(URI remoteLocation,
TransportOptions options,
boolean secure)
Create a new transport instance
|
| Modifier and Type | Method and Description |
|---|---|
protected void |
addAdditionalHandlers(io.netty.channel.ChannelPipeline pipeline) |
io.netty.buffer.ByteBuf |
allocateSendBuffer(int size)
Request that the Transport provide an output buffer sized for the given
value.
|
protected void |
checkConnected() |
void |
close()
Close the Transport, no additional send operations are accepted.
|
ScheduledExecutorService |
connect(Runnable initRoutine,
SSLContext sslContextOverride)
Performs the connect operation for the implemented Transport type
such as a TCP socket connection, SSL/TLS handshake etc.
|
protected io.netty.channel.ChannelInboundHandlerAdapter |
createChannelHandler() |
void |
flush()
Request a flush of all pending writes to the underlying connection.
|
Principal |
getLocalPrincipal() |
int |
getMaxFrameSize()
Returns the currently configured maximum frame size setting.
|
protected String |
getRemoteHost() |
URI |
getRemoteLocation() |
protected int |
getRemotePort() |
ThreadFactory |
getThreadFactory() |
TransportListener |
getTransportListener()
Gets the currently set TransportListener instance
|
TransportOptions |
getTransportOptions() |
protected void |
handleChannelInactive(io.netty.channel.Channel channel) |
protected void |
handleConnected(io.netty.channel.Channel channel) |
protected void |
handleException(io.netty.channel.Channel channel,
Throwable cause) |
boolean |
isConnected() |
boolean |
isSecure() |
void |
setMaxFrameSize(int maxFrameSize)
Sets the Maximum Frame Size the transport should accept from the remote.
|
void |
setThreadFactory(ThreadFactory factory)
Sets the
ThreadFactory that the Transport should use when creating the Transport
IO thread for processing. |
void |
setTransportListener(TransportListener listener)
Sets the Transport Listener instance that will be notified of incoming data or
error events.
|
void |
write(io.netty.buffer.ByteBuf output)
Writes a chunk of data over the Transport connection without performing an
explicit flush on the transport.
|
void |
writeAndFlush(io.netty.buffer.ByteBuf output)
Writes a chunk of data over the Transport connection and requests a flush of
all pending queued write operations
|
public static final int SHUTDOWN_TIMEOUT
public static final int DEFAULT_MAX_FRAME_SIZE
protected io.netty.bootstrap.Bootstrap bootstrap
protected io.netty.channel.EventLoopGroup group
protected io.netty.channel.Channel channel
protected TransportListener listener
protected ThreadFactory ioThreadfactory
protected int maxFrameSize
public NettyTcpTransport(URI remoteLocation, TransportOptions options, boolean secure)
remoteLocation - the URI that defines the remote resource to connect to.options - the transport options used to configure the socket connection.secure - should the transport enable an SSL layer.public NettyTcpTransport(TransportListener listener, URI remoteLocation, TransportOptions options, boolean secure)
listener - the TransportListener that will receive events from this Transport.remoteLocation - the URI that defines the remote resource to connect to.options - the transport options used to configure the socket connection.secure - should the transport enable an SSL layer.public ScheduledExecutorService connect(Runnable initRoutine, SSLContext sslContextOverride) throws IOException
Transportconnect in interface TransportinitRoutine - a runnable initialization method that is executed in the context
of the transport's IO thread to allow thread safe setup of resources
that will be run from the transport executor service.sslContextOverride - a user-provided SSLContext to use if establishing a secure
connection, overrides applicable URI configurationIOException - if an error occurs while attempting the connect.public boolean isConnected()
isConnected in interface Transportpublic boolean isSecure()
public void close()
throws IOException
Transportclose in interface TransportIOException - if an error occurs while closing the connection.public io.netty.buffer.ByteBuf allocateSendBuffer(int size)
throws IOException
TransportallocateSendBuffer in interface Transportsize - the size necessary to hold the outgoing bytes.IOException - if an error occurs while allocating the send buffer.public void write(io.netty.buffer.ByteBuf output)
throws IOException
Transportwrite in interface Transportoutput - The buffer of data that is to be transmitted.IOException - if an error occurs during the write operation.public void writeAndFlush(io.netty.buffer.ByteBuf output)
throws IOException
TransportwriteAndFlush in interface Transportoutput - The buffer of data that is to be transmitted.IOException - if an error occurs during the write operation.public void flush()
throws IOException
Transportflush in interface TransportIOException - if an error occurs during the flush operation.public TransportListener getTransportListener()
TransportgetTransportListener in interface Transportpublic void setTransportListener(TransportListener listener)
TransportsetTransportListener in interface Transportlistener - The new TransportListener instance to use (cannot be null).public TransportOptions getTransportOptions()
getTransportOptions in interface Transportpublic URI getRemoteLocation()
getRemoteLocation in interface Transportpublic Principal getLocalPrincipal()
getLocalPrincipal in interface Transportpublic void setMaxFrameSize(int maxFrameSize)
TransportsetMaxFrameSize in interface TransportmaxFrameSize - The maximum frame size to accept from the remote.public int getMaxFrameSize()
TransportgetMaxFrameSize in interface Transportpublic ThreadFactory getThreadFactory()
getThreadFactory in interface TransportThreadFactory used to create the IO thread for this Transportpublic void setThreadFactory(ThreadFactory factory)
TransportThreadFactory that the Transport should use when creating the Transport
IO thread for processing.setThreadFactory in interface Transportfactory - The ThreadFactoryprotected String getRemoteHost()
protected int getRemotePort()
protected void addAdditionalHandlers(io.netty.channel.ChannelPipeline pipeline)
protected io.netty.channel.ChannelInboundHandlerAdapter createChannelHandler()
protected void handleConnected(io.netty.channel.Channel channel)
throws Exception
Exceptionprotected void handleChannelInactive(io.netty.channel.Channel channel)
throws Exception
Exceptionprotected void handleException(io.netty.channel.Channel channel,
Throwable cause)
throws Exception
Exceptionprotected final void checkConnected()
throws IOException
IOExceptionCopyright © 2013–2019 The Apache Software Foundation. All rights reserved.