Package io.netty.channel.nio
Class AbstractNioChannel
java.lang.Object
io.netty.util.DefaultAttributeMap
io.netty.channel.AbstractChannel
io.netty.channel.nio.AbstractNioChannel
- All Implemented Interfaces:
Channel
,ChannelOutboundInvoker
,AttributeMap
,Comparable<Channel>
- Direct Known Subclasses:
AbstractNioByteChannel
,AbstractNioMessageChannel
Abstract base class for
Channel
implementations which use a Selector based approach.-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionprotected class
static interface
SpecialChannel.Unsafe
sub-type which allows to access the underlyingSelectableChannel
Nested classes/interfaces inherited from class io.netty.channel.AbstractChannel
AbstractChannel.AbstractUnsafe
Nested classes/interfaces inherited from interface io.netty.channel.Channel
Channel.Unsafe
-
Field Summary
FieldsModifier and TypeFieldDescriptionprivate final SelectableChannel
private final Runnable
private ChannelPromise
The future of the current connection attempt.private Future
<?> private static final InternalLogger
protected final int
(package private) boolean
private SocketAddress
(package private) SelectionKey
-
Constructor Summary
ConstructorsModifierConstructorDescriptionprotected
AbstractNioChannel
(Channel parent, SelectableChannel ch, int readInterestOp) Create a new instance -
Method Summary
Modifier and TypeMethodDescriptionprotected final void
Set read pending tofalse
.private void
protected void
Schedule a read operation.protected void
doClose()
Close theChannel
protected abstract boolean
doConnect
(SocketAddress remoteAddress, SocketAddress localAddress) Connect to the remote peerprotected void
protected abstract void
Finish the connectprotected void
protected boolean
isCompatible
(EventLoop loop) Returntrue
if the givenEventLoop
is compatible with this instance.boolean
isOpen()
Returnstrue
if theChannel
is open and may get active laterprotected boolean
Deprecated.No longer supported.protected SelectableChannel
protected final ByteBuf
newDirectBuffer
(ByteBuf buf) Returns an off-heap copy of the specifiedByteBuf
, and releases the original one.protected final ByteBuf
newDirectBuffer
(ReferenceCounted holder, ByteBuf buf) Returns an off-heap copy of the specifiedByteBuf
, and releases the specified holder.protected SelectionKey
Return the currentSelectionKey
protected void
setReadPending
(boolean readPending) Deprecated.UseclearReadPending()
if appropriate instead.private void
setReadPending0
(boolean readPending) unsafe()
Returns an internal-use-only object that provides unsafe operations.Methods inherited from class io.netty.channel.AbstractChannel
alloc, bind, bind, bytesBeforeUnwritable, bytesBeforeWritable, close, close, closeFuture, compareTo, connect, connect, connect, connect, deregister, deregister, disconnect, disconnect, doBind, doDisconnect, doShutdownOutput, doWrite, equals, filterOutboundMessage, flush, hashCode, id, invalidateLocalAddress, invalidateRemoteAddress, isRegistered, isWritable, localAddress, localAddress0, maxMessagesPerWrite, newChannelPipeline, newFailedFuture, newId, newProgressivePromise, newPromise, newSucceededFuture, newUnsafe, parent, pipeline, read, remoteAddress, remoteAddress0, toString, validateFileRegion, voidPromise, write, write, writeAndFlush, writeAndFlush
Methods inherited from class io.netty.util.DefaultAttributeMap
attr, hasAttr
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
Methods inherited from interface io.netty.util.AttributeMap
attr, hasAttr
-
Field Details
-
logger
-
ch
-
readInterestOp
protected final int readInterestOp -
selectionKey
-
readPending
boolean readPending -
clearReadPendingRunnable
-
connectPromise
The future of the current connection attempt. If not null, subsequent connection attempts will fail. -
connectTimeoutFuture
-
requestedRemoteAddress
-
-
Constructor Details
-
AbstractNioChannel
Create a new instance- Parameters:
parent
- the parentChannel
by which this instance was created. May benull
ch
- the underlyingSelectableChannel
on which it operatesreadInterestOp
- the ops to set to receive data from theSelectableChannel
-
-
Method Details
-
isOpen
public boolean isOpen()Description copied from interface:Channel
Returnstrue
if theChannel
is open and may get active later -
unsafe
Description copied from interface:Channel
Returns an internal-use-only object that provides unsafe operations.- Specified by:
unsafe
in interfaceChannel
- Overrides:
unsafe
in classAbstractChannel
-
javaChannel
-
eventLoop
Description copied from interface:Channel
- Specified by:
eventLoop
in interfaceChannel
- Overrides:
eventLoop
in classAbstractChannel
-
selectionKey
Return the currentSelectionKey
-
isReadPending
Deprecated.No longer supported. No longer supported. -
setReadPending
Deprecated.UseclearReadPending()
if appropriate instead. No longer supported. -
clearReadPending
protected final void clearReadPending()Set read pending tofalse
. -
setReadPending0
private void setReadPending0(boolean readPending) -
clearReadPending0
private void clearReadPending0() -
isCompatible
Description copied from class:AbstractChannel
Returntrue
if the givenEventLoop
is compatible with this instance.- Specified by:
isCompatible
in classAbstractChannel
-
doRegister
Description copied from class:AbstractChannel
Is called after theChannel
is registered with itsEventLoop
as part of the register process. Sub-classes may override this method- Overrides:
doRegister
in classAbstractChannel
- Throws:
Exception
-
doDeregister
Description copied from class:AbstractChannel
- Overrides:
doDeregister
in classAbstractChannel
- Throws:
Exception
-
doBeginRead
Description copied from class:AbstractChannel
Schedule a read operation.- Specified by:
doBeginRead
in classAbstractChannel
- Throws:
Exception
-
doConnect
protected abstract boolean doConnect(SocketAddress remoteAddress, SocketAddress localAddress) throws Exception Connect to the remote peer- Throws:
Exception
-
doFinishConnect
Finish the connect- Throws:
Exception
-
newDirectBuffer
-
newDirectBuffer
Returns an off-heap copy of the specifiedByteBuf
, and releases the specified holder. The caller must ensure that the holder releases the originalByteBuf
when the holder is released by this method. Note that this method does not create an off-heap copy if the allocation / deallocation cost is too high, but just returns the originalByteBuf
.. -
doClose
Description copied from class:AbstractChannel
Close theChannel
- Specified by:
doClose
in classAbstractChannel
- Throws:
Exception
-