Package org.apache.cassandra.net
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.ChannelInboundHandlerAdapterA Netty inbound handler that decodes incoming frames and passes them forward toInboundMessageHandlerfor processing. Handles work stashing, and together withInboundMessageHandler- flow control. Unlike most Netty inbound handlers, doesn't use the pipeline to talk to its upstream handler. Instead, aFrameDecoder.FrameProcessormust be registered with the frame decoder, to be invoked on new frames. Seedeliver(FrameProcessor). Seeactivate(FrameProcessor),reactivate(), andFrameDecoder.FrameProcessorfor 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 4.FrameDecoderLegacy: no compression; no integrity protection; turns unframed streams of legacy messages (< 4.0) into frames 5.FrameDecoderLegacyLZ4LZ4 compression using standard LZ4 frame format; groups legacy messages (< 4.0) into frames
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static classFrameDecoder.CorruptFrameA corrupted frame was encountered; this represents the knowledge we have about this frame, and whether or not the stream is recoverable.static classFrameDecoder.Framestatic interfaceFrameDecoder.FrameProcessorstatic classFrameDecoder.IntactFrameThe payload bytes of a complete frame, i.e.
-
Field Summary
Fields Modifier and Type Field Description protected BufferPoolAllocatorallocator
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description voidactivate(FrameDecoder.FrameProcessor processor)For use by InboundMessageHandler (or other upstream handlers) that want to start receiving frames.voidchannelInactive(io.netty.channel.ChannelHandlerContext ctx)voidchannelRead(io.netty.channel.ChannelHandlerContext ctx, java.lang.Object msg)Called by Netty pipeline when a new message arrives; we anticipate in normal operation this will receive messages of typeBufferPoolAllocator.WrappedorBufferPoolAllocator.Wrapped.voidchannelReadComplete(io.netty.channel.ChannelHandlerContext ctx)voiddiscard()For use by InboundMessageHandler (or other upstream handlers) that want to permanently stop receiving frames, e.g.voidhandlerAdded(io.netty.channel.ChannelHandlerContext ctx)booleanisActive()voidreactivate()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
-
-
-
-
Field Detail
-
allocator
protected final BufferPoolAllocator allocator
-
-
Method Detail
-
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 java.io.IOExceptionFor use by InboundMessageHandler (or other upstream handlers) that want to resume receiving frames after previously indicating that processing should be paused.- Throws:
java.io.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, java.lang.Object msg) throws java.io.IOExceptionCalled by Netty pipeline when a new message arrives; we anticipate in normal operation this will receive messages of typeBufferPoolAllocator.WrappedorBufferPoolAllocator.Wrapped. These buffers are unwrapped and passed todecode(Collection, ShareableBytes), which collects decoded frames intoframes, which we send upstream indeliver(org.apache.cassandra.net.FrameDecoder.FrameProcessor)- Specified by:
channelReadin interfaceio.netty.channel.ChannelInboundHandler- Overrides:
channelReadin classio.netty.channel.ChannelInboundHandlerAdapter- Throws:
java.io.IOException
-
channelReadComplete
public void channelReadComplete(io.netty.channel.ChannelHandlerContext ctx)
- Specified by:
channelReadCompletein interfaceio.netty.channel.ChannelInboundHandler- Overrides:
channelReadCompletein classio.netty.channel.ChannelInboundHandlerAdapter
-
handlerAdded
public void handlerAdded(io.netty.channel.ChannelHandlerContext ctx)
- Specified by:
handlerAddedin interfaceio.netty.channel.ChannelHandler- Overrides:
handlerAddedin classio.netty.channel.ChannelHandlerAdapter
-
channelInactive
public void channelInactive(io.netty.channel.ChannelHandlerContext ctx)
- Specified by:
channelInactivein interfaceio.netty.channel.ChannelInboundHandler- Overrides:
channelInactivein classio.netty.channel.ChannelInboundHandlerAdapter
-
-