Class FrameDecoder

java.lang.Object
io.netty.channel.ChannelHandlerAdapter
io.netty.channel.ChannelInboundHandlerAdapter
org.apache.cassandra.net.FrameDecoder
All Implemented Interfaces:
io.netty.channel.ChannelHandler, io.netty.channel.ChannelInboundHandler
Direct Known Subclasses:
FrameDecoderCrc, FrameDecoderLZ4

public abstract class FrameDecoder extends io.netty.channel.ChannelInboundHandlerAdapter
A Netty inbound handler that decodes incoming frames and passes them forward to InboundMessageHandler for processing. Handles work stashing, and together with InboundMessageHandler - flow control. Unlike most Netty inbound handlers, doesn't use the pipeline to talk to its upstream handler. Instead, a FrameDecoder.FrameProcessor must be registered with the frame decoder, to be invoked on new frames. See deliver(FrameProcessor). See activate(FrameProcessor), reactivate(), and FrameDecoder.FrameProcessor for flow control implementation. Five frame decoders currently exist, one used for each connection depending on flags and messaging version: 1. FrameDecoderCrc: no compression; payload is protected by CRC32 2. FrameDecoderLZ4: LZ4 compression with custom frame format; payload is protected by CRC32 3. FrameDecoderUnprotected: no compression; no integrity protection
  • Nested Class Summary

    Nested Classes
    Modifier and Type
    Class
    Description
    static final class 
    A corrupted frame was encountered; this represents the knowledge we have about this frame, and whether or not the stream is recoverable.
    static class 
     
    static interface 
     
    static final class 
    The payload bytes of a complete frame, i.e.

    Nested classes/interfaces inherited from interface io.netty.channel.ChannelHandler

    io.netty.channel.ChannelHandler.Sharable
  • Field Summary

    Fields
    Modifier and Type
    Field
    Description
    protected final BufferPoolAllocator
     
  • Method Summary

    Modifier and Type
    Method
    Description
    void
    For use by InboundMessageHandler (or other upstream handlers) that want to start receiving frames.
    void
    channelInactive(io.netty.channel.ChannelHandlerContext ctx)
     
    void
    channelRead(io.netty.channel.ChannelHandlerContext ctx, Object msg)
    Called by Netty pipeline when a new message arrives; we anticipate in normal operation this will receive messages of type BufferPoolAllocator.Wrapped or BufferPoolAllocator.Wrapped.
    void
    channelReadComplete(io.netty.channel.ChannelHandlerContext ctx)
     
    void
    For use by InboundMessageHandler (or other upstream handlers) that want to permanently stop receiving frames, e.g.
    void
    handlerAdded(io.netty.channel.ChannelHandlerContext ctx)
     
    boolean
     
    void
    For use by InboundMessageHandler (or other upstream handlers) that want to resume receiving frames after previously indicating that processing should be paused.

    Methods inherited from class io.netty.channel.ChannelInboundHandlerAdapter

    channelActive, channelRegistered, channelUnregistered, channelWritabilityChanged, exceptionCaught, userEventTriggered

    Methods inherited from class io.netty.channel.ChannelHandlerAdapter

    ensureNotSharable, handlerRemoved, isSharable

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait

    Methods inherited from interface io.netty.channel.ChannelHandler

    handlerRemoved
  • Field Details

  • Method Details

    • isActive

      public boolean isActive()
      Returns:
      true if we are actively decoding and processing frames
    • activate

      public void activate(FrameDecoder.FrameProcessor processor)
      For use by InboundMessageHandler (or other upstream handlers) that want to start receiving frames.
    • reactivate

      public void reactivate() throws IOException
      For use by InboundMessageHandler (or other upstream handlers) that want to resume receiving frames after previously indicating that processing should be paused.
      Throws:
      IOException
    • discard

      public void discard()
      For use by InboundMessageHandler (or other upstream handlers) that want to permanently stop receiving frames, e.g. because of an exception caught.
    • channelRead

      public void channelRead(io.netty.channel.ChannelHandlerContext ctx, Object msg) throws IOException
      Called by Netty pipeline when a new message arrives; we anticipate in normal operation this will receive messages of type BufferPoolAllocator.Wrapped or BufferPoolAllocator.Wrapped. These buffers are unwrapped and passed to decode(Collection, ShareableBytes), which collects decoded frames into frames, which we send upstream in deliver(org.apache.cassandra.net.FrameDecoder.FrameProcessor)
      Specified by:
      channelRead in interface io.netty.channel.ChannelInboundHandler
      Overrides:
      channelRead in class io.netty.channel.ChannelInboundHandlerAdapter
      Throws:
      IOException
    • channelReadComplete

      public void channelReadComplete(io.netty.channel.ChannelHandlerContext ctx)
      Specified by:
      channelReadComplete in interface io.netty.channel.ChannelInboundHandler
      Overrides:
      channelReadComplete in class io.netty.channel.ChannelInboundHandlerAdapter
    • handlerAdded

      public void handlerAdded(io.netty.channel.ChannelHandlerContext ctx)
      Specified by:
      handlerAdded in interface io.netty.channel.ChannelHandler
      Overrides:
      handlerAdded in class io.netty.channel.ChannelHandlerAdapter
    • channelInactive

      public void channelInactive(io.netty.channel.ChannelHandlerContext ctx)
      Specified by:
      channelInactive in interface io.netty.channel.ChannelInboundHandler
      Overrides:
      channelInactive in class io.netty.channel.ChannelInboundHandlerAdapter