public class CQLMessageHandler<M extends Message> extends AbstractMessageHandler
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
.
Message.Serializer.inferMessageSize(ByteBuffer, int, int, int)
.
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.AbstractMessageHandler.OnHandlerClosed, AbstractMessageHandler.WaitQueue
Modifier and Type | Field and Description |
---|---|
static int |
LARGE_MESSAGE_THRESHOLD |
channel, corruptFramesRecovered, corruptFramesUnrecovered, decoder, endpointReserveCapacity, endpointWaitQueue, globalReserveCapacity, globalWaitQueue, largeMessage, largeThreshold, onClosed, queueCapacity, receivedBytes, receivedCount, throttledCount, throttledNanos
Modifier and Type | Method and Description |
---|---|
protected void |
fatalExceptionCaught(java.lang.Throwable cause) |
protected java.lang.String |
id() |
protected void |
processCorruptFrame(FrameDecoder.CorruptFrame frame) |
protected boolean |
processFirstFrameOfLargeMessage(FrameDecoder.IntactFrame frame,
ResourceLimits.Limit endpointReserve,
ResourceLimits.Limit globalReserve) |
protected boolean |
processOneContainedMessage(ShareableBytes bytes,
ResourceLimits.Limit endpointReserve,
ResourceLimits.Limit globalReserve) |
protected void |
processRequest(Envelope request) |
acquireCapacity, acquireCapacity, channelInactive, channelRead, handlerAdded, process, processSubsequentFrameOfLargeMessage, releaseCapacity, releaseProcessedCapacity
channelActive, channelReadComplete, channelRegistered, channelUnregistered, channelWritabilityChanged, exceptionCaught, userEventTriggered
ensureNotSharable, handlerRemoved, isSharable
public static final int LARGE_MESSAGE_THRESHOLD
protected boolean processOneContainedMessage(ShareableBytes bytes, ResourceLimits.Limit endpointReserve, ResourceLimits.Limit globalReserve)
processOneContainedMessage
in class AbstractMessageHandler
protected void processRequest(Envelope request)
protected boolean processFirstFrameOfLargeMessage(FrameDecoder.IntactFrame frame, ResourceLimits.Limit endpointReserve, ResourceLimits.Limit globalReserve) throws java.io.IOException
processFirstFrameOfLargeMessage
in class AbstractMessageHandler
java.io.IOException
protected java.lang.String id()
id
in class AbstractMessageHandler
protected void processCorruptFrame(FrameDecoder.CorruptFrame frame)
processCorruptFrame
in class AbstractMessageHandler
protected void fatalExceptionCaught(java.lang.Throwable cause)
fatalExceptionCaught
in class AbstractMessageHandler
Copyright © 2009-2020 The Apache Software Foundation