Class AbstractMemcacheObjectAggregator<H extends MemcacheMessage>
java.lang.Object
io.netty.channel.ChannelHandlerAdapter
io.netty.channel.ChannelInboundHandlerAdapter
io.netty.handler.codec.MessageToMessageDecoder<MemcacheObject>
io.netty.handler.codec.MessageAggregator<MemcacheObject, H, MemcacheContent, FullMemcacheMessage>
io.netty.handler.codec.memcache.AbstractMemcacheObjectAggregator<H>
- All Implemented Interfaces:
ChannelHandler, ChannelInboundHandler
- Direct Known Subclasses:
BinaryMemcacheObjectAggregator
@UnstableApi
public abstract class AbstractMemcacheObjectAggregator<H extends MemcacheMessage>
extends MessageAggregator<MemcacheObject, H, MemcacheContent, FullMemcacheMessage>
A
ChannelHandler that aggregates an MemcacheMessage
and its following MemcacheContents into a single MemcacheMessage with
no following MemcacheContents. 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:
ChannelPipelinep = ...; ... p.addLast("decoder", newBinaryMemcacheRequestDecoder()); p.addLast("aggregator", newBinaryMemcacheObjectAggregator(1048576) ); ... p.addLast("encoder", newBinaryMemcacheResponseEncoder()); p.addLast("handler", new YourMemcacheRequestHandler());
-
Nested Class Summary
Nested classes/interfaces inherited from interface ChannelHandler
ChannelHandler.Sharable -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionprotected booleanDetermine if the channel should be closed after the result ofMessageAggregator.newContinueResponse(Object, int, ChannelPipeline)is written.protected booleanDetermine if all objects for the current request/response should be ignored or not.protected booleanReturnstrueif and only if the specified message is already aggregated.protected booleanisContentLengthInvalid(H start, int maxContentLength) Determine if the messagestart's content length is known, and if it greater thanmaxContentLength.protected booleanReturnstrueif and only if the specified message is a content message.protected booleanReturnstrueif and only if the specified message is the last content message.protected ObjectnewContinueResponse(H start, int maxContentLength, ChannelPipeline pipeline) Returns the 'continue response' for the specified start message if necessary.Methods inherited from class MessageAggregator
acceptInboundMessage, aggregate, beginAggregation, channelInactive, channelReadComplete, ctx, decode, finishAggregation, handleOversizedMessage, handlerAdded, handlerRemoved, isHandlingOversizedMessage, isStartMessage, maxContentLength, maxCumulationBufferComponents, releaseCurrentMessage, setMaxCumulationBufferComponentsMethods inherited from class MessageToMessageDecoder
channelReadMethods inherited from class ChannelInboundHandlerAdapter
channelActive, channelRegistered, channelUnregistered, channelWritabilityChanged, exceptionCaught, userEventTriggeredMethods inherited from class ChannelHandlerAdapter
ensureNotSharable, isSharable
-
Constructor Details
-
AbstractMemcacheObjectAggregator
protected AbstractMemcacheObjectAggregator(int maxContentLength)
-
-
Method Details
-
isContentMessage
Description copied from class:MessageAggregatorReturnstrueif and only if the specified message is a content message. Typically, this method is implemented as a singlereturnstatement withinstanceof:return msg instanceof MyContentMessage;
- Specified by:
isContentMessagein classMessageAggregator<MemcacheObject, H extends MemcacheMessage, MemcacheContent, FullMemcacheMessage>- Throws:
Exception
-
isLastContentMessage
Description copied from class:MessageAggregatorReturnstrueif and only if the specified message is the last content message. Typically, this method is implemented as a singlereturnstatement withinstanceof:return msg instanceof MyLastContentMessage;
or withinstanceofand boolean field check:return msg instanceof MyContentMessage invalid input: '&'invalid input: '&' msg.isLastFragment();
- Specified by:
isLastContentMessagein classMessageAggregator<MemcacheObject, H extends MemcacheMessage, MemcacheContent, FullMemcacheMessage>- Throws:
Exception
-
isAggregated
Description copied from class:MessageAggregatorReturnstrueif and only if the specified message is already aggregated. If this method returnstrue, this handler will simply forward the message to the next handler as-is.- Specified by:
isAggregatedin classMessageAggregator<MemcacheObject, H extends MemcacheMessage, MemcacheContent, FullMemcacheMessage>- Throws:
Exception
-
isContentLengthInvalid
Description copied from class:MessageAggregatorDetermine if the messagestart's content length is known, and if it greater thanmaxContentLength.- Specified by:
isContentLengthInvalidin classMessageAggregator<MemcacheObject, H extends MemcacheMessage, MemcacheContent, FullMemcacheMessage>- Parameters:
start- The message which may indicate the content length.maxContentLength- The maximum allowed content length.- Returns:
trueif the messagestart's content length is known, and if it greater thanmaxContentLength.falseotherwise.
-
newContinueResponse
Description copied from class:MessageAggregatorReturns the 'continue response' for the specified start message if necessary. For example, this method is useful to handle an HTTP 100-continue header.- Specified by:
newContinueResponsein classMessageAggregator<MemcacheObject, H extends MemcacheMessage, MemcacheContent, FullMemcacheMessage>- Returns:
- the 'continue response', or
nullif there's no message to send
-
closeAfterContinueResponse
Description copied from class:MessageAggregatorDetermine if the channel should be closed after the result ofMessageAggregator.newContinueResponse(Object, int, ChannelPipeline)is written.- Specified by:
closeAfterContinueResponsein classMessageAggregator<MemcacheObject, H extends MemcacheMessage, MemcacheContent, FullMemcacheMessage>- Parameters:
msg- The return value fromMessageAggregator.newContinueResponse(Object, int, ChannelPipeline).- Returns:
trueif the channel should be closed after the result ofMessageAggregator.newContinueResponse(Object, int, ChannelPipeline)is written.falseotherwise.- Throws:
Exception
-
ignoreContentAfterContinueResponse
Description copied from class:MessageAggregatorDetermine if all objects for the current request/response should be ignored or not. Messages will stop being ignored the next timeMessageAggregator.isContentMessage(Object)returnstrue.- Specified by:
ignoreContentAfterContinueResponsein classMessageAggregator<MemcacheObject, H extends MemcacheMessage, MemcacheContent, FullMemcacheMessage>- Parameters:
msg- The return value fromMessageAggregator.newContinueResponse(Object, int, ChannelPipeline).- Returns:
trueif all objects for the current request/response should be ignored or not.falseotherwise.- Throws:
Exception
-