Package org.apache.cassandra.net
Class InboundMessageHandler
- java.lang.Object
-
- io.netty.channel.ChannelHandlerAdapter
-
- io.netty.channel.ChannelInboundHandlerAdapter
-
- org.apache.cassandra.net.AbstractMessageHandler
-
- org.apache.cassandra.net.InboundMessageHandler
-
- All Implemented Interfaces:
io.netty.channel.ChannelHandler
,io.netty.channel.ChannelInboundHandler
,FrameDecoder.FrameProcessor
public class InboundMessageHandler extends AbstractMessageHandler
Implementation ofAbstractMessageHandler
for processing internode messages from peers. # Small vs large messages Small messages are deserialized in place, and then handed off to an appropriate thread pool for processing. Large messages accumulate frames until completion of a message, then hand off the untouched frames to the correct thread pool for the verb to be deserialized there and immediately processed. # Flow control (backpressure) To prevent nodes from overwhelming and bringing each other to the knees with more inbound messages that can be processed in a timely manner,InboundMessageHandler
implements a strict flow control policy. The size of the incoming message is dependent on the messaging version of the specific peer connection. SeeMessage.Serializer#inferMessageSize(ByteBuffer, int, int, int)
. By default, every connection has 4MiB of exlusive permits available before needing to access the per-endpoint and global reserves. Permits are released after the verb handler has been invoked on theStage
for theVerb
of the message.
-
-
Nested Class Summary
-
Nested classes/interfaces inherited from class org.apache.cassandra.net.AbstractMessageHandler
AbstractMessageHandler.OnHandlerClosed, AbstractMessageHandler.WaitQueue
-
-
Field Summary
-
Fields inherited from class org.apache.cassandra.net.AbstractMessageHandler
channel, corruptFramesRecovered, corruptFramesUnrecovered, decoder, endpointReserveCapacity, endpointWaitQueue, globalReserveCapacity, globalWaitQueue, largeMessage, largeThreshold, onClosed, queueCapacity, receivedBytes, receivedCount, throttledCount, throttledNanos
-
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description void
exceptionCaught(io.netty.channel.ChannelHandlerContext ctx, java.lang.Throwable cause)
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)
java.lang.String
toString()
-
Methods inherited from class org.apache.cassandra.net.AbstractMessageHandler
acquireCapacity, acquireCapacity, channelInactive, channelRead, handlerAdded, process, processSubsequentFrameOfLargeMessage, processUpToOneMessage, releaseCapacity, releaseProcessedCapacity
-
Methods inherited from class io.netty.channel.ChannelInboundHandlerAdapter
channelActive, channelReadComplete, channelRegistered, channelUnregistered, channelWritabilityChanged, userEventTriggered
-
Methods inherited from class io.netty.channel.ChannelHandlerAdapter
ensureNotSharable, handlerRemoved, isSharable
-
-
-
-
Method Detail
-
processOneContainedMessage
protected boolean processOneContainedMessage(ShareableBytes bytes, ResourceLimits.Limit endpointReserve, ResourceLimits.Limit globalReserve) throws java.io.IOException
- Specified by:
processOneContainedMessage
in classAbstractMessageHandler
- Throws:
java.io.IOException
-
processFirstFrameOfLargeMessage
protected boolean processFirstFrameOfLargeMessage(FrameDecoder.IntactFrame frame, ResourceLimits.Limit endpointReserve, ResourceLimits.Limit globalReserve) throws java.io.IOException
- Specified by:
processFirstFrameOfLargeMessage
in classAbstractMessageHandler
- Throws:
java.io.IOException
-
processCorruptFrame
protected void processCorruptFrame(FrameDecoder.CorruptFrame frame) throws Crc.InvalidCrc
- Specified by:
processCorruptFrame
in classAbstractMessageHandler
- Throws:
Crc.InvalidCrc
-
id
protected java.lang.String id()
- Specified by:
id
in classAbstractMessageHandler
-
toString
public java.lang.String toString()
- Overrides:
toString
in classjava.lang.Object
-
exceptionCaught
public void exceptionCaught(io.netty.channel.ChannelHandlerContext ctx, java.lang.Throwable cause)
- Specified by:
exceptionCaught
in interfaceio.netty.channel.ChannelHandler
- Specified by:
exceptionCaught
in interfaceio.netty.channel.ChannelInboundHandler
- Overrides:
exceptionCaught
in classio.netty.channel.ChannelInboundHandlerAdapter
-
fatalExceptionCaught
protected void fatalExceptionCaught(java.lang.Throwable cause)
- Specified by:
fatalExceptionCaught
in classAbstractMessageHandler
-
-