@UnstableApi public final class RedisBulkStringAggregator extends MessageAggregator<RedisMessage,BulkStringHeaderRedisMessage,BulkStringRedisContent,FullBulkStringRedisMessage>
ChannelHandler that aggregates an BulkStringHeaderRedisMessage
and its following BulkStringRedisContents into a single FullBulkStringRedisMessage
with no following BulkStringRedisContents. It is useful when you don't want to take
care of RedisMessages whose transfer encoding is 'chunked'. Insert this
handler after RedisDecoder in the ChannelPipeline:
Be aware that you need to have theChannelPipelinep = ...; ... p.addLast("encoder", newRedisEncoder()); p.addLast("decoder", newRedisDecoder()); p.addLast("aggregator", newRedisBulkStringAggregator()); ... p.addLast("handler", new HttpRequestHandler());
RedisEncoder before the RedisBulkStringAggregator
in the ChannelPipeline.ChannelHandler.Sharable| Constructor and Description |
|---|
RedisBulkStringAggregator()
Creates a new instance.
|
| Modifier and Type | Method and Description |
|---|---|
protected FullBulkStringRedisMessage |
beginAggregation(BulkStringHeaderRedisMessage start,
ByteBuf content)
Creates a new aggregated message from the specified start message and the specified content.
|
protected boolean |
closeAfterContinueResponse(Object msg)
Determine if the channel should be closed after the result of
MessageAggregator.newContinueResponse(Object, int, ChannelPipeline) is written. |
protected boolean |
ignoreContentAfterContinueResponse(Object msg)
Determine if all objects for the current request/response should be ignored or not.
|
protected boolean |
isAggregated(RedisMessage msg)
Returns
true if and only if the specified message is already aggregated. |
protected boolean |
isContentLengthInvalid(BulkStringHeaderRedisMessage start,
int maxContentLength)
Determine if the message
start's content length is known, and if it greater than
maxContentLength. |
protected boolean |
isContentMessage(RedisMessage msg)
Returns
true if and only if the specified message is a content message. |
protected boolean |
isLastContentMessage(BulkStringRedisContent msg)
Returns
true if and only if the specified message is the last content message. |
protected boolean |
isStartMessage(RedisMessage msg)
Returns
true if and only if the specified message is a start message. |
protected Object |
newContinueResponse(BulkStringHeaderRedisMessage start,
int maxContentLength,
ChannelPipeline pipeline)
Returns the 'continue response' for the specified start message if necessary.
|
acceptInboundMessage, aggregate, channelInactive, channelReadComplete, ctx, decode, finishAggregation, handleOversizedMessage, handlerAdded, handlerRemoved, isHandlingOversizedMessage, maxContentLength, maxCumulationBufferComponents, setMaxCumulationBufferComponentschannelReadchannelActive, channelRegistered, channelUnregistered, channelWritabilityChanged, exceptionCaught, userEventTriggeredensureNotSharable, isSharablepublic RedisBulkStringAggregator()
protected boolean isStartMessage(RedisMessage msg) throws Exception
MessageAggregatortrue if and only if the specified message is a start message. Typically, this method is
implemented as a single return statement with instanceof:
return msg instanceof MyStartMessage;
isStartMessage in class MessageAggregator<RedisMessage,BulkStringHeaderRedisMessage,BulkStringRedisContent,FullBulkStringRedisMessage>Exceptionprotected boolean isContentMessage(RedisMessage msg) throws Exception
MessageAggregatortrue if and only if the specified message is a content message. Typically, this method is
implemented as a single return statement with instanceof:
return msg instanceof MyContentMessage;
isContentMessage in class MessageAggregator<RedisMessage,BulkStringHeaderRedisMessage,BulkStringRedisContent,FullBulkStringRedisMessage>Exceptionprotected boolean isLastContentMessage(BulkStringRedisContent msg) throws Exception
MessageAggregatortrue if and only if the specified message is the last content message. Typically, this method is
implemented as a single return statement with instanceof:
return msg instanceof MyLastContentMessage;or with
instanceof and boolean field check:
return msg instanceof MyContentMessage && msg.isLastFragment();
isLastContentMessage in class MessageAggregator<RedisMessage,BulkStringHeaderRedisMessage,BulkStringRedisContent,FullBulkStringRedisMessage>Exceptionprotected boolean isAggregated(RedisMessage msg) throws Exception
MessageAggregatortrue if and only if the specified message is already aggregated. If this method returns
true, this handler will simply forward the message to the next handler as-is.isAggregated in class MessageAggregator<RedisMessage,BulkStringHeaderRedisMessage,BulkStringRedisContent,FullBulkStringRedisMessage>Exceptionprotected boolean isContentLengthInvalid(BulkStringHeaderRedisMessage start, int maxContentLength) throws Exception
MessageAggregatorstart's content length is known, and if it greater than
maxContentLength.isContentLengthInvalid in class MessageAggregator<RedisMessage,BulkStringHeaderRedisMessage,BulkStringRedisContent,FullBulkStringRedisMessage>start - The message which may indicate the content length.maxContentLength - The maximum allowed content length.true if the message start's content length is known, and if it greater than
maxContentLength. false otherwise.Exceptionprotected Object newContinueResponse(BulkStringHeaderRedisMessage start, int maxContentLength, ChannelPipeline pipeline) throws Exception
MessageAggregatornewContinueResponse in class MessageAggregator<RedisMessage,BulkStringHeaderRedisMessage,BulkStringRedisContent,FullBulkStringRedisMessage>null if there's no message to sendExceptionprotected boolean closeAfterContinueResponse(Object msg) throws Exception
MessageAggregatorMessageAggregator.newContinueResponse(Object, int, ChannelPipeline) is written.closeAfterContinueResponse in class MessageAggregator<RedisMessage,BulkStringHeaderRedisMessage,BulkStringRedisContent,FullBulkStringRedisMessage>msg - The return value from MessageAggregator.newContinueResponse(Object, int, ChannelPipeline).true if the channel should be closed after the result of
MessageAggregator.newContinueResponse(Object, int, ChannelPipeline) is written. false otherwise.Exceptionprotected boolean ignoreContentAfterContinueResponse(Object msg) throws Exception
MessageAggregatorMessageAggregator.isContentMessage(Object) returns true.ignoreContentAfterContinueResponse in class MessageAggregator<RedisMessage,BulkStringHeaderRedisMessage,BulkStringRedisContent,FullBulkStringRedisMessage>msg - The return value from MessageAggregator.newContinueResponse(Object, int, ChannelPipeline).true if all objects for the current request/response should be ignored or not.
false otherwise.Exceptionprotected FullBulkStringRedisMessage beginAggregation(BulkStringHeaderRedisMessage start, ByteBuf content) throws Exception
MessageAggregatorByteBufHolder, its content is appended to the specified content.
This aggregator will continue to append the received content to the specified content.beginAggregation in class MessageAggregator<RedisMessage,BulkStringHeaderRedisMessage,BulkStringRedisContent,FullBulkStringRedisMessage>ExceptionCopyright © 2008–2017 The Netty Project. All rights reserved.