Home / Class/ AbstractBinaryMemcacheDecoder Class — netty Architecture

AbstractBinaryMemcacheDecoder Class — netty Architecture

Architecture documentation for the AbstractBinaryMemcacheDecoder class in AbstractBinaryMemcacheDecoder.java from the netty codebase.

Entity Profile

Dependency Diagram

graph TD
  337c246d_1811_4204_aa58_594cb5d04bc8["AbstractBinaryMemcacheDecoder"]
  e78d5d70_8d92_cac9_15ad_a5aee207abc6["AbstractBinaryMemcacheDecoder.java"]
  337c246d_1811_4204_aa58_594cb5d04bc8 -->|defined in| e78d5d70_8d92_cac9_15ad_a5aee207abc6
  f5c624c6_9b91_ae47_c753_65ae03fe2124["AbstractBinaryMemcacheDecoder()"]
  337c246d_1811_4204_aa58_594cb5d04bc8 -->|method| f5c624c6_9b91_ae47_c753_65ae03fe2124
  fc04d2f1_e0ef_815c_2cb1_b5f24e44683e["decode()"]
  337c246d_1811_4204_aa58_594cb5d04bc8 -->|method| fc04d2f1_e0ef_815c_2cb1_b5f24e44683e
  cbbda982_c1c0_5038_dc6a_b2912ed9c3b9["M()"]
  337c246d_1811_4204_aa58_594cb5d04bc8 -->|method| cbbda982_c1c0_5038_dc6a_b2912ed9c3b9
  d22af869_e47a_9151_a6e0_81375fd296e1["MemcacheContent()"]
  337c246d_1811_4204_aa58_594cb5d04bc8 -->|method| d22af869_e47a_9151_a6e0_81375fd296e1
  c04dbbdb_f114_8989_7590_ab0a480734a4["channelInactive()"]
  337c246d_1811_4204_aa58_594cb5d04bc8 -->|method| c04dbbdb_f114_8989_7590_ab0a480734a4
  af4d9ee7_c660_e32a_59ac_59524875e13b["resetDecoder()"]
  337c246d_1811_4204_aa58_594cb5d04bc8 -->|method| af4d9ee7_c660_e32a_59ac_59524875e13b

Relationship Graph

Source Code

codec-memcache/src/main/java/io/netty/handler/codec/memcache/binary/AbstractBinaryMemcacheDecoder.java lines 38–268

@UnstableApi
public abstract class AbstractBinaryMemcacheDecoder<M extends BinaryMemcacheMessage>
    extends AbstractMemcacheObjectDecoder {

    public static final int DEFAULT_MAX_CHUNK_SIZE = 8192;

    private final int chunkSize;

    private M currentMessage;
    private int alreadyReadChunkSize;

    private State state = State.READ_HEADER;

    /**
     * Create a new {@link AbstractBinaryMemcacheDecoder} with default settings.
     */
    protected AbstractBinaryMemcacheDecoder() {
        this(DEFAULT_MAX_CHUNK_SIZE);
    }

    /**
     * Create a new {@link AbstractBinaryMemcacheDecoder} with custom settings.
     *
     * @param chunkSize the maximum chunk size of the payload.
     */
    protected AbstractBinaryMemcacheDecoder(int chunkSize) {
        checkPositiveOrZero(chunkSize, "chunkSize");

        this.chunkSize = chunkSize;
    }

    @Override
    protected void decode(ChannelHandlerContext ctx, ByteBuf in, List<Object> out) throws Exception {
        switch (state) {
            case READ_HEADER: try {
                if (in.readableBytes() < 24) {
                    return;
                }
                resetDecoder();

                currentMessage = decodeHeader(in);
                state = State.READ_EXTRAS;
            } catch (Exception e) {
                resetDecoder();
                out.add(invalidMessage(e));
                return;
            }
            case READ_EXTRAS: try {
                byte extrasLength = currentMessage.extrasLength();
                if (extrasLength > 0) {
                    if (in.readableBytes() < extrasLength) {
                        return;
                    }

                    currentMessage.setExtras(in.readRetainedSlice(extrasLength));
                }

                state = State.READ_KEY;
            } catch (Exception e) {
                resetDecoder();
                out.add(invalidMessage(e));
                return;
            }
            case READ_KEY: try {
                short keyLength = currentMessage.keyLength();
                if (keyLength > 0) {
                    if (in.readableBytes() < keyLength) {
                        return;
                    }

                    currentMessage.setKey(in.readRetainedSlice(keyLength));
                }
                out.add(currentMessage.retain());
                state = State.READ_CONTENT;
            } catch (Exception e) {
                resetDecoder();
                out.add(invalidMessage(e));
                return;
            }
            case READ_CONTENT: try {
                int valueLength = currentMessage.totalBodyLength()

Frequently Asked Questions

What is the AbstractBinaryMemcacheDecoder class?
AbstractBinaryMemcacheDecoder is a class in the netty codebase, defined in codec-memcache/src/main/java/io/netty/handler/codec/memcache/binary/AbstractBinaryMemcacheDecoder.java.
Where is AbstractBinaryMemcacheDecoder defined?
AbstractBinaryMemcacheDecoder is defined in codec-memcache/src/main/java/io/netty/handler/codec/memcache/binary/AbstractBinaryMemcacheDecoder.java at line 38.

Analyze Your Own Codebase

Get architecture documentation, dependency graphs, and domain analysis for your codebase in minutes.

Try Supermodel Free