public abstract class AbstractMemcacheObjectAggregator extends io.netty.handler.codec.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());
Modifier and Type | Field and Description |
---|---|
protected io.netty.channel.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(io.netty.channel.ChannelHandlerContext ctx) |
int |
getMaxContentLength() |
int |
getMaxCumulationBufferComponents()
Returns the maximum number of components in the cumulation buffer.
|
void |
handlerAdded(io.netty.channel.ChannelHandlerContext ctx) |
void |
handlerRemoved(io.netty.channel.ChannelHandlerContext ctx) |
void |
setMaxCumulationBufferComponents(int maxCumulationBufferComponents)
Sets the maximum number of components in the cumulation buffer.
|
acceptInboundMessage, channelRead, decode
protected FullMemcacheMessage currentMessage
Contains the current message that gets aggregated.
protected io.netty.channel.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(io.netty.channel.ChannelHandlerContext ctx) throws java.lang.Exception
channelInactive
in interface io.netty.channel.ChannelInboundHandler
channelInactive
in class io.netty.channel.ChannelInboundHandlerAdapter
java.lang.Exception
public void handlerAdded(io.netty.channel.ChannelHandlerContext ctx) throws java.lang.Exception
handlerAdded
in interface io.netty.channel.ChannelHandler
handlerAdded
in class io.netty.channel.ChannelHandlerAdapter
java.lang.Exception
public void handlerRemoved(io.netty.channel.ChannelHandlerContext ctx) throws java.lang.Exception
handlerRemoved
in interface io.netty.channel.ChannelHandler
handlerRemoved
in class io.netty.channel.ChannelHandlerAdapter
java.lang.Exception