Class AbstractNioChannel

All Implemented Interfaces:
Channel, ChannelOutboundInvoker, AttributeMap, Comparable<Channel>
Direct Known Subclasses:
AbstractNioByteChannel, AbstractNioMessageChannel

public abstract class AbstractNioChannel extends AbstractChannel
Abstract base class for Channel implementations which use a Selector based approach.
  • Field Details

    • logger

      private static final InternalLogger logger
    • ch

      private final SelectableChannel ch
    • readInterestOp

      protected final int readInterestOp
    • readOps

      protected final NioIoOps readOps
    • registration

      volatile IoRegistration registration
    • readPending

      boolean readPending
    • clearReadPendingRunnable

      private final Runnable clearReadPendingRunnable
    • connectPromise

      private ChannelPromise connectPromise
      The future of the current connection attempt. If not null, subsequent connection attempts will fail.
    • connectTimeoutFuture

      private Future<?> connectTimeoutFuture
    • requestedRemoteAddress

      private SocketAddress requestedRemoteAddress
  • Constructor Details

  • Method Details

    • addAndSubmit

      protected void addAndSubmit(NioIoOps addOps)
    • removeAndSubmit

      protected void removeAndSubmit(NioIoOps removeOps)
    • isOpen

      public boolean isOpen()
      Description copied from interface: Channel
      Returns true if the Channel 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 interface Channel
      Overrides:
      unsafe in class AbstractChannel
    • javaChannel

      protected SelectableChannel javaChannel()
    • selectionKey

      @Deprecated protected SelectionKey selectionKey()
      Deprecated.
      Return the current SelectionKey
    • registration

      protected IoRegistration registration()
    • isReadPending

      @Deprecated protected boolean isReadPending()
      Deprecated.
      No longer supported. No longer supported.
    • setReadPending

      @Deprecated protected void setReadPending(boolean readPending)
      Deprecated.
      Use clearReadPending() if appropriate instead. No longer supported.
    • clearReadPending

      protected final void clearReadPending()
      Set read pending to false.
    • setReadPending0

      private void setReadPending0(boolean readPending)
    • clearReadPending0

      private void clearReadPending0()
    • isCompatible

      protected boolean isCompatible(EventLoop loop)
      Description copied from class: AbstractChannel
      Return true if the given EventLoop is compatible with this instance.
      Specified by:
      isCompatible in class AbstractChannel
    • doRegister

      protected void doRegister(ChannelPromise promise)
      Description copied from class: AbstractChannel
      Is called after the Channel is registered with its EventLoop as part of the register process. Subclasses may override this method
      Overrides:
      doRegister in class AbstractChannel
      Parameters:
      promise - ChannelPromise that must be notified once done to continue the registration.
    • doDeregister

      protected void doDeregister() throws Exception
      Description copied from class: AbstractChannel
      Deregister the Channel from its EventLoop. Sub-classes may override this method
      Overrides:
      doDeregister in class AbstractChannel
      Throws:
      Exception
    • doBeginRead

      protected void doBeginRead() throws Exception
      Description copied from class: AbstractChannel
      Schedule a read operation.
      Specified by:
      doBeginRead in class AbstractChannel
      Throws:
      Exception
    • doConnect

      protected abstract boolean doConnect(SocketAddress remoteAddress, SocketAddress localAddress) throws Exception
      Connect to the remote peer
      Throws:
      Exception
    • doFinishConnect

      protected abstract void doFinishConnect() throws Exception
      Finish the connect
      Throws:
      Exception
    • newDirectBuffer

      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..
    • newDirectBuffer

      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..
    • doClose

      protected void doClose() throws Exception
      Description copied from class: AbstractChannel
      Close the Channel
      Specified by:
      doClose in class AbstractChannel
      Throws:
      Exception