public class InboundMessageHandler extends AbstractMessageHandler
AbstractMessageHandler
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. See
Message.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 the Stage
for the Verb
of the message.AbstractMessageHandler.OnHandlerClosed, AbstractMessageHandler.WaitQueue
channel, corruptFramesRecovered, corruptFramesUnrecovered, decoder, endpointReserveCapacity, endpointWaitQueue, globalReserveCapacity, globalWaitQueue, largeMessage, largeThreshold, onClosed, queueCapacity, receivedBytes, receivedCount, throttledCount, throttledNanos
Modifier and Type | Method and 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() |
acquireCapacity, acquireCapacity, channelInactive, channelRead, handlerAdded, process, processSubsequentFrameOfLargeMessage, releaseCapacity, releaseProcessedCapacity
channelActive, channelReadComplete, channelRegistered, channelUnregistered, channelWritabilityChanged, userEventTriggered
ensureNotSharable, handlerRemoved, isSharable
protected boolean processOneContainedMessage(ShareableBytes bytes, ResourceLimits.Limit endpointReserve, ResourceLimits.Limit globalReserve) throws java.io.IOException
processOneContainedMessage
in class AbstractMessageHandler
java.io.IOException
protected boolean processFirstFrameOfLargeMessage(FrameDecoder.IntactFrame frame, ResourceLimits.Limit endpointReserve, ResourceLimits.Limit globalReserve) throws java.io.IOException
processFirstFrameOfLargeMessage
in class AbstractMessageHandler
java.io.IOException
protected void processCorruptFrame(FrameDecoder.CorruptFrame frame) throws Crc.InvalidCrc
processCorruptFrame
in class AbstractMessageHandler
Crc.InvalidCrc
protected java.lang.String id()
id
in class AbstractMessageHandler
public java.lang.String toString()
toString
in class java.lang.Object
public void exceptionCaught(io.netty.channel.ChannelHandlerContext ctx, java.lang.Throwable cause)
exceptionCaught
in interface io.netty.channel.ChannelHandler
exceptionCaught
in interface io.netty.channel.ChannelInboundHandler
exceptionCaught
in class io.netty.channel.ChannelInboundHandlerAdapter
protected void fatalExceptionCaught(java.lang.Throwable cause)
fatalExceptionCaught
in class AbstractMessageHandler
Copyright © 2009-2022 The Apache Software Foundation