Class AbstractChannel

    • Constructor Detail

      • AbstractChannel

        protected AbstractChannel​(Channel parent)
        Creates a new instance.
        Parameters:
        parent - the parent of this channel. null if there's no parent.
      • AbstractChannel

        protected AbstractChannel​(Channel parent,
                                  ChannelId id)
        Creates a new instance.
        Parameters:
        parent - the parent of this channel. null if there's no parent.
    • Method Detail

      • maxMessagesPerWrite

        protected final int maxMessagesPerWrite()
      • id

        public final ChannelId id()
        Description copied from interface: Channel
        Returns the globally unique identifier of this Channel.
        Specified by:
        id in interface Channel
      • parent

        public Channel parent()
        Description copied from interface: Channel
        Returns the parent of this channel.
        Specified by:
        parent in interface Channel
        Returns:
        the parent channel. null if this channel does not have a parent channel.
      • localAddress

        public java.net.SocketAddress localAddress()
        Description copied from interface: Channel
        Returns the local address where this channel is bound to. The returned SocketAddress is supposed to be down-cast into more concrete type such as InetSocketAddress to retrieve the detailed information.
        Specified by:
        localAddress in interface Channel
        Returns:
        the local address of this channel. null if this channel is not bound.
      • invalidateLocalAddress

        @Deprecated
        protected void invalidateLocalAddress()
        Deprecated.
        no use-case for this.
      • remoteAddress

        public java.net.SocketAddress remoteAddress()
        Description copied from interface: Channel
        Returns the remote address where this channel is connected to. The returned SocketAddress is supposed to be down-cast into more concrete type such as InetSocketAddress to retrieve the detailed information.
        Specified by:
        remoteAddress in interface Channel
        Returns:
        the remote address of this channel. null if this channel is not connected. If this channel is not connected but it can receive messages from arbitrary remote addresses (e.g. DatagramChannel, use DefaultAddressedEnvelope.recipient() to determine the origination of the received message as this method will return null.
      • invalidateRemoteAddress

        @Deprecated
        protected void invalidateRemoteAddress()
        Deprecated.
        no use-case for this.
      • closeFuture

        public ChannelFuture closeFuture()
        Description copied from interface: Channel
        Returns the ChannelFuture which will be notified when this channel is closed. This method always returns the same future instance.
        Specified by:
        closeFuture in interface Channel
      • unsafe

        public Channel.Unsafe unsafe()
        Description copied from interface: Channel
        Returns an internal-use-only object that provides unsafe operations.
        Specified by:
        unsafe in interface Channel
      • hashCode

        public final int hashCode()
        Returns the ID of this channel.
        Overrides:
        hashCode in class java.lang.Object
      • equals

        public final boolean equals​(java.lang.Object o)
        Returns true if and only if the specified object is identical with this channel (i.e: this == o).
        Overrides:
        equals in class java.lang.Object
      • compareTo

        public final int compareTo​(Channel o)
        Specified by:
        compareTo in interface java.lang.Comparable<Channel>
      • toString

        public java.lang.String toString()
        Returns the String representation of this channel. The returned string contains the ID, local address, and remote address of this channel for easier identification.
        Overrides:
        toString in class java.lang.Object
      • isCompatible

        protected abstract boolean isCompatible​(EventLoop loop)
        Return true if the given EventLoop is compatible with this instance.
      • localAddress0

        protected abstract java.net.SocketAddress localAddress0()
        Returns the SocketAddress which is bound locally.
      • remoteAddress0

        protected abstract java.net.SocketAddress remoteAddress0()
        Return the SocketAddress which the Channel is connected to.
      • doRegister

        @Deprecated
        protected void doRegister()
                           throws java.lang.Exception
        Is called after the Channel is registered with its EventLoop as part of the register process. Subclasses may override this method
        Throws:
        java.lang.Exception
      • doRegister

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

        protected abstract void doBind​(java.net.SocketAddress localAddress)
                                throws java.lang.Exception
        Bind the Channel to the SocketAddress
        Throws:
        java.lang.Exception
      • doDisconnect

        protected abstract void doDisconnect()
                                      throws java.lang.Exception
        Disconnect this Channel from its remote peer
        Throws:
        java.lang.Exception
      • doClose

        protected abstract void doClose()
                                 throws java.lang.Exception
        Close the Channel
        Throws:
        java.lang.Exception
      • doShutdownOutput

        protected void doShutdownOutput()
                                 throws java.lang.Exception
        Called when conditions justify shutting down the output portion of the channel. This may happen if a write operation throws an exception.
        Throws:
        java.lang.Exception
      • doDeregister

        protected void doDeregister()
                             throws java.lang.Exception
        Deregister the Channel from its EventLoop. Sub-classes may override this method
        Throws:
        java.lang.Exception
      • doBeginRead

        protected abstract void doBeginRead()
                                     throws java.lang.Exception
        Schedule a read operation.
        Throws:
        java.lang.Exception
      • doWrite

        protected abstract void doWrite​(ChannelOutboundBuffer in)
                                 throws java.lang.Exception
        Flush the content of the given buffer to the remote peer.
        Throws:
        java.lang.Exception
      • filterOutboundMessage

        protected java.lang.Object filterOutboundMessage​(java.lang.Object msg)
                                                  throws java.lang.Exception
        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)
        Throws:
        java.lang.Exception
      • validateFileRegion

        protected void validateFileRegion​(DefaultFileRegion region,
                                          long position)
                                   throws java.io.IOException
        Throws:
        java.io.IOException