@UnstableApi public abstract class AbstractMemcacheObjectAggregator<H extends MemcacheMessage> extends MessageAggregator<MemcacheObject,H,MemcacheContent,FullMemcacheMessage>
ChannelHandler
that aggregates an MemcacheMessage
and its following MemcacheContent
s into a single MemcacheMessage
with
no following MemcacheContent
s. It is useful when you don't want to take
care of memcache messages where the content comes along in chunks. Insert this
handler after a AbstractMemcacheObjectDecoder in the ChannelPipeline
.
For example, here for the binary protocol:
ChannelPipeline
p = ...; ... p.addLast("decoder", newBinaryMemcacheRequestDecoder
()); p.addLast("aggregator", newBinaryMemcacheObjectAggregator
(1048576) ); ... p.addLast("encoder", newBinaryMemcacheResponseEncoder
()); p.addLast("handler", new YourMemcacheRequestHandler());
ChannelHandler.Sharable
Modifier | Constructor and Description |
---|---|
protected |
AbstractMemcacheObjectAggregator(int maxContentLength) |
Modifier and Type | Method and Description |
---|---|
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(MemcacheObject msg)
Returns
true if and only if the specified message is already aggregated. |
protected boolean |
isContentLengthInvalid(H start,
int maxContentLength)
Determine if the message
start 's content length is known, and if it greater than
maxContentLength . |
protected boolean |
isContentMessage(MemcacheObject msg)
Returns
true if and only if the specified message is a content message. |
protected boolean |
isLastContentMessage(MemcacheContent msg)
Returns
true if and only if the specified message is the last content message. |
protected Object |
newContinueResponse(H start,
int maxContentLength,
ChannelPipeline pipeline)
Returns the 'continue response' for the specified start message if necessary.
|
acceptInboundMessage, aggregate, beginAggregation, channelInactive, channelReadComplete, ctx, decode, finishAggregation, handleOversizedMessage, handlerAdded, handlerRemoved, isHandlingOversizedMessage, isStartMessage, maxContentLength, maxCumulationBufferComponents, setMaxCumulationBufferComponents
channelRead
channelActive, channelRegistered, channelUnregistered, channelWritabilityChanged, exceptionCaught, userEventTriggered
ensureNotSharable, isSharable
protected AbstractMemcacheObjectAggregator(int maxContentLength)
protected boolean isContentMessage(MemcacheObject msg) throws Exception
MessageAggregator
true
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<MemcacheObject,H extends MemcacheMessage,MemcacheContent,FullMemcacheMessage>
Exception
protected boolean isLastContentMessage(MemcacheContent msg) throws Exception
MessageAggregator
true
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<MemcacheObject,H extends MemcacheMessage,MemcacheContent,FullMemcacheMessage>
Exception
protected boolean isAggregated(MemcacheObject msg) throws Exception
MessageAggregator
true
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<MemcacheObject,H extends MemcacheMessage,MemcacheContent,FullMemcacheMessage>
Exception
protected boolean isContentLengthInvalid(H start, int maxContentLength)
MessageAggregator
start
's content length is known, and if it greater than
maxContentLength
.isContentLengthInvalid
in class MessageAggregator<MemcacheObject,H extends MemcacheMessage,MemcacheContent,FullMemcacheMessage>
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.protected Object newContinueResponse(H start, int maxContentLength, ChannelPipeline pipeline)
MessageAggregator
newContinueResponse
in class MessageAggregator<MemcacheObject,H extends MemcacheMessage,MemcacheContent,FullMemcacheMessage>
null
if there's no message to sendprotected boolean closeAfterContinueResponse(Object msg) throws Exception
MessageAggregator
MessageAggregator.newContinueResponse(Object, int, ChannelPipeline)
is written.closeAfterContinueResponse
in class MessageAggregator<MemcacheObject,H extends MemcacheMessage,MemcacheContent,FullMemcacheMessage>
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.Exception
protected boolean ignoreContentAfterContinueResponse(Object msg) throws Exception
MessageAggregator
MessageAggregator.isContentMessage(Object)
returns true
.ignoreContentAfterContinueResponse
in class MessageAggregator<MemcacheObject,H extends MemcacheMessage,MemcacheContent,FullMemcacheMessage>
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.Exception
Copyright © 2008–2024 The Netty Project. All rights reserved.