GeodeRedisServer (Apache Geode 1.4.0)
Date: 2018-01-29

org.apache.geode.redis

## Class GeodeRedisServer

- java.lang.Object
- - org.apache.geode.redis.GeodeRedisServer

-     @Experimental
      public class GeodeRedisServer
      extends java.lang.Object

  The GeodeRedisServer is a server that understands the Redis protocol. As commands are sent to the server, each command is picked up by a thread, interpreted and then executed and a response is sent back to the client. The default connection port is 6379 but that can be altered when run through GFSH or started through the provided static main class.

  Each Redis data type instance is stored in a separate `Region` except for the Strings and HyperLogLogs which are collectively stored in one Region respectively. That Region along with a meta data region used internally are protected so the client may not store keys with the name `REDIS_META_DATA_REGION` or `STRING_REGION`. The default Region type is `RegionShortcut.PARTITION` although this can be changed by specifying the SystemProperty "gemfireredis.regiontype" to a type defined by `RegionShortcut`. If the `NUM_THREADS_SYS_PROP_NAME` system property is set to 0, one thread per client will be created. Otherwise a worker thread pool of specified size is used or a default size of 4 * `Runtime.availableProcessors()` if the property is not set.

  Setting the AUTH password requires setting the property "redis-password" just as "redis-port" would be in xml or through GFSH.

  The supported commands are as follows:

  Supported String commands - APPEND, BITCOUNT, BITOP, BITPOS, DECR, DECRBY, GET, GETBIT, GETRANGE, GETSET, INCR, INCRBY, INCRBYFLOAT, MGET, MSET, MSETNX, PSETEX, SET, SETBIT, SETEX, SETNX, STRLEN

  Supported List commands - LINDEX, LLEN, LPOP, LPUSH, LPUSHX, LRANGE, LREM, LSET, LTRIM, RPOP, RPUSH, RPUSHX

  Supported Hash commands - HDEL, HEXISTS, HGET, HGETALL, HINCRBY, HINCRBYFLOAT, HKEYS, HMGET, HMSET, HSETNX, HLEN, HSCAN, HSET, HVALS

  Supported Set commands - SADD, SCARD, SDIFF, SDIFFSTORE, SINTER, SINTERSTORE, SISMEMBER, SMEMBERS, SMOVE, SREM, SPOP, SRANDMEMBER, SCAN, SUNION, SUNIONSTORE

  Supported SortedSet commands - ZADD, ZCARD, ZCOUNT, ZINCRBY, ZLEXCOUNT, ZRANGE, ZRANGEBYLEX, ZRANGEBYSCORE, ZRANK, ZREM, ZREMRANGEBYLEX, ZREMRANGEBYRANK, ZREMRANGEBYSCORE, ZREVRANGE, ZREVRANGEBYSCORE, ZREVRANK, ZSCAN, ZSCORE

  Supported HyperLogLog commands - PFADD, PFCOUNT, PFMERGE

  Supported Keys commands - DEL, DBSIZE, EXISTS, EXPIRE, EXPIREAT, FLUSHDB, FLUSHALL, KEYS, PERSIST, PEXPIRE, PEXPIREAT, PTTL, SCAN, TTL

  Supported Transaction commands - DISCARD, EXEC, MULTI

  Supported Server commands - AUTH, ECHO, PING, TIME, QUIT

  The command executors are not explicitly documented but the functionality can be found at Redis Commands

  Exceptions to the Redis Commands Documents:

  - Any command that removes keys and returns a count of removed entries will not return a total remove count but rather a count of how many entries have been removed that existed on the local vm, though all entries will be removed
  - Any command that returns a count of newly set members has an unspecified return value. The command will work just as the Redis protocol states but the count will not necessary reflect the number set compared to overridden.
  - Transactions work just as they would on a Redis instance, they are local transaction. Transactions cannot be executed on data that is not local to the executing server, that is on a partitioned region in a different server instance or on a persistent region that does not have transactions enabled. Also, you cannot watch or unwatch keys as all keys within a GemFire transaction are watched by default.

- - ### Field Summary

    Fields
    Modifier and Type | Field and Description
    --- | ---
    `static int` | `DEFAULT_REDIS_SERVER_PORT` The default Redis port as specified by their protocol, `DEFAULT_REDIS_SERVER_PORT`
    `static java.lang.String` | `DEFAULT_REGION_SYS_PROP_NAME` The system property name used to set the default `Region` creation type.
    `RegionShortcut` | `DEFAULT_REGION_TYPE` The actual `RegionShortcut` type specified by the system property "gemfireredis.regiontype".
    `static java.lang.String` | `HLL_REGION` The field that defines the name of the `Region` which holds all of the HyperLogLogs.
    `static java.lang.String` | `NUM_THREADS_SYS_PROP_NAME` System property name that can be used to set the number of threads to be used by the GeodeRedisServer
    `static java.lang.String` | `REDIS_META_DATA_REGION` The field that defines the name of the `Region` which holds all of the Redis meta data.
    `static java.lang.String` | `STRING_REGION` The field that defines the name of the `Region` which holds all of the strings.

  - ### Constructor Summary

    Constructors
    Constructor and Description
    `GeodeRedisServer(int port)` Constructor for `GeodeRedisServer` that will start the server on the given port and bind to the first non-loopback address
    `GeodeRedisServer(java.lang.String bindAddress, int port)` Constructor for `GeodeRedisServer` that will start the server and bind to the given address and port
    `GeodeRedisServer(java.lang.String bindAddress, int port, java.lang.String logLevel)` Constructor for `GeodeRedisServer` that will start the server and bind to the given address and port.

  - ### Method Summary

    All Methods Static Methods Instance Methods Concrete Methods
    Modifier and Type | Method and Description
    --- | ---
    `static void` | `main(java.lang.String[] args)` Static main method that allows the `GeodeRedisServer` to be started from the command line.
    `void` | `shutdown()` Shutdown method for `GeodeRedisServer`.
    `void` | `start()` This is function to call on a `GeodeRedisServer` instance to start it running

    - ### Methods inherited from class java.lang.Object

      `clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

- - ### Field Detail

    - #### DEFAULT_REDIS_SERVER_PORT

          public static final int DEFAULT_REDIS_SERVER_PORT

      The default Redis port as specified by their protocol, `DEFAULT_REDIS_SERVER_PORT`
      See Also:
        Constant Field Values

    - #### STRING_REGION

          public static final java.lang.String STRING_REGION

      The field that defines the name of the `Region` which holds all of the strings. The current value of this field is `STRING_REGION`.
      See Also:
        Constant Field Values

    - #### HLL_REGION

          public static final java.lang.String HLL_REGION

      The field that defines the name of the `Region` which holds all of the HyperLogLogs. The current value of this field is `HLL_REGION`.
      See Also:
        Constant Field Values

    - #### REDIS_META_DATA_REGION

          public static final java.lang.String REDIS_META_DATA_REGION

      The field that defines the name of the `Region` which holds all of the Redis meta data. The current value of this field is `REDIS_META_DATA_REGION`.
      See Also:
        Constant Field Values

    - #### DEFAULT_REGION_SYS_PROP_NAME

          public static final java.lang.String DEFAULT_REGION_SYS_PROP_NAME

      The system property name used to set the default `Region` creation type. The property name is `DEFAULT_REGION_SYS_PROP_NAME` and the acceptable values are types defined by `RegionShortcut`, i.e. "PARTITION" would be used for `RegionShortcut.PARTITION`.
      See Also:
        Constant Field Values

    - #### NUM_THREADS_SYS_PROP_NAME

          public static final java.lang.String NUM_THREADS_SYS_PROP_NAME

      System property name that can be used to set the number of threads to be used by the GeodeRedisServer
      See Also:
        Constant Field Values

    - #### DEFAULT_REGION_TYPE

          public final RegionShortcut DEFAULT_REGION_TYPE

      The actual `RegionShortcut` type specified by the system property "gemfireredis.regiontype".

  - ### Constructor Detail

    - #### GeodeRedisServer

          public GeodeRedisServer(int port)

      Constructor for `GeodeRedisServer` that will start the server on the given port and bind to the first non-loopback address
      Parameters:
        `port` - The port the server will bind to, will use 6379 by default

    - #### GeodeRedisServer

          public GeodeRedisServer(java.lang.String bindAddress,
                                  int port)

      Constructor for `GeodeRedisServer` that will start the server and bind to the given address and port
      Parameters:
        `bindAddress` - The address to which the server will attempt to bind to
        `port` - The port the server will bind to, will use 6379 by default if argument is less than or equal to 0

    - #### GeodeRedisServer

          public GeodeRedisServer(java.lang.String bindAddress,
                                  int port,
                                  java.lang.String logLevel)

      Constructor for `GeodeRedisServer` that will start the server and bind to the given address and port. Keep in mind that the log level configuration will only be set if a `Cache` does not already exist, if one already exists then setting that property will have no effect.
      Parameters:
        `bindAddress` - The address to which the server will attempt to bind to
        `port` - The port the server will bind to, will use 6379 by default if argument is less than or equal to 0
        `logLevel` - The logging level to be used by GemFire

  - ### Method Detail

    - #### start

          public void start()

      This is function to call on a `GeodeRedisServer` instance to start it running

    - #### shutdown

          public void shutdown()

      Shutdown method for `GeodeRedisServer`. This closes the `Cache`, interrupts all execution and forcefully closes all connections.

    - #### main

          public static void main(java.lang.String[] args)

      Static main method that allows the `GeodeRedisServer` to be started from the command line. The supported command line arguments are

      -port=
      -bind-address=
      -log-level=

      Parameters:
        `args` - Command line args