public abstract class AbstractEpollStreamChannel extends AbstractEpollChannel implements DuplexChannel
Modifier and Type | Class and Description |
---|---|
(package private) class |
AbstractEpollStreamChannel.EpollStreamUnsafe |
private class |
AbstractEpollStreamChannel.SocketWritableByteChannel |
private class |
AbstractEpollStreamChannel.SpliceFdTask |
private class |
AbstractEpollStreamChannel.SpliceInChannelTask |
protected class |
AbstractEpollStreamChannel.SpliceInTask |
private class |
AbstractEpollStreamChannel.SpliceOutTask |
AbstractEpollChannel.AbstractEpollUnsafe
AbstractChannel.AbstractUnsafe
Channel.Unsafe
Modifier and Type | Field and Description |
---|---|
private java.nio.channels.WritableByteChannel |
byteChannel |
private static java.nio.channels.ClosedChannelException |
CLEAR_SPLICE_QUEUE_CLOSED_CHANNEL_EXCEPTION |
private ChannelPromise |
connectPromise
The future of the current connection attempt.
|
private java.util.concurrent.ScheduledFuture<?> |
connectTimeoutFuture |
private static java.nio.channels.ClosedChannelException |
DO_CLOSE_CLOSED_CHANNEL_EXCEPTION |
private static java.lang.String |
EXPECTED_TYPES |
private static java.nio.channels.ClosedChannelException |
FAIL_SPLICE_IF_CLOSED_CLOSED_CHANNEL_EXCEPTION |
private static InternalLogger |
logger |
private FileDescriptor |
pipeIn |
private FileDescriptor |
pipeOut |
private java.net.SocketAddress |
requestedRemoteAddress |
private static java.nio.channels.ClosedChannelException |
SPLICE_TO_CLOSED_CHANNEL_EXCEPTION |
private java.util.Queue<AbstractEpollStreamChannel.SpliceInTask> |
spliceQueue |
active, flags
Modifier | Constructor and Description |
---|---|
protected |
AbstractEpollStreamChannel(Channel parent,
int fd)
Deprecated.
|
protected |
AbstractEpollStreamChannel(Channel parent,
Socket fd) |
protected |
AbstractEpollStreamChannel(FileDescriptor fd)
Deprecated.
|
protected |
AbstractEpollStreamChannel(int fd)
Deprecated.
|
protected |
AbstractEpollStreamChannel(Socket fd)
Deprecated.
|
protected |
AbstractEpollStreamChannel(Socket fd,
boolean active) |
Modifier and Type | Method and Description |
---|---|
private void |
addToSpliceQueue(AbstractEpollStreamChannel.SpliceInTask task) |
private void |
addToSpliceQueue0(AbstractEpollStreamChannel.SpliceInTask task) |
private void |
clearSpliceQueue() |
protected void |
doClose()
Close the
Channel |
protected boolean |
doConnect(java.net.SocketAddress remoteAddress,
java.net.SocketAddress localAddress)
Connect to the remote peer
|
protected void |
doWrite(ChannelOutboundBuffer in)
Flush the content of the given buffer to the remote peer.
|
private boolean |
doWriteMultiple(ChannelOutboundBuffer in,
int writeSpinCount) |
protected boolean |
doWriteSingle(ChannelOutboundBuffer in,
int writeSpinCount) |
private void |
failSpliceIfClosed(ChannelPromise promise) |
protected java.lang.Object |
filterOutboundMessage(java.lang.Object msg)
Invoked when a new message is added to a
ChannelOutboundBuffer of this AbstractChannel , so that
the Channel implementation converts the message to another. |
boolean |
isInputShutdown()
Returns
true if and only if the remote peer shut down its output so that no more
data is received from this channel. |
boolean |
isOutputShutdown() |
protected AbstractEpollChannel.AbstractEpollUnsafe |
newUnsafe()
Create a new
AbstractChannel.AbstractUnsafe instance which will be used for the life-time of the Channel |
private static void |
safeClosePipe(FileDescriptor fd) |
ChannelFuture |
shutdownOutput() |
ChannelFuture |
shutdownOutput(ChannelPromise promise) |
protected void |
shutdownOutput0(ChannelPromise promise) |
ChannelFuture |
spliceTo(AbstractEpollStreamChannel ch,
int len)
Splice from this
AbstractEpollStreamChannel to another AbstractEpollStreamChannel . |
ChannelFuture |
spliceTo(AbstractEpollStreamChannel ch,
int len,
ChannelPromise promise)
Splice from this
AbstractEpollStreamChannel to another AbstractEpollStreamChannel . |
ChannelFuture |
spliceTo(FileDescriptor ch,
int offset,
int len)
Splice from this
AbstractEpollStreamChannel to another FileDescriptor . |
ChannelFuture |
spliceTo(FileDescriptor ch,
int offset,
int len,
ChannelPromise promise)
Splice from this
AbstractEpollStreamChannel to another FileDescriptor . |
private boolean |
writeBytes(ChannelOutboundBuffer in,
ByteBuf buf,
int writeSpinCount)
Write bytes form the given
ByteBuf to the underlying Channel . |
private boolean |
writeBytesMultiple(ChannelOutboundBuffer in,
java.nio.ByteBuffer[] nioBuffers,
int nioBufferCnt,
long expectedWrittenBytes,
int writeSpinCount) |
private boolean |
writeBytesMultiple(ChannelOutboundBuffer in,
IovArray array,
int writeSpinCount) |
private boolean |
writeDefaultFileRegion(ChannelOutboundBuffer in,
DefaultFileRegion region,
int writeSpinCount)
Write a
DefaultFileRegion |
private boolean |
writeFileRegion(ChannelOutboundBuffer in,
FileRegion region,
int writeSpinCount) |
checkResolvable, clearEpollIn, clearFlag, config, doBeginRead, doDeregister, doDisconnect, doReadBytes, doRegister, doWriteBytes, fd, isActive, isCompatible, isFlagSet, isOpen, isSoErrorZero, metadata, newDirectBuffer, newDirectBuffer, setFlag
alloc, bind, bind, close, close, closeFuture, compareTo, connect, connect, connect, connect, deregister, deregister, disconnect, disconnect, doBind, equals, eventLoop, flush, hashCode, invalidateLocalAddress, invalidateRemoteAddress, isRegistered, isWritable, localAddress, localAddress0, newChannelPipeline, newFailedFuture, newProgressivePromise, newPromise, newSucceededFuture, parent, pipeline, read, remoteAddress, remoteAddress0, toString, unsafe, voidPromise, write, write, writeAndFlush, writeAndFlush
attr
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
alloc, bind, bind, close, close, closeFuture, config, connect, connect, connect, connect, deregister, deregister, disconnect, disconnect, eventLoop, flush, isActive, isOpen, isRegistered, isWritable, localAddress, metadata, newFailedFuture, newProgressivePromise, newPromise, newSucceededFuture, parent, pipeline, read, remoteAddress, unsafe, voidPromise, write, write, writeAndFlush, writeAndFlush
attr
private static final java.lang.String EXPECTED_TYPES
private static final InternalLogger logger
private static final java.nio.channels.ClosedChannelException DO_CLOSE_CLOSED_CHANNEL_EXCEPTION
private static final java.nio.channels.ClosedChannelException CLEAR_SPLICE_QUEUE_CLOSED_CHANNEL_EXCEPTION
private static final java.nio.channels.ClosedChannelException SPLICE_TO_CLOSED_CHANNEL_EXCEPTION
private static final java.nio.channels.ClosedChannelException FAIL_SPLICE_IF_CLOSED_CLOSED_CHANNEL_EXCEPTION
private ChannelPromise connectPromise
private java.util.concurrent.ScheduledFuture<?> connectTimeoutFuture
private java.net.SocketAddress requestedRemoteAddress
private java.util.Queue<AbstractEpollStreamChannel.SpliceInTask> spliceQueue
private FileDescriptor pipeIn
private FileDescriptor pipeOut
private java.nio.channels.WritableByteChannel byteChannel
@Deprecated protected AbstractEpollStreamChannel(Channel parent, int fd)
AbstractEpollStreamChannel(Channel, Socket)
.@Deprecated protected AbstractEpollStreamChannel(int fd)
AbstractEpollStreamChannel(Socket, boolean)
.@Deprecated protected AbstractEpollStreamChannel(FileDescriptor fd)
AbstractEpollStreamChannel(Socket, boolean)
.@Deprecated protected AbstractEpollStreamChannel(Socket fd)
AbstractEpollStreamChannel(Socket, boolean)
.protected AbstractEpollStreamChannel(Socket fd, boolean active)
protected AbstractEpollChannel.AbstractEpollUnsafe newUnsafe()
AbstractChannel
AbstractChannel.AbstractUnsafe
instance which will be used for the life-time of the Channel
newUnsafe
in class AbstractEpollChannel
public final ChannelFuture spliceTo(AbstractEpollStreamChannel ch, int len)
AbstractEpollStreamChannel
to another AbstractEpollStreamChannel
.
The len
is the number of bytes to splice. If using Integer.MAX_VALUE
it will
splice until the ChannelFuture
was canceled or it was failed.
Please note:
EventLoop
, otherwise an
IllegalArgumentException
is thrown. EpollChannelConfig.getEpollMode()
must be EpollMode.LEVEL_TRIGGERED
for this and the
target AbstractEpollStreamChannel
public final ChannelFuture spliceTo(AbstractEpollStreamChannel ch, int len, ChannelPromise promise)
AbstractEpollStreamChannel
to another AbstractEpollStreamChannel
.
The len
is the number of bytes to splice. If using Integer.MAX_VALUE
it will
splice until the ChannelFuture
was canceled or it was failed.
Please note:
EventLoop
, otherwise an
IllegalArgumentException
is thrown. EpollChannelConfig.getEpollMode()
must be EpollMode.LEVEL_TRIGGERED
for this and the
target AbstractEpollStreamChannel
public final ChannelFuture spliceTo(FileDescriptor ch, int offset, int len)
AbstractEpollStreamChannel
to another FileDescriptor
.
The offset
is the offset for the FileDescriptor
and len
is the
number of bytes to splice. If using Integer.MAX_VALUE
it will splice until the
ChannelFuture
was canceled or it was failed.
Please note:
EpollChannelConfig.getEpollMode()
must be EpollMode.LEVEL_TRIGGERED
for this
AbstractEpollStreamChannel
FileDescriptor
will not be closed after the ChannelFuture
is notifiedIllegalStateException
will be thrown.public final ChannelFuture spliceTo(FileDescriptor ch, int offset, int len, ChannelPromise promise)
AbstractEpollStreamChannel
to another FileDescriptor
.
The offset
is the offset for the FileDescriptor
and len
is the
number of bytes to splice. If using Integer.MAX_VALUE
it will splice until the
ChannelFuture
was canceled or it was failed.
Please note:
EpollChannelConfig.getEpollMode()
must be EpollMode.LEVEL_TRIGGERED
for this
AbstractEpollStreamChannel
FileDescriptor
will not be closed after the ChannelPromise
is notifiedIllegalStateException
will be thrown.private void failSpliceIfClosed(ChannelPromise promise)
private boolean writeBytes(ChannelOutboundBuffer in, ByteBuf buf, int writeSpinCount) throws java.lang.Exception
ByteBuf
to the underlying Channel
.buf
- the ByteBuf
from which the bytes should be writtenjava.lang.Exception
private boolean writeBytesMultiple(ChannelOutboundBuffer in, IovArray array, int writeSpinCount) throws java.io.IOException
java.io.IOException
private boolean writeBytesMultiple(ChannelOutboundBuffer in, java.nio.ByteBuffer[] nioBuffers, int nioBufferCnt, long expectedWrittenBytes, int writeSpinCount) throws java.io.IOException
java.io.IOException
private boolean writeDefaultFileRegion(ChannelOutboundBuffer in, DefaultFileRegion region, int writeSpinCount) throws java.lang.Exception
DefaultFileRegion
region
- the DefaultFileRegion
from which the bytes should be writtenjava.lang.Exception
private boolean writeFileRegion(ChannelOutboundBuffer in, FileRegion region, int writeSpinCount) throws java.lang.Exception
java.lang.Exception
protected void doWrite(ChannelOutboundBuffer in) throws java.lang.Exception
AbstractChannel
doWrite
in class AbstractChannel
java.lang.Exception
protected boolean doWriteSingle(ChannelOutboundBuffer in, int writeSpinCount) throws java.lang.Exception
java.lang.Exception
private boolean doWriteMultiple(ChannelOutboundBuffer in, int writeSpinCount) throws java.lang.Exception
java.lang.Exception
protected java.lang.Object filterOutboundMessage(java.lang.Object msg)
AbstractChannel
ChannelOutboundBuffer
of this AbstractChannel
, so that
the Channel
implementation converts the message to another. (e.g. heap buffer -> direct buffer)filterOutboundMessage
in class AbstractChannel
protected void shutdownOutput0(ChannelPromise promise)
public boolean isInputShutdown()
DuplexChannel
true
if and only if the remote peer shut down its output so that no more
data is received from this channel. Note that the semantic of this method is different from
that of Socket.shutdownInput()
and Socket.isInputShutdown()
.isInputShutdown
in interface DuplexChannel
public boolean isOutputShutdown()
isOutputShutdown
in interface DuplexChannel
Socket.isOutputShutdown()
public ChannelFuture shutdownOutput()
shutdownOutput
in interface DuplexChannel
Socket.shutdownOutput()
public ChannelFuture shutdownOutput(ChannelPromise promise)
shutdownOutput
in interface DuplexChannel
Will notify the given {@link ChannelPromise}
protected void doClose() throws java.lang.Exception
AbstractChannel
Channel
doClose
in class AbstractEpollChannel
java.lang.Exception
private void clearSpliceQueue()
protected boolean doConnect(java.net.SocketAddress remoteAddress, java.net.SocketAddress localAddress) throws java.lang.Exception
java.lang.Exception
private static void safeClosePipe(FileDescriptor fd)
private void addToSpliceQueue(AbstractEpollStreamChannel.SpliceInTask task)
private void addToSpliceQueue0(AbstractEpollStreamChannel.SpliceInTask task)