@UnstableApi public abstract class AbstractBinaryMemcacheDecoder<M extends BinaryMemcacheMessage> extends AbstractMemcacheObjectDecoder
BinaryMemcacheRequest and BinaryMemcacheResponse.
The difference in the protocols (header) is implemented by the subclasses.| Modifier and Type | Class and Description |
|---|---|
(package private) static class |
AbstractBinaryMemcacheDecoder.State
Contains all states this decoder can possibly be in.
|
ByteToMessageDecoder.CumulatorChannelHandler.Sharable| Modifier and Type | Field and Description |
|---|---|
private int |
alreadyReadChunkSize |
private int |
chunkSize |
private M |
currentMessage |
static int |
DEFAULT_MAX_CHUNK_SIZE |
private AbstractBinaryMemcacheDecoder.State |
state |
COMPOSITE_CUMULATOR, MERGE_CUMULATOR| Modifier | Constructor and Description |
|---|---|
protected |
AbstractBinaryMemcacheDecoder()
Create a new
AbstractBinaryMemcacheDecoder with default settings. |
protected |
AbstractBinaryMemcacheDecoder(int chunkSize)
Create a new
AbstractBinaryMemcacheDecoder with custom settings. |
| Modifier and Type | Method and Description |
|---|---|
protected abstract M |
buildInvalidMessage()
Helper method to create a upstream message when the incoming parsing did fail.
|
void |
channelInactive(ChannelHandlerContext ctx)
When the channel goes inactive, release all frames to prevent data leaks.
|
protected void |
decode(ChannelHandlerContext ctx,
ByteBuf in,
java.util.List<java.lang.Object> out)
Decode the from one
ByteBuf to an other. |
protected abstract M |
decodeHeader(ByteBuf in)
Decode and return the parsed
BinaryMemcacheMessage. |
private MemcacheContent |
invalidChunk(java.lang.Exception cause)
Helper method to create a content chunk indicating a invalid decoding result.
|
private M |
invalidMessage(java.lang.Exception cause)
Helper method to create a message indicating a invalid decoding result.
|
protected void |
resetDecoder()
Prepare for next decoding iteration.
|
actualReadableBytes, callDecode, channelRead, channelReadComplete, decodeLast, discardSomeReadBytes, handlerRemoved, handlerRemoved0, internalBuffer, isSingleDecode, setCumulator, setDiscardAfterReads, setSingleDecode, userEventTriggeredchannelActive, channelRegistered, channelUnregistered, channelWritabilityChanged, exceptionCaughtensureNotSharable, handlerAdded, isSharableclone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waithandlerAddedpublic static final int DEFAULT_MAX_CHUNK_SIZE
private final int chunkSize
private M extends BinaryMemcacheMessage currentMessage
private int alreadyReadChunkSize
private AbstractBinaryMemcacheDecoder.State state
protected AbstractBinaryMemcacheDecoder()
AbstractBinaryMemcacheDecoder with default settings.protected AbstractBinaryMemcacheDecoder(int chunkSize)
AbstractBinaryMemcacheDecoder with custom settings.chunkSize - the maximum chunk size of the payload.protected void decode(ChannelHandlerContext ctx, ByteBuf in, java.util.List<java.lang.Object> out) throws java.lang.Exception
ByteToMessageDecoderByteBuf to an other. This method will be called till either the input
ByteBuf has nothing to read when return from this method or till nothing was read from the input
ByteBuf.decode in class ByteToMessageDecoderctx - the ChannelHandlerContext which this ByteToMessageDecoder belongs toin - the ByteBuf from which to read dataout - the List to which decoded messages should be addedjava.lang.Exception - is thrown if an error occursprivate M invalidMessage(java.lang.Exception cause)
cause - the cause of the decoding failure.private MemcacheContent invalidChunk(java.lang.Exception cause)
cause - the cause of the decoding failure.public void channelInactive(ChannelHandlerContext ctx) throws java.lang.Exception
channelInactive in interface ChannelInboundHandlerchannelInactive in class ByteToMessageDecoderctx - handler contextjava.lang.Exceptionprotected void resetDecoder()
protected abstract M decodeHeader(ByteBuf in)
BinaryMemcacheMessage.in - the incoming buffer.protected abstract M buildInvalidMessage()