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>
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
.
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
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 Details
-
currentMessage
Contains the current message that gets aggregated. -
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
-
-
Constructor Details
-
AbstractMemcacheObjectAggregator
protected AbstractMemcacheObjectAggregator(int maxContentLength)
-
-
Method Details
-
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
- Specified by:
channelInactive
in interfaceChannelInboundHandler
- Overrides:
channelInactive
in classChannelInboundHandlerAdapter
- Throws:
Exception
-
handlerAdded
- Specified by:
handlerAdded
in interfaceChannelHandler
- Overrides:
handlerAdded
in classChannelHandlerAdapter
- Throws:
Exception
-
handlerRemoved
- Specified by:
handlerRemoved
in interfaceChannelHandler
- Overrides:
handlerRemoved
in classChannelHandlerAdapter
- Throws:
Exception
-