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, ChannelHandler.Skip
Modifier | Constructor and Description |
---|---|
protected |
AbstractMemcacheObjectAggregator(int maxContentLength) |
Modifier and Type | Method and Description |
---|---|
protected long |
contentLength(H start)
Retrieves the length of the whole content from the specified start message.
|
protected boolean |
hasContentLength(H start)
Returns
true if and only if the specified start message already contains the information about the
length of the whole content. |
protected boolean |
isAggregated(MemcacheObject msg)
Returns
true if and only if the specified message is already aggregated. |
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)
Returns the 'continue response' for the specified start message if necessary.
|
acceptInboundMessage, aggregate, beginAggregation, channelInactive, ctx, decode, finishAggregation, handleOversizedMessage, handlerAdded, handlerRemoved, isHandlingOversizedMessage, isStartMessage, maxContentLength, maxCumulationBufferComponents, setMaxCumulationBufferComponents
channelRead
bind, channelActive, channelReadComplete, channelRegistered, channelUnregistered, channelWritabilityChanged, close, connect, deregister, disconnect, exceptionCaught, flush, isSharable, read, userEventTriggered, write
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 hasContentLength(H start) throws Exception
MessageAggregator
true
if and only if the specified start message already contains the information about the
length of the whole content.hasContentLength
in class MessageAggregator<MemcacheObject,H extends MemcacheMessage,MemcacheContent,FullMemcacheMessage>
Exception
protected long contentLength(H start) throws Exception
MessageAggregator
MessageAggregator.hasContentLength(Object)
returned true
.contentLength
in class MessageAggregator<MemcacheObject,H extends MemcacheMessage,MemcacheContent,FullMemcacheMessage>
Exception
protected Object newContinueResponse(H start) throws Exception
MessageAggregator
newContinueResponse
in class MessageAggregator<MemcacheObject,H extends MemcacheMessage,MemcacheContent,FullMemcacheMessage>
null
if there's no message to sendException
Copyright © 2008–2015 The Netty Project. All rights reserved.