Class CQLMessageHandler<M extends Message>

  • All Implemented Interfaces:
    io.netty.channel.ChannelHandler, io.netty.channel.ChannelInboundHandler, FrameDecoder.FrameProcessor

    public class CQLMessageHandler<M extends Message>
    extends AbstractMessageHandler
    Implementation of AbstractMessageHandler for processing CQL messages which comprise a Message wrapped in an Envelope. This class is parameterized by a Message subtype, expected to be either Message.Request or Message.Response. Most commonly, an instance for handling Message.Request is created for each inbound CQL client connection. # Small vs large messages Small messages are deserialized in place, and then handed off to a consumer for processing. Large messages accumulate frames until all bytes for the envelope are received, then concatenate and deserialize the frames on the event loop thread and pass them on to the same consumer. # Flow control (backpressure) The size of an incoming message is explicit in the Envelope.Header. By default, every connection has 1MiB of exlusive permits available before needing to access the per-endpoint and global reserves. By default, those reserves are sized proportionally to the heap - 2.5% of heap per-endpoint and a 10% for the global reserve. Permits are held while CQL messages are processed and released after the response has been encoded into the buffers of the response frame. A connection level option (THROW_ON_OVERLOAD) allows clients to choose the backpressure strategy when a connection has exceeded the maximum number of allowed permits. The choices are to either pause reads from the incoming socket and allow TCP backpressure to do the work, or to throw an explict exception and rely on the client to back off.