public abstract class AbstractMemcacheObjectAggregator extends MessageToMessageDecoder<MemcacheObject>
A 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
.
ChannelPipeline
p = …; … p.addLast(“decoder”, newBinaryMemcacheRequestDecoder
()); p.addLast(“aggregator”, newBinaryMemcacheObjectAggregator
(1048576) ); … p.addLast(“encoder”, newBinaryMemcacheResponseEncoder
()); p.addLast(“handler”, new YourMemcacheRequestHandler());
ChannelHandler.Sharable
Modifier and Type | Field and Description |
---|---|
protected ChannelHandlerContext |
ctx
Holds the current channel handler context if set.
|
protected FullMemcacheMessage |
currentMessage
Contains the current message that gets aggregated.
|
static int |
DEFAULT_MAX_COMPOSITEBUFFER_COMPONENTS |
Modifier | Constructor and Description |
---|---|
protected |
AbstractMemcacheObjectAggregator(int maxContentLength) |
Modifier and Type | Method and Description |
---|---|
void |
channelInactive(ChannelHandlerContext ctx) |
int |
getMaxContentLength() |
int |
getMaxCumulationBufferComponents()
Returns the maximum number of components in the cumulation buffer.
|
void |
handlerAdded(ChannelHandlerContext ctx) |
void |
handlerRemoved(ChannelHandlerContext ctx) |
void |
setMaxCumulationBufferComponents(int maxCumulationBufferComponents)
Sets the maximum number of components in the cumulation buffer.
|
acceptInboundMessage, channelRead, decode
channelActive, channelReadComplete, channelRegistered, channelUnregistered, channelWritabilityChanged, exceptionCaught, userEventTriggered
isSharable
protected FullMemcacheMessage currentMessage
Contains the current message that gets aggregated.
protected ChannelHandlerContext ctx
Holds the current channel handler context if set.
public static final int DEFAULT_MAX_COMPOSITEBUFFER_COMPONENTS
protected AbstractMemcacheObjectAggregator(int maxContentLength)
public final int getMaxCumulationBufferComponents()
Returns the maximum number of components in the cumulation buffer. If the number of the components in the cumulation buffer exceeds this value, the components of the cumulation buffer are consolidated into a single component, involving memory copies. The default value of this property is DEFAULT_MAX_COMPOSITEBUFFER_COMPONENTS
.
public final void setMaxCumulationBufferComponents(int maxCumulationBufferComponents)
Sets the maximum number of components in the cumulation buffer. If the number of the components in the cumulation buffer exceeds this value, the components of the cumulation buffer are consolidated into a single component, involving memory copies. The default value of this property is DEFAULT_MAX_COMPOSITEBUFFER_COMPONENTS
and its minimum allowed value is 2
.
public int getMaxContentLength()
public void channelInactive(ChannelHandlerContext ctx) throws Exception
channelInactive
in interface ChannelInboundHandler
channelInactive
in class ChannelInboundHandlerAdapter
Exception
public void handlerAdded(ChannelHandlerContext ctx) throws Exception
handlerAdded
in interface ChannelHandler
handlerAdded
in class ChannelHandlerAdapter
Exception
public void handlerRemoved(ChannelHandlerContext ctx) throws Exception
handlerRemoved
in interface ChannelHandler
handlerRemoved
in class ChannelHandlerAdapter
Exception
Copyright © 2016 Couchbase, Inc.. All rights reserved.