final class NettyStream extends java.lang.Object implements Stream
Modifier and Type | Class and Description |
---|---|
private static class |
NettyStream.FutureAsyncCompletionHandler<T> |
private class |
NettyStream.InboundBufferHandler |
private static class |
NettyStream.PendingReader |
Modifier and Type | Field and Description |
---|---|
private ServerAddress |
address |
private io.netty.buffer.ByteBufAllocator |
allocator |
private io.netty.channel.Channel |
channel |
private boolean |
isClosed |
private java.lang.Throwable |
pendingException |
private java.util.LinkedList<io.netty.buffer.ByteBuf> |
pendingInboundBuffers |
private NettyStream.PendingReader |
pendingReader |
private static java.lang.String |
READ_HANDLER_NAME |
private SocketSettings |
settings |
private java.lang.Class<? extends io.netty.channel.socket.SocketChannel> |
socketChannelClass |
private SslSettings |
sslSettings |
private io.netty.channel.EventLoopGroup |
workerGroup |
Constructor and Description |
---|
NettyStream(ServerAddress address,
SocketSettings settings,
SslSettings sslSettings,
io.netty.channel.EventLoopGroup workerGroup,
java.lang.Class<? extends io.netty.channel.socket.SocketChannel> socketChannelClass,
io.netty.buffer.ByteBufAllocator allocator) |
Modifier and Type | Method and Description |
---|---|
private void |
adjustTimeout(boolean disable) |
void |
close()
Closes the connection.
|
private void |
disableReadTimeout() |
ServerAddress |
getAddress()
The address that this stream is connected to.
|
io.netty.buffer.ByteBufAllocator |
getAllocator() |
ByteBuf |
getBuffer(int size)
Gets a buffer with the givens capacity.
|
SocketSettings |
getSettings() |
java.lang.Class<? extends io.netty.channel.socket.SocketChannel> |
getSocketChannelClass() |
SslSettings |
getSslSettings() |
io.netty.channel.EventLoopGroup |
getWorkerGroup() |
private void |
handleReadResponse(io.netty.buffer.ByteBuf buffer,
java.lang.Throwable t) |
private boolean |
hasBytesAvailable(int numBytes) |
boolean |
isClosed()
Returns the closed state of the connection
|
void |
open()
Open the stream.
|
void |
openAsync(AsyncCompletionHandler<java.lang.Void> handler)
Open the stream asynchronously.
|
ByteBuf |
read(int numBytes)
Read from the stream, blocking until the requested number of bytes have been read.
|
void |
readAsync(int numBytes,
AsyncCompletionHandler<ByteBuf> handler)
Read from the stream, asynchronously.
|
private void |
scheduleReadTimeout() |
void |
write(java.util.List<ByteBuf> buffers)
Write each buffer in the list to the stream in order, blocking until all are completely written.
|
void |
writeAsync(java.util.List<ByteBuf> buffers,
AsyncCompletionHandler<java.lang.Void> handler)
Write each buffer in the list to the stream in order, asynchronously.
|
private static final java.lang.String READ_HANDLER_NAME
private final ServerAddress address
private final SocketSettings settings
private final SslSettings sslSettings
private final io.netty.channel.EventLoopGroup workerGroup
private final java.lang.Class<? extends io.netty.channel.socket.SocketChannel> socketChannelClass
private final io.netty.buffer.ByteBufAllocator allocator
private volatile boolean isClosed
private volatile io.netty.channel.Channel channel
private final java.util.LinkedList<io.netty.buffer.ByteBuf> pendingInboundBuffers
private volatile NettyStream.PendingReader pendingReader
private volatile java.lang.Throwable pendingException
public NettyStream(ServerAddress address, SocketSettings settings, SslSettings sslSettings, io.netty.channel.EventLoopGroup workerGroup, java.lang.Class<? extends io.netty.channel.socket.SocketChannel> socketChannelClass, io.netty.buffer.ByteBufAllocator allocator)
public ByteBuf getBuffer(int size)
BufferProvider
getBuffer
in interface BufferProvider
size
- the size required for the bufferpublic void open() throws java.io.IOException
Stream
public void openAsync(AsyncCompletionHandler<java.lang.Void> handler)
Stream
public void write(java.util.List<ByteBuf> buffers) throws java.io.IOException
Stream
public ByteBuf read(int numBytes) throws java.io.IOException
Stream
public void writeAsync(java.util.List<ByteBuf> buffers, AsyncCompletionHandler<java.lang.Void> handler)
Stream
writeAsync
in interface Stream
buffers
- the buffers to writehandler
- invoked when the read operation has completedpublic void readAsync(int numBytes, AsyncCompletionHandler<ByteBuf> handler)
Stream
private boolean hasBytesAvailable(int numBytes)
private void handleReadResponse(io.netty.buffer.ByteBuf buffer, java.lang.Throwable t)
public ServerAddress getAddress()
Stream
getAddress
in interface Stream
public void close()
Stream
public boolean isClosed()
Stream
public SocketSettings getSettings()
public SslSettings getSslSettings()
public io.netty.channel.EventLoopGroup getWorkerGroup()
public java.lang.Class<? extends io.netty.channel.socket.SocketChannel> getSocketChannelClass()
public io.netty.buffer.ByteBufAllocator getAllocator()
private void scheduleReadTimeout()
private void disableReadTimeout()
private void adjustTimeout(boolean disable)