Top Description Inners Fields Constructors Methods
io.netty.channel.nio

public abstract Class AbstractNioChannel

extends AbstractChannel
Class Inheritance
Known Direct Subclasses
io.netty.channel.nio.AbstractNioMessageChannel, io.netty.channel.nio.AbstractNioByteChannel
Imports
io.netty.buffer.ByteBuf, .ByteBufAllocator, .ByteBufUtil, .Unpooled, io.netty.channel.AbstractChannel, .Channel, .ChannelException, .ChannelFuture, .ChannelFutureListener, .ChannelPromise, .ConnectTimeoutException, .EventLoop, io.netty.util.ReferenceCountUtil, .ReferenceCounted, io.netty.util.concurrent.Future, io.netty.util.internal.logging.InternalLogger, .InternalLoggerFactory, java.io.IOException, java.net.SocketAddress, java.nio.channels.CancelledKeyException, .ClosedChannelException, .ConnectionPendingException, .SelectableChannel, .SelectionKey, java.util.concurrent.TimeUnit

Abstract base class for Channel implementations which use a Selector based approach.

Nested and Inner Type Summary

Modifier and TypeClass and Description
protected abstract class
public static interface
AbstractNioChannel.NioUnsafe

Special Unsafe sub-type which allows to access the underlying SelectableChannel

Field Summary

Modifier and TypeField and Description
private final SelectableChannel
private final Runnable
private ChannelPromise
connectPromise

The future of the current connection attempt.

private Future<?>
private static final InternalLogger
protected final int
pack-priv boolean
private SocketAddress
pack-priv volatile SelectionKey

Constructor Summary

AccessConstructor and Description
protected
AbstractNioChannel(Channel
the parent Channel by which this instance was created. May be null
parent
,
SelectableChannel
the underlying SelectableChannel on which it operates
ch
,
int
the ops to set to receive data from the SelectableChannel
readInterestOp
)

Create a new instance

Method Summary

Modifier and TypeMethod and Description
protected final void
clearReadPending()

Set read pending to false.

private void
protected void
doBeginRead()

Implements abstract io.netty.channel.AbstractChannel.doBeginRead.

Schedule a read operation.
protected void
protected abstract boolean
doConnect(SocketAddress remoteAddress, SocketAddress localAddress)

Connect to the remote peer

protected void
protected abstract void
doFinishConnect()

Finish the connect

protected void
doRegister()

Overrides io.netty.channel.AbstractChannel.doRegister.

Is called after the Channel is registered with its EventLoop as part of the register process.
public NioEventLoop
protected boolean
isCompatible(EventLoop loop)

Implements abstract io.netty.channel.AbstractChannel.isCompatible.

Return true if the given EventLoop is compatible with this instance.
public boolean
isOpen()

Implements io.netty.channel.Channel.isOpen.

Returns true if the Channel is open and may get active later
protected boolean
isReadPending()

Deprecated No longer supported. No longer supported.
protected SelectableChannel
protected final ByteBuf
newDirectBuffer(ByteBuf buf)

Returns an off-heap copy of the specified ByteBuf, and releases the original one.

protected final ByteBuf
newDirectBuffer(ReferenceCounted holder, ByteBuf buf)

Returns an off-heap copy of the specified ByteBuf, and releases the specified holder.

protected SelectionKey
selectionKey()

Return the current SelectionKey

protected void
setReadPending(final boolean readPending)

Deprecated Use clearReadPending() if appropriate instead. No longer supported.
private void
setReadPending0(boolean readPending)

public AbstractNioChannel.NioUnsafe
unsafe()

Overrides io.netty.channel.AbstractChannel.unsafe.

Implements io.netty.channel.Channel.unsafe.

Returns an internal-use-only object that provides unsafe operations.
Inherited from io.netty.channel.AbstractChannel:
allocbindbindbytesBeforeUnwritablebytesBeforeWritablecloseclosecloseFuturecompareToconnectconnectconnectconnectderegisterderegisterdisconnectdisconnectdoBinddoDisconnectdoShutdownOutputdoWriteequalsfilterOutboundMessageflushhashCodeidinvalidateLocalAddressinvalidateRemoteAddressisRegisteredisWritablelocalAddresslocalAddress0maxMessagesPerWritenewChannelPipelinenewFailedFuturenewIdnewProgressivePromisenewPromisenewSucceededFuturenewUnsafeparentpipelinereadremoteAddressremoteAddress0toStringvalidateFileRegionvoidPromisewritewritewriteAndFlushwriteAndFlush

Field Detail

chback to summary
private final SelectableChannel ch
clearReadPendingRunnableback to summary
private final Runnable clearReadPendingRunnable
connectPromiseback to summary
private ChannelPromise connectPromise

The future of the current connection attempt. If not null, subsequent connection attempts will fail.

connectTimeoutFutureback to summary
private Future<?> connectTimeoutFuture
loggerback to summary
private static final InternalLogger logger

Hides io.netty.channel.AbstractChannel.logger.

readInterestOpback to summary
protected final int readInterestOp
readPendingback to summary
pack-priv boolean readPending
requestedRemoteAddressback to summary
private SocketAddress requestedRemoteAddress
selectionKeyback to summary
pack-priv volatile SelectionKey selectionKey

Constructor Detail

AbstractNioChannelback to summary
protected AbstractNioChannel(Channel parent, SelectableChannel ch, int readInterestOp)

Create a new instance

Parameters
parent:Channel

the parent Channel by which this instance was created. May be null

ch:SelectableChannel

the underlying SelectableChannel on which it operates

readInterestOp:int

the ops to set to receive data from the SelectableChannel

Method Detail

clearReadPendingback to summary
protected final void clearReadPending()

Set read pending to false.

clearReadPending0back to summary
private void clearReadPending0()
doBeginReadback to summary
protected void doBeginRead() throws Exception

Implements abstract io.netty.channel.AbstractChannel.doBeginRead.

Doc from io.netty.channel.AbstractChannel.doBeginRead.

Schedule a read operation.

Annotations
@Override
doCloseback to summary
protected void doClose() throws Exception

Implements abstract io.netty.channel.AbstractChannel.doClose.

Doc from io.netty.channel.AbstractChannel.doClose.

Close the Channel

Annotations
@Override
doConnectback to summary
protected abstract boolean doConnect(SocketAddress remoteAddress, SocketAddress localAddress) throws Exception

Connect to the remote peer

doDeregisterback to summary
protected void doDeregister() throws Exception

Overrides io.netty.channel.AbstractChannel.doDeregister.

Doc from io.netty.channel.AbstractChannel.doDeregister.

Deregister the Channel from its EventLoop. Sub-classes may override this method

Annotations
@Override
doFinishConnectback to summary
protected abstract void doFinishConnect() throws Exception

Finish the connect

doRegisterback to summary
protected void doRegister() throws Exception

Overrides io.netty.channel.AbstractChannel.doRegister.

Doc from io.netty.channel.AbstractChannel.doRegister.

Is called after the Channel is registered with its EventLoop as part of the register process. Sub-classes may override this method

Annotations
@Override
eventLoopback to summary
public NioEventLoop eventLoop()

Overrides io.netty.channel.AbstractChannel.eventLoop.

Implements io.netty.channel.Channel.eventLoop.

Doc from io.netty.channel.Channel.eventLoop.

Return the EventLoop this Channel was registered to.

Annotations
@Override
isCompatibleback to summary
protected boolean isCompatible(EventLoop loop)

Implements abstract io.netty.channel.AbstractChannel.isCompatible.

Doc from io.netty.channel.AbstractChannel.isCompatible.

Return true if the given EventLoop is compatible with this instance.

Annotations
@Override
isOpenback to summary
public boolean isOpen()

Implements io.netty.channel.Channel.isOpen.

Doc from io.netty.channel.Channel.isOpen.

Returns true if the Channel is open and may get active later

Annotations
@Override
isReadPendingback to summary
protected boolean isReadPending()

Deprecated

No longer supported. No longer supported.

Annotations
@Deprecated
javaChannelback to summary
protected SelectableChannel javaChannel()
newDirectBufferback to summary
protected final ByteBuf newDirectBuffer(ByteBuf buf)

Returns an off-heap copy of the specified ByteBuf, and releases the original one. Note that this method does not create an off-heap copy if the allocation / deallocation cost is too high, but just returns the original ByteBuf..

newDirectBufferback to summary
protected final ByteBuf newDirectBuffer(ReferenceCounted holder, ByteBuf buf)

Returns an off-heap copy of the specified ByteBuf, and releases the specified holder. The caller must ensure that the holder releases the original ByteBuf 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 original ByteBuf..

selectionKeyback to summary
protected SelectionKey selectionKey()

Return the current SelectionKey

setReadPendingback to summary
protected void setReadPending(final boolean readPending)

Deprecated

Use clearReadPending() if appropriate instead. No longer supported.

Annotations
@Deprecated
setReadPending0back to summary
private void setReadPending0(boolean readPending)
unsafeback to summary
public AbstractNioChannel.NioUnsafe unsafe()

Overrides io.netty.channel.AbstractChannel.unsafe.

Implements io.netty.channel.Channel.unsafe.

Doc from io.netty.channel.Channel.unsafe.

Returns an internal-use-only object that provides unsafe operations.

Annotations
@Override
io.netty.channel.nio back to summary

protected abstract Class AbstractNioChannel.AbstractNioUnsafe

extends AbstractUnsafe
implements NioUnsafe
Class Inheritance
All Implemented Interfaces
io.netty.channel.nio.AbstractNioChannel.NioUnsafe, io.netty.channel.Channel.Unsafe
Known Direct Subclasses
io.netty.channel.nio.AbstractNioMessageChannel.NioMessageUnsafe, io.netty.channel.nio.AbstractNioByteChannel.NioByteUnsafe

Constructor Summary

AccessConstructor and Description
protected

Method Summary

Modifier and TypeMethod and Description
public final SelectableChannel
public final void
connect(final SocketAddress remoteAddress, final SocketAddress localAddress, final ChannelPromise promise)

Implements io.netty.channel.Channel.Unsafe.connect.

Connect the Channel of the given ChannelFuture with the given remote SocketAddress.
public final void
protected final void
public final void
private void
fulfillConnectPromise(ChannelPromise promise, boolean wasActive)

private void
private boolean
protected final void
Inherited from io.netty.channel.AbstractChannel.AbstractUnsafe:
annotateConnectExceptionbeginReadbindclosecloseForciblycloseIfClosedderegisterdisconnectensureOpenflushhandleWriteErrorlocalAddressoutboundBufferprepareToCloserecvBufAllocHandleregisterremoteAddresssafeSetFailuresafeSetSuccessshutdownOutputvoidPromisewrite

Constructor Detail

AbstractNioUnsafeback to summary
protected AbstractNioUnsafe()

Method Detail

chback to summary
public final SelectableChannel ch()

Implements io.netty.channel.nio.AbstractNioChannel.NioUnsafe.ch.

Doc from io.netty.channel.nio.AbstractNioChannel.NioUnsafe.ch.

Return underlying SelectableChannel

Annotations
@Override
connectback to summary
public final void connect(final SocketAddress remoteAddress, final SocketAddress localAddress, final ChannelPromise promise)

Implements io.netty.channel.Channel.Unsafe.connect.

Doc from io.netty.channel.Channel.Unsafe.connect.

Connect the Channel of the given ChannelFuture with the given remote SocketAddress. If a specific local SocketAddress should be used it need to be given as argument. Otherwise just pass null to it. The ChannelPromise will get notified once the connect operation was complete.

Annotations
@Override
finishConnectback to summary
public final void finishConnect()

Implements io.netty.channel.nio.AbstractNioChannel.NioUnsafe.finishConnect.

Doc from io.netty.channel.nio.AbstractNioChannel.NioUnsafe.finishConnect.

Finish connect

Annotations
@Override
flush0back to summary
protected final void flush0()

Overrides io.netty.channel.AbstractChannel.AbstractUnsafe.flush0.

Annotations
@Override
forceFlushback to summary
public final void forceFlush()

Implements io.netty.channel.nio.AbstractNioChannel.NioUnsafe.forceFlush.

Annotations
@Override
fulfillConnectPromiseback to summary
private void fulfillConnectPromise(ChannelPromise promise, boolean wasActive)
fulfillConnectPromiseback to summary
private void fulfillConnectPromise(ChannelPromise promise, Throwable cause)
isFlushPendingback to summary
private boolean isFlushPending()
removeReadOpback to summary
protected final void removeReadOp()
io.netty.channel.nio back to summary

public Interface AbstractNioChannel.NioUnsafe

extends Unsafe
Known Direct Implementers
io.netty.channel.nio.AbstractNioChannel.AbstractNioUnsafe

Special Unsafe sub-type which allows to access the underlying SelectableChannel

Method Summary

Modifier and TypeMethod and Description
public SelectableChannel
ch()

Return underlying SelectableChannel

public void
finishConnect()

Finish connect

public void
public void
read()

Read from underlying SelectableChannel

Inherited from io.netty.channel.Channel.Unsafe:
beginReadbindclosecloseForciblyconnectderegisterdisconnectflushlocalAddressoutboundBufferrecvBufAllocHandleregisterremoteAddressvoidPromisewrite

Method Detail

chback to summary
public SelectableChannel ch()

Return underlying SelectableChannel

finishConnectback to summary
public void finishConnect()

Finish connect

forceFlushback to summary
public void forceFlush()
readback to summary
public void read()

Read from underlying SelectableChannel