Class AbstractMemcacheObjectAggregator
- java.lang.Object
-
- io.netty.channel.ChannelHandlerAdapter
-
- io.netty.channel.ChannelInboundHandlerAdapter
-
- io.netty.handler.codec.MessageToMessageDecoder<MemcacheObject>
-
- com.couchbase.client.deps.io.netty.handler.codec.memcache.AbstractMemcacheObjectAggregator
-
- All Implemented Interfaces:
ChannelHandler
,ChannelInboundHandler
- Direct Known Subclasses:
BinaryMemcacheObjectAggregator
public abstract class AbstractMemcacheObjectAggregator extends MessageToMessageDecoder<MemcacheObject>
AChannelHandler
that aggregates anMemcacheMessage
and its followingMemcacheContent
s into a singleMemcacheMessage
with no followingMemcacheContent
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 theChannelPipeline
.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());
-
-
Nested Class Summary
-
Nested classes/interfaces inherited from interface io.netty.channel.ChannelHandler
ChannelHandler.Sharable
-
-
Field Summary
Fields Modifier and Type Field 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
-
Constructor Summary
Constructors Modifier Constructor Description protected
AbstractMemcacheObjectAggregator(int maxContentLength)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method 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.-
Methods inherited from class io.netty.handler.codec.MessageToMessageDecoder
acceptInboundMessage, channelRead, decode
-
Methods inherited from class io.netty.channel.ChannelInboundHandlerAdapter
channelActive, channelReadComplete, channelRegistered, channelUnregistered, channelWritabilityChanged, exceptionCaught, userEventTriggered
-
Methods inherited from class io.netty.channel.ChannelHandlerAdapter
ensureNotSharable, isSharable
-
-
-
-
Field Detail
-
currentMessage
protected FullMemcacheMessage currentMessage
Contains the current message that gets aggregated.
-
ctx
protected ChannelHandlerContext ctx
Holds the current channel handler context if set.
-
DEFAULT_MAX_COMPOSITEBUFFER_COMPONENTS
public static final int DEFAULT_MAX_COMPOSITEBUFFER_COMPONENTS
- See Also:
- Constant Field Values
-
-
Method Detail
-
getMaxCumulationBufferComponents
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 isDEFAULT_MAX_COMPOSITEBUFFER_COMPONENTS
.
-
setMaxCumulationBufferComponents
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 isDEFAULT_MAX_COMPOSITEBUFFER_COMPONENTS
and its minimum allowed value is2
.
-
getMaxContentLength
public int getMaxContentLength()
-
channelInactive
public void channelInactive(ChannelHandlerContext ctx) throws Exception
- Specified by:
channelInactive
in interfaceChannelInboundHandler
- Overrides:
channelInactive
in classChannelInboundHandlerAdapter
- Throws:
Exception
-
handlerAdded
public void handlerAdded(ChannelHandlerContext ctx) throws Exception
- Specified by:
handlerAdded
in interfaceChannelHandler
- Overrides:
handlerAdded
in classChannelHandlerAdapter
- Throws:
Exception
-
handlerRemoved
public void handlerRemoved(ChannelHandlerContext ctx) throws Exception
- Specified by:
handlerRemoved
in interfaceChannelHandler
- Overrides:
handlerRemoved
in classChannelHandlerAdapter
- Throws:
Exception
-
-