Class CopyBytesSocketChannel
java.lang.Object
io.netty.util.DefaultAttributeMap
io.netty.channel.AbstractChannel
io.netty.channel.nio.AbstractNioChannel
io.netty.channel.nio.AbstractNioByteChannel
io.netty.channel.socket.nio.NioSocketChannel
org.elasticsearch.transport.netty4.Netty4NioSocketChannel
org.elasticsearch.transport.netty4.CopyBytesSocketChannel
- All Implemented Interfaces:
io.netty.channel.Channel,io.netty.channel.ChannelOutboundInvoker,io.netty.channel.socket.DuplexChannel,io.netty.channel.socket.SocketChannel,io.netty.util.AttributeMap,Comparable<io.netty.channel.Channel>
This class is adapted from
NioSocketChannel class in the Netty project. It overrides the channel
read/write behavior to ensure that the bytes are always copied to a thread-local direct bytes buffer. This
happens BEFORE the call to the Java SocketChannel is issued.
The purpose of this class is to allow the disabling of netty direct buffer pooling while allowing us to
control how bytes end up being copied to direct memory. If we simply disabled netty pooling, we would rely
on the JDK's internal thread local buffer pooling. Instead, this class allows us to create a one thread
local buffer with a defined size.-
Nested Class Summary
Nested classes/interfaces inherited from class io.netty.channel.nio.AbstractNioByteChannel
io.netty.channel.nio.AbstractNioByteChannel.NioByteUnsafeNested classes/interfaces inherited from class io.netty.channel.nio.AbstractNioChannel
io.netty.channel.nio.AbstractNioChannel.AbstractNioUnsafe, io.netty.channel.nio.AbstractNioChannel.NioUnsafeNested classes/interfaces inherited from class io.netty.channel.AbstractChannel
io.netty.channel.AbstractChannel.AbstractUnsafeNested classes/interfaces inherited from interface io.netty.channel.Channel
io.netty.channel.Channel.Unsafe -
Field Summary
Fields inherited from class io.netty.channel.nio.AbstractNioChannel
readInterestOp -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionprotected intdoReadBytes(io.netty.buffer.ByteBuf byteBuf) protected voiddoWrite(io.netty.channel.ChannelOutboundBuffer in) protected intreadFromSocketChannel(SocketChannel socketChannel, ByteBuffer buffer) protected intwriteToSocketChannel(SocketChannel socketChannel, ByteBuffer buffer) Methods inherited from class org.elasticsearch.transport.netty4.Netty4NioSocketChannel
javaChannelMethods inherited from class io.netty.channel.socket.nio.NioSocketChannel
config, doBind, doClose, doConnect, doDisconnect, doFinishConnect, doShutdownOutput, doWriteBytes, doWriteFileRegion, isActive, isInputShutdown, isInputShutdown0, isOutputShutdown, isShutdown, localAddress, localAddress0, newUnsafe, parent, remoteAddress, remoteAddress0, shutdown, shutdown, shutdownInput, shutdownInput, shutdownOutput, shutdownOutputMethods inherited from class io.netty.channel.nio.AbstractNioByteChannel
clearOpWrite, doWrite0, filterOutboundMessage, incompleteWrite, metadata, setOpWriteMethods inherited from class io.netty.channel.nio.AbstractNioChannel
clearReadPending, doBeginRead, doDeregister, doRegister, eventLoop, isCompatible, isOpen, isReadPending, newDirectBuffer, newDirectBuffer, selectionKey, setReadPending, unsafeMethods inherited from class io.netty.channel.AbstractChannel
alloc, bind, bind, bytesBeforeUnwritable, bytesBeforeWritable, close, close, closeFuture, compareTo, connect, connect, connect, connect, deregister, deregister, disconnect, disconnect, equals, flush, hashCode, id, invalidateLocalAddress, invalidateRemoteAddress, isRegistered, isWritable, maxMessagesPerWrite, newChannelPipeline, newFailedFuture, newId, newProgressivePromise, newPromise, newSucceededFuture, pipeline, read, toString, validateFileRegion, voidPromise, write, write, writeAndFlush, writeAndFlushMethods inherited from class io.netty.util.DefaultAttributeMap
attr, hasAttrMethods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, waitMethods inherited from interface io.netty.util.AttributeMap
attr, hasAttrMethods inherited from interface io.netty.channel.Channel
alloc, bytesBeforeUnwritable, bytesBeforeWritable, closeFuture, eventLoop, flush, id, isOpen, isRegistered, isWritable, metadata, pipeline, read, unsafeMethods inherited from interface io.netty.channel.ChannelOutboundInvoker
bind, bind, close, close, connect, connect, connect, connect, deregister, deregister, disconnect, disconnect, newFailedFuture, newProgressivePromise, newPromise, newSucceededFuture, voidPromise, write, write, writeAndFlush, writeAndFlushMethods inherited from interface java.lang.Comparable
compareTo
-
Constructor Details
-
CopyBytesSocketChannel
public CopyBytesSocketChannel()
-
-
Method Details
-
doWrite
- Overrides:
doWritein classio.netty.channel.socket.nio.NioSocketChannel- Throws:
Exception
-
doReadBytes
- Overrides:
doReadBytesin classio.netty.channel.socket.nio.NioSocketChannel- Throws:
Exception
-
writeToSocketChannel
protected int writeToSocketChannel(SocketChannel socketChannel, ByteBuffer buffer) throws IOException - Throws:
IOException
-
readFromSocketChannel
protected int readFromSocketChannel(SocketChannel socketChannel, ByteBuffer buffer) throws IOException - Throws:
IOException
-