Home / Class/ FixedRedisMessagePool Class — netty Architecture

FixedRedisMessagePool Class — netty Architecture

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

Entity Profile

Dependency Diagram

graph TD
  0a970cb8_ea2c_fe8d_2baf_8bc44e226bf7["FixedRedisMessagePool"]
  b50d93b3_4a36_5468_8a9a_7b3a829ede32["FixedRedisMessagePool.java"]
  0a970cb8_ea2c_fe8d_2baf_8bc44e226bf7 -->|defined in| b50d93b3_4a36_5468_8a9a_7b3a829ede32
  868ba199_2cc5_ee9a_5da3_b38f5b6724bf["FixedRedisMessagePool()"]
  0a970cb8_ea2c_fe8d_2baf_8bc44e226bf7 -->|method| 868ba199_2cc5_ee9a_5da3_b38f5b6724bf
  7ecd0b44_eeae_47bf_2705_96233e3a8471["SimpleStringRedisMessage()"]
  0a970cb8_ea2c_fe8d_2baf_8bc44e226bf7 -->|method| 7ecd0b44_eeae_47bf_2705_96233e3a8471
  903744d1_3176_ef8e_72e5_58d0e698b04e["ErrorRedisMessage()"]
  0a970cb8_ea2c_fe8d_2baf_8bc44e226bf7 -->|method| 903744d1_3176_ef8e_72e5_58d0e698b04e
  a9256733_6baf_8881_6293_ddf1f1bafafa["IntegerRedisMessage()"]
  0a970cb8_ea2c_fe8d_2baf_8bc44e226bf7 -->|method| a9256733_6baf_8881_6293_ddf1f1bafafa
  85862ee1_6ec6_24da_aa4d_fe85f2541633["getByteBufOfInteger()"]
  0a970cb8_ea2c_fe8d_2baf_8bc44e226bf7 -->|method| 85862ee1_6ec6_24da_aa4d_fe85f2541633

Relationship Graph

Source Code

codec-redis/src/main/java/io/netty/handler/codec/redis/FixedRedisMessagePool.java lines 31–186

@UnstableApi
public final class FixedRedisMessagePool implements RedisMessagePool {

    public enum RedisReplyKey {
        OK, PONG, QUEUED
    }

    public enum RedisErrorKey {
        ERR("ERR"),
        ERR_IDX("ERR index out of range"),
        ERR_NOKEY("ERR no such key"),
        ERR_SAMEOBJ("ERR source and destination objects are the same"),
        ERR_SYNTAX("ERR syntax error"),
        BUSY("BUSY Redis is busy running a script. You can only call SCRIPT KILL or SHUTDOWN NOSAVE."),
        BUSYKEY("BUSYKEY Target key name already exists."),
        EXECABORT("EXECABORT Transaction discarded because of previous errors."),
        LOADING("LOADING Redis is loading the dataset in memory"),
        MASTERDOWN("MASTERDOWN Link with MASTER is down and slave-serve-stale-data is set to 'no'."),
        MISCONF("MISCONF Redis is configured to save RDB snapshots, but is currently not able to persist on disk. " +
            "Commands that may modify the data set are disabled. Please check Redis logs for details " +
            "about the error."),
        NOREPLICAS("NOREPLICAS Not enough good slaves to write."),
        NOSCRIPT("NOSCRIPT No matching script. Please use EVAL."),
        OOM("OOM command not allowed when used memory > 'maxmemory'."),
        READONLY("READONLY You can't write against a read only slave."),
        WRONGTYPE("WRONGTYPE Operation against a key holding the wrong kind of value"),
        NOT_AUTH("NOAUTH Authentication required.");

        private final String msg;

        RedisErrorKey(String msg) {
            this.msg = msg;
        }

        @Override
        public String toString() {
            return msg;
        }
    }

    private static final long MIN_CACHED_INTEGER_NUMBER = RedisConstants.NULL_VALUE; // inclusive
    private static final long MAX_CACHED_INTEGER_NUMBER = 128; // exclusive

    // cached integer size cannot larger than `int` range because of Collection.
    private static final int SIZE_CACHED_INTEGER_NUMBER = (int) (MAX_CACHED_INTEGER_NUMBER - MIN_CACHED_INTEGER_NUMBER);

    /**
     * A shared object for {@link FixedRedisMessagePool}.
     */
    public static final FixedRedisMessagePool INSTANCE = new FixedRedisMessagePool();

    // internal caches.
    private final Map<ByteBuf, SimpleStringRedisMessage> byteBufToSimpleStrings;
    private final Map<String, SimpleStringRedisMessage> stringToSimpleStrings;
    private final Map<RedisReplyKey, SimpleStringRedisMessage> keyToSimpleStrings;
    private final Map<ByteBuf, ErrorRedisMessage> byteBufToErrors;
    private final Map<String, ErrorRedisMessage> stringToErrors;
    private final Map<RedisErrorKey, ErrorRedisMessage> keyToErrors;
    private final Map<ByteBuf, IntegerRedisMessage> byteBufToIntegers;
    private final LongObjectMap<IntegerRedisMessage> longToIntegers;
    private final LongObjectMap<byte[]> longToByteBufs;

    /**
     * Creates a {@link FixedRedisMessagePool} instance.
     */
    private FixedRedisMessagePool() {
        keyToSimpleStrings = new HashMap<RedisReplyKey, SimpleStringRedisMessage>(RedisReplyKey.values().length, 1.0f);
        stringToSimpleStrings = new HashMap<String, SimpleStringRedisMessage>(RedisReplyKey.values().length, 1.0f);
        byteBufToSimpleStrings = new HashMap<ByteBuf, SimpleStringRedisMessage>(RedisReplyKey.values().length, 1.0f);
        for (RedisReplyKey value : RedisReplyKey.values()) {
            ByteBuf key = Unpooled.unreleasableBuffer(Unpooled.wrappedBuffer(
                value.name().getBytes(CharsetUtil.UTF_8))).asReadOnly();
            SimpleStringRedisMessage message = new SimpleStringRedisMessage(new String(Unpooled.unreleasableBuffer(
                Unpooled.wrappedBuffer(value.name().getBytes(CharsetUtil.UTF_8))).array()));
            stringToSimpleStrings.put(value.name(), message);
            keyToSimpleStrings.put(value, message);
            byteBufToSimpleStrings.put(key, message);
        }

        keyToErrors = new HashMap<RedisErrorKey, ErrorRedisMessage>(RedisErrorKey.values().length, 1.0f);
        stringToErrors = new HashMap<String, ErrorRedisMessage>(RedisErrorKey.values().length, 1.0f);

Frequently Asked Questions

What is the FixedRedisMessagePool class?
FixedRedisMessagePool is a class in the netty codebase, defined in codec-redis/src/main/java/io/netty/handler/codec/redis/FixedRedisMessagePool.java.
Where is FixedRedisMessagePool defined?
FixedRedisMessagePool is defined in codec-redis/src/main/java/io/netty/handler/codec/redis/FixedRedisMessagePool.java at line 31.

Analyze Your Own Codebase

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

Try Supermodel Free