Class AbstractNioByteChannel

All Implemented Interfaces:
Channel, ChannelOutboundInvoker, AttributeMap, java.lang.Comparable<Channel>
Direct Known Subclasses:
NioDomainSocketChannel, NioSocketChannel

public abstract class AbstractNioByteChannel extends AbstractNioChannel
AbstractNioChannel base class for Channels that operate on bytes.
  • Field Details

    • METADATA

      private static final ChannelMetadata METADATA
    • EXPECTED_TYPES

      private static final java.lang.String EXPECTED_TYPES
    • flushTask

      private final java.lang.Runnable flushTask
    • inputClosedSeenErrorOnRead

      private boolean inputClosedSeenErrorOnRead
  • Constructor Details

    • AbstractNioByteChannel

      protected AbstractNioByteChannel(Channel parent, java.nio.channels.SelectableChannel ch)
      Create a new instance
      Parameters:
      parent - the parent Channel by which this instance was created. May be null
      ch - the underlying SelectableChannel on which it operates
  • Method Details

    • shutdownInput

      protected abstract ChannelFuture shutdownInput()
      Shutdown the input side of the channel.
    • isInputShutdown0

      protected boolean isInputShutdown0()
    • newUnsafe

      protected AbstractNioChannel.AbstractNioUnsafe newUnsafe()
      Description copied from class: AbstractChannel
      Create a new AbstractChannel.AbstractUnsafe instance which will be used for the life-time of the Channel
      Specified by:
      newUnsafe in class AbstractChannel
    • metadata

      public ChannelMetadata metadata()
      Description copied from interface: Channel
      Return the ChannelMetadata of the Channel which describe the nature of the Channel.
    • shouldBreakReadReady

      final boolean shouldBreakReadReady(ChannelConfig config)
    • isAllowHalfClosure

      private static boolean isAllowHalfClosure(ChannelConfig config)
    • doWrite0

      protected final int doWrite0(ChannelOutboundBuffer in) throws java.lang.Exception
      Write objects to the OS.
      Parameters:
      in - the collection which contains objects to write.
      Returns:
      The value that should be decremented from the write quantum which starts at ChannelConfig.getWriteSpinCount(). The typical use cases are as follows:
      • 0 - if no write was attempted. This is appropriate if an empty ByteBuf (or other empty content) is encountered
      • 1 - if a single call to write data was made to the OS
      • ChannelUtils.WRITE_STATUS_SNDBUF_FULL - if an attempt to write data was made to the OS, but no data was accepted
      Throws:
      java.lang.Exception - if an I/O exception occurs during write.
    • doWriteInternal

      private int doWriteInternal(ChannelOutboundBuffer in, java.lang.Object msg) throws java.lang.Exception
      Throws:
      java.lang.Exception
    • doWrite

      protected void doWrite(ChannelOutboundBuffer in) throws java.lang.Exception
      Description copied from class: AbstractChannel
      Flush the content of the given buffer to the remote peer.
      Specified by:
      doWrite in class AbstractChannel
      Throws:
      java.lang.Exception
    • filterOutboundMessage

      protected final java.lang.Object filterOutboundMessage(java.lang.Object msg)
      Description copied from class: AbstractChannel
      Invoked when a new message is added to a ChannelOutboundBuffer of this AbstractChannel, so that the Channel implementation converts the message to another. (e.g. heap buffer -> direct buffer)
      Overrides:
      filterOutboundMessage in class AbstractChannel
    • incompleteWrite

      protected final void incompleteWrite(boolean setOpWrite)
    • doWriteFileRegion

      protected abstract long doWriteFileRegion(FileRegion region) throws java.lang.Exception
      Write a FileRegion
      Parameters:
      region - the FileRegion from which the bytes should be written
      Returns:
      amount the amount of written bytes
      Throws:
      java.lang.Exception
    • doReadBytes

      protected abstract int doReadBytes(ByteBuf buf) throws java.lang.Exception
      Read bytes into the given ByteBuf and return the amount.
      Throws:
      java.lang.Exception
    • doWriteBytes

      protected abstract int doWriteBytes(ByteBuf buf) throws java.lang.Exception
      Write bytes form the given ByteBuf to the underlying Channel.
      Parameters:
      buf - the ByteBuf from which the bytes should be written
      Returns:
      amount the amount of written bytes
      Throws:
      java.lang.Exception
    • setOpWrite

      protected final void setOpWrite()
    • clearOpWrite

      protected final void clearOpWrite()