From 930a3d5f5869cc525e1a996f5107cd732e956c92 Mon Sep 17 00:00:00 2001 From: Christoph Manns Date: Wed, 7 Nov 2018 16:07:04 +0100 Subject: [PATCH 1/4] Adds support for redis sentinel deployments New RedisSentinelJedisProvider class which uses the JedisSentinelPool to do all the magic. Also a new config option to choose the redis_sentinel as DB type. --- .../conductor/core/config/Configuration.java | 2 +- .../jedis/RedisSentinelJedisProvider.java | 53 +++++++++++++++++++ .../conductor/bootstrap/ModulesProvider.java | 6 +++ .../conductor/server/RedisSentinelModule.java | 31 +++++++++++ 4 files changed, 91 insertions(+), 1 deletion(-) create mode 100644 redis-persistence/src/main/java/com/netflix/conductor/jedis/RedisSentinelJedisProvider.java create mode 100644 server/src/main/java/com/netflix/conductor/server/RedisSentinelModule.java diff --git a/core/src/main/java/com/netflix/conductor/core/config/Configuration.java b/core/src/main/java/com/netflix/conductor/core/config/Configuration.java index 25632367b7..fa63864fe4 100644 --- a/core/src/main/java/com/netflix/conductor/core/config/Configuration.java +++ b/core/src/main/java/com/netflix/conductor/core/config/Configuration.java @@ -212,6 +212,6 @@ default List getAdditionalModules() { enum DB { - REDIS, DYNOMITE, MEMORY, REDIS_CLUSTER, MYSQL + REDIS, DYNOMITE, MEMORY, REDIS_CLUSTER, MYSQL, REDIS_SENTINEL } } diff --git a/redis-persistence/src/main/java/com/netflix/conductor/jedis/RedisSentinelJedisProvider.java b/redis-persistence/src/main/java/com/netflix/conductor/jedis/RedisSentinelJedisProvider.java new file mode 100644 index 0000000000..ed486ff296 --- /dev/null +++ b/redis-persistence/src/main/java/com/netflix/conductor/jedis/RedisSentinelJedisProvider.java @@ -0,0 +1,53 @@ +package com.netflix.conductor.jedis; + +import com.google.common.collect.Lists; + +import com.netflix.conductor.dyno.DynomiteConfiguration; +import com.netflix.dyno.connectionpool.Host; +import com.netflix.dyno.connectionpool.HostSupplier; + +import org.apache.commons.pool2.impl.GenericObjectPoolConfig; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + +import java.util.HashSet; +import java.util.Set; + +import javax.inject.Inject; +import javax.inject.Provider; + +import redis.clients.jedis.JedisCommands; +import redis.clients.jedis.JedisSentinelPool; + +public class RedisSentinelJedisProvider implements Provider { + private static Logger logger = LoggerFactory.getLogger(RedisSentinelJedisProvider.class); + private final JedisSentinelPool jedisPool; + + @Inject + public RedisSentinelJedisProvider(HostSupplier hostSupplier, DynomiteConfiguration configuration) { + GenericObjectPoolConfig poolConfig = new GenericObjectPoolConfig(); + poolConfig.setMinIdle(5); + poolConfig.setMaxTotal(1000); + + logger.info("Starting conductor server using redis_sentinel and cluster " + configuration.getClusterName()); + + Set sentinels = new HashSet<>(); + + for (Host host : hostSupplier.getHosts()) { + sentinels.add(host.getHostName() + ":" + host.getPort()); + } + + jedisPool = new JedisSentinelPool(configuration.getClusterName(), sentinels, poolConfig); + } + + @Override + public JedisCommands get() { + return jedisPool.getResource(); + } + + @Override + protected void finalize() throws Throwable { + jedisPool.close(); + super.finalize(); + } +} diff --git a/server/src/main/java/com/netflix/conductor/bootstrap/ModulesProvider.java b/server/src/main/java/com/netflix/conductor/bootstrap/ModulesProvider.java index 350665a9b9..a8ce41bbc6 100644 --- a/server/src/main/java/com/netflix/conductor/bootstrap/ModulesProvider.java +++ b/server/src/main/java/com/netflix/conductor/bootstrap/ModulesProvider.java @@ -17,6 +17,7 @@ import com.netflix.conductor.server.JerseyModule; import com.netflix.conductor.server.LocalRedisModule; import com.netflix.conductor.server.RedisClusterModule; +import com.netflix.conductor.server.RedisSentinelModule; import com.netflix.conductor.server.ServerModule; import com.netflix.conductor.server.SwaggerModule; import org.slf4j.Logger; @@ -88,6 +89,11 @@ private List selectModulesToLoad() { modules.add(new RedisWorkflowModule()); logger.info("Starting conductor server using redis_cluster."); break; + case REDIS_SENTINEL: + modules.add(new RedisSentinelModule()); + modules.add(new RedisWorkflowModule()); + logger.info("Starting conductor server using redis_sentinel."); + break; } modules.add(new ElasticSearchV5Module()); diff --git a/server/src/main/java/com/netflix/conductor/server/RedisSentinelModule.java b/server/src/main/java/com/netflix/conductor/server/RedisSentinelModule.java new file mode 100644 index 0000000000..4222e94cee --- /dev/null +++ b/server/src/main/java/com/netflix/conductor/server/RedisSentinelModule.java @@ -0,0 +1,31 @@ +package com.netflix.conductor.server; + +import com.google.inject.AbstractModule; +import com.google.inject.name.Names; +import com.netflix.conductor.dyno.DynoShardSupplierProvider; +import com.netflix.conductor.dyno.DynomiteConfiguration; +import com.netflix.conductor.dyno.RedisQueuesProvider; +import com.netflix.conductor.dyno.SystemPropertiesDynomiteConfiguration; +import com.netflix.conductor.jedis.ConfigurationHostSupplierProvider; +import com.netflix.conductor.jedis.RedisSentinelJedisProvider; +import com.netflix.conductor.jedis.TokenMapSupplierProvider; +import com.netflix.dyno.connectionpool.HostSupplier; +import com.netflix.dyno.connectionpool.TokenMapSupplier; +import com.netflix.dyno.queues.ShardSupplier; + +import redis.clients.jedis.JedisCommands; + +public class RedisSentinelModule extends AbstractModule { + @Override + protected void configure(){ + bind(DynomiteConfiguration.class).to(SystemPropertiesDynomiteConfiguration.class); + bind(JedisCommands.class).toProvider(RedisSentinelJedisProvider.class).asEagerSingleton(); + bind(JedisCommands.class) + .annotatedWith(Names.named(RedisQueuesProvider.READ_CLIENT_INJECTION_NAME)) + .toProvider(RedisSentinelJedisProvider.class) + .asEagerSingleton(); + bind(HostSupplier.class).toProvider(ConfigurationHostSupplierProvider.class); + bind(TokenMapSupplier.class).toProvider(TokenMapSupplierProvider.class); + bind(ShardSupplier.class).toProvider(DynoShardSupplierProvider.class); + } +} From fa8e7a0aa88b790f68f7be1caad24e6094c47738 Mon Sep 17 00:00:00 2001 From: Christoph Manns Date: Wed, 21 Nov 2018 10:08:01 +0100 Subject: [PATCH 2/4] Fix the redis sentinel implementation The initial implementation was flawed, it worked only for a couple of seconds. We know have a wrapper class, which ensures a new resource is fetched from the pool and then closed if the requests finishes. --- .../conductor/jedis/JedisClusterSentinel.java | 1729 +++++++++++++++++ .../jedis/RedisSentinelJedisProvider.java | 10 +- 2 files changed, 1730 insertions(+), 9 deletions(-) create mode 100644 redis-persistence/src/main/java/com/netflix/conductor/jedis/JedisClusterSentinel.java diff --git a/redis-persistence/src/main/java/com/netflix/conductor/jedis/JedisClusterSentinel.java b/redis-persistence/src/main/java/com/netflix/conductor/jedis/JedisClusterSentinel.java new file mode 100644 index 0000000000..62fc7dff57 --- /dev/null +++ b/redis-persistence/src/main/java/com/netflix/conductor/jedis/JedisClusterSentinel.java @@ -0,0 +1,1729 @@ +package com.netflix.conductor.jedis; + +import java.util.List; +import java.util.Map; +import java.util.Map.Entry; +import java.util.Set; + +import redis.clients.jedis.BinaryClient.LIST_POSITION; +import redis.clients.jedis.BitPosParams; +import redis.clients.jedis.GeoCoordinate; +import redis.clients.jedis.GeoRadiusResponse; +import redis.clients.jedis.GeoUnit; +import redis.clients.jedis.Jedis; +import redis.clients.jedis.JedisCommands; +import redis.clients.jedis.JedisSentinelPool; +import redis.clients.jedis.ScanParams; +import redis.clients.jedis.ScanResult; +import redis.clients.jedis.SortingParams; +import redis.clients.jedis.Tuple; +import redis.clients.jedis.params.geo.GeoRadiusParam; +import redis.clients.jedis.params.sortedset.ZAddParams; +import redis.clients.jedis.params.sortedset.ZIncrByParams; + +public class JedisClusterSentinel implements JedisCommands { + + private final JedisSentinelPool jedisPool; + + public JedisClusterSentinel(JedisSentinelPool jedisPool) { + this.jedisPool = jedisPool; + } + + @Override + public String set(String key, String value) { + Jedis jedis = null; + try { + jedis = jedisPool.getResource(); + return jedis.set(key, value); + } finally { + if (jedis != null) + jedis.close(); + } + } + + @Override + public String set(String key, String value, String nxxx, String expx, long time) { + Jedis jedis = null; + try { + jedis = jedisPool.getResource(); + return jedis.set(key, value, nxxx, expx, time); + } finally { + if (jedis != null) + jedis.close(); + } + } + + @Override + public String set(String key, String value, String nxxx) { + Jedis jedis = null; + try { + jedis = jedisPool.getResource(); + return jedis.set(key, value, nxxx); + } finally { + if (jedis != null) + jedis.close(); + } + } + + @Override + public String get(String key) { + Jedis jedis = null; + try { + jedis = jedisPool.getResource(); + return jedis.get(key); + } finally { + if (jedis != null) + jedis.close(); + } + } + + @Override + public Boolean exists(String key) { + Jedis jedis = null; + try { + jedis = jedisPool.getResource(); + return jedis.exists(key); + } finally { + if (jedis != null) + jedis.close(); + } + } + + @Override + public Long persist(String key) { + Jedis jedis = null; + try { + jedis = jedisPool.getResource(); + return jedis.persist(key); + } finally { + if (jedis != null) + jedis.close(); + } + } + + @Override + public String type(String key) { + Jedis jedis = null; + try { + jedis = jedisPool.getResource(); + return jedis.type(key); + } finally { + if (jedis != null) + jedis.close(); + } + } + + @Override + public Long expire(String key, int seconds) { + Jedis jedis = null; + try { + jedis = jedisPool.getResource(); + return jedis.expire(key, seconds); + } finally { + if (jedis != null) + jedis.close(); + } + } + + @Override + public Long pexpire(String key, long milliseconds) { + Jedis jedis = null; + try { + jedis = jedisPool.getResource(); + return jedis.pexpire(key, milliseconds); + } finally { + if (jedis != null) + jedis.close(); + } + } + + @Override + public Long expireAt(String key, long unixTime) { + Jedis jedis = null; + try { + jedis = jedisPool.getResource(); + return jedis.expireAt(key, unixTime); + } finally { + if (jedis != null) + jedis.close(); + } + } + + @Override + public Long pexpireAt(String key, long millisecondsTimestamp) { + Jedis jedis = null; + try { + jedis = jedisPool.getResource(); + return jedis.pexpireAt(key, millisecondsTimestamp); + } finally { + if (jedis != null) + jedis.close(); + } + } + + @Override + public Long ttl(String key) { + Jedis jedis = null; + try { + jedis = jedisPool.getResource(); + return jedis.ttl(key); + } finally { + if (jedis != null) + jedis.close(); + } + } + + @Override + public Long pttl(String key) { + Jedis jedis = null; + try { + jedis = jedisPool.getResource(); + return jedis.pttl(key); + } finally { + if (jedis != null) + jedis.close(); + } + } + + @Override + public Boolean setbit(String key, long offset, boolean value) { + Jedis jedis = null; + try { + jedis = jedisPool.getResource(); + return jedis.setbit(key, offset, value); + } finally { + if (jedis != null) + jedis.close(); + } + } + + @Override + public Boolean setbit(String key, long offset, String value) { + Jedis jedis = null; + try { + jedis = jedisPool.getResource(); + return jedis.setbit(key, offset, value); + } finally { + if (jedis != null) + jedis.close(); + } + } + + @Override + public Boolean getbit(String key, long offset) { + Jedis jedis = null; + try { + jedis = jedisPool.getResource(); + return jedis.getbit(key, offset); + } finally { + if (jedis != null) + jedis.close(); + } + } + + @Override + public Long setrange(String key, long offset, String value) { + Jedis jedis = null; + try { + jedis = jedisPool.getResource(); + return jedis.setrange(key, offset, value); + } finally { + if (jedis != null) + jedis.close(); + } + } + + @Override + public String getrange(String key, long startOffset, long endOffset) { + Jedis jedis = null; + try { + jedis = jedisPool.getResource(); + return jedis.getrange(key, startOffset, endOffset); + } finally { + if (jedis != null) + jedis.close(); + } + } + + @Override + public String getSet(String key, String value) { + Jedis jedis = null; + try { + jedis = jedisPool.getResource(); + return jedis.getSet(key, value); + } finally { + if (jedis != null) + jedis.close(); + } + } + + @Override + public Long setnx(String key, String value) { + Jedis jedis = null; + try { + jedis = jedisPool.getResource(); + return jedis.setnx(key, value); + } finally { + if (jedis != null) + jedis.close(); + } + } + + @Override + public String setex(String key, int seconds, String value) { + Jedis jedis = null; + try { + jedis = jedisPool.getResource(); + return jedis.setex(key, seconds, value); + } finally { + if (jedis != null) + jedis.close(); + } + } + + @Override + public String psetex(String key, long milliseconds, String value) { + Jedis jedis = null; + try { + jedis = jedisPool.getResource(); + return jedis.psetex(key, milliseconds, value); + } finally { + if (jedis != null) + jedis.close(); + } + } + + @Override + public Long decrBy(String key, long integer) { + Jedis jedis = null; + try { + jedis = jedisPool.getResource(); + return jedis.decrBy(key, integer); + } finally { + if (jedis != null) + jedis.close(); + } + } + + @Override + public Long decr(String key) { + Jedis jedis = null; + try { + jedis = jedisPool.getResource(); + return jedis.decr(key); + } finally { + if (jedis != null) + jedis.close(); + } + } + + @Override + public Long incrBy(String key, long integer) { + Jedis jedis = null; + try { + jedis = jedisPool.getResource(); + return jedis.incrBy(key, integer); + } finally { + if (jedis != null) + jedis.close(); + } + } + + @Override + public Double incrByFloat(String key, double value) { + Jedis jedis = null; + try { + jedis = jedisPool.getResource(); + return jedis.incrByFloat(key, value); + } finally { + if (jedis != null) + jedis.close(); + } + } + + @Override + public Long incr(String key) { + Jedis jedis = null; + try { + jedis = jedisPool.getResource(); + return jedis.incr(key); + } finally { + if (jedis != null) + jedis.close(); + } + } + + @Override + public Long append(String key, String value) { + Jedis jedis = null; + try { + jedis = jedisPool.getResource(); + return jedis.append(key, value); + } finally { + if (jedis != null) + jedis.close(); + } + } + + @Override + public String substr(String key, int start, int end) { + Jedis jedis = null; + try { + jedis = jedisPool.getResource(); + return jedis.substr(key, start, end); + } finally { + if (jedis != null) + jedis.close(); + } + } + + @Override + public Long hset(String key, String field, String value) { + Jedis jedis = null; + try { + jedis = jedisPool.getResource(); + return jedis.hset(key, field, value); + } finally { + if (jedis != null) + jedis.close(); + } + } + + @Override + public String hget(String key, String field) { + Jedis jedis = null; + try { + jedis = jedisPool.getResource(); + return jedis.hget(key, field); + } finally { + if (jedis != null) + jedis.close(); + } + } + + @Override + public Long hsetnx(String key, String field, String value) { + Jedis jedis = null; + try { + jedis = jedisPool.getResource(); + return jedis.hsetnx(key, field, value); + } finally { + if (jedis != null) + jedis.close(); + } + } + + @Override + public String hmset(String key, Map hash) { + Jedis jedis = null; + try { + jedis = jedisPool.getResource(); + return jedis.hmset(key, hash); + } finally { + if (jedis != null) + jedis.close(); + } + } + + @Override + public List hmget(String key, String... fields) { + Jedis jedis = null; + try { + jedis = jedisPool.getResource(); + return jedis.hmget(key, fields); + } finally { + if (jedis != null) + jedis.close(); + } + } + + @Override + public Long hincrBy(String key, String field, long value) { + Jedis jedis = null; + try { + jedis = jedisPool.getResource(); + return jedis.hincrBy(key, field, value); + } finally { + if (jedis != null) + jedis.close(); + } + } + + @Override + public Double hincrByFloat(String key, String field, double value) { + Jedis jedis = null; + try { + jedis = jedisPool.getResource(); + return jedis.hincrByFloat(key, field, value); + } finally { + if (jedis != null) + jedis.close(); + } + } + + @Override + public Boolean hexists(String key, String field) { + Jedis jedis = null; + try { + jedis = jedisPool.getResource(); + return jedis.hexists(key, field); + } finally { + if (jedis != null) + jedis.close(); + } + } + + @Override + public Long hdel(String key, String... field) { + Jedis jedis = null; + try { + jedis = jedisPool.getResource(); + return jedis.hdel(key, field); + } finally { + if (jedis != null) + jedis.close(); + } + } + + @Override + public Long hlen(String key) { + Jedis jedis = null; + try { + jedis = jedisPool.getResource(); + return jedis.hlen(key); + } finally { + if (jedis != null) + jedis.close(); + } + } + + @Override + public Set hkeys(String key) { + Jedis jedis = null; + try { + jedis = jedisPool.getResource(); + return jedis.hkeys(key); + } finally { + if (jedis != null) + jedis.close(); + } + } + + @Override + public List hvals(String key) { + Jedis jedis = null; + try { + jedis = jedisPool.getResource(); + return jedis.hvals(key); + } finally { + if (jedis != null) + jedis.close(); + } + } + + @Override + public Map hgetAll(String key) { + Jedis jedis = null; + try { + jedis = jedisPool.getResource(); + return jedis.hgetAll(key); + } finally { + if (jedis != null) + jedis.close(); + } + } + + @Override + public Long rpush(String key, String... string) { + Jedis jedis = null; + try { + jedis = jedisPool.getResource(); + return jedis.rpush(key, string); + } finally { + if (jedis != null) + jedis.close(); + } + } + + @Override + public Long lpush(String key, String... string) { + Jedis jedis = null; + try { + jedis = jedisPool.getResource(); + return jedis.lpush(key, string); + } finally { + if (jedis != null) + jedis.close(); + } + } + + @Override + public Long llen(String key) { + Jedis jedis = null; + try { + jedis = jedisPool.getResource(); + return jedis.llen(key); + } finally { + if (jedis != null) + jedis.close(); + } + } + + @Override + public List lrange(String key, long start, long end) { + Jedis jedis = null; + try { + jedis = jedisPool.getResource(); + return jedis.lrange(key, start, end); + } finally { + if (jedis != null) + jedis.close(); + } + } + + @Override + public String ltrim(String key, long start, long end) { + Jedis jedis = null; + try { + jedis = jedisPool.getResource(); + return jedis.ltrim(key, start, end); + } finally { + if (jedis != null) + jedis.close(); + } + } + + @Override + public String lindex(String key, long index) { + Jedis jedis = null; + try { + jedis = jedisPool.getResource(); + return jedis.lindex(key, index); + } finally { + if (jedis != null) + jedis.close(); + } + } + + @Override + public String lset(String key, long index, String value) { + Jedis jedis = null; + try { + jedis = jedisPool.getResource(); + return jedis.lset(key, index, value); + } finally { + if (jedis != null) + jedis.close(); + } + } + + @Override + public Long lrem(String key, long count, String value) { + Jedis jedis = null; + try { + jedis = jedisPool.getResource(); + return jedis.lrem(key, count, value); + } finally { + if (jedis != null) + jedis.close(); + } + } + + @Override + public String lpop(String key) { + Jedis jedis = null; + try { + jedis = jedisPool.getResource(); + return jedis.lpop(key); + } finally { + if (jedis != null) + jedis.close(); + } + } + + @Override + public String rpop(String key) { + Jedis jedis = null; + try { + jedis = jedisPool.getResource(); + return jedis.rpop(key); + } finally { + if (jedis != null) + jedis.close(); + } + } + + @Override + public Long sadd(String key, String... member) { + Jedis jedis = null; + try { + jedis = jedisPool.getResource(); + return jedis.sadd(key, member); + } finally { + if (jedis != null) + jedis.close(); + } + } + + @Override + public Set smembers(String key) { + Jedis jedis = null; + try { + jedis = jedisPool.getResource(); + return jedis.smembers(key); + } finally { + if (jedis != null) + jedis.close(); + } + } + + @Override + public Long srem(String key, String... member) { + Jedis jedis = null; + try { + jedis = jedisPool.getResource(); + return jedis.srem(key, member); + } finally { + if (jedis != null) + jedis.close(); + } + } + + @Override + public String spop(String key) { + Jedis jedis = null; + try { + jedis = jedisPool.getResource(); + return jedis.spop(key); + } finally { + if (jedis != null) + jedis.close(); + } + } + + @Override + public Set spop(String key, long count) { + Jedis jedis = null; + try { + jedis = jedisPool.getResource(); + return jedis.spop(key, count); + } finally { + if (jedis != null) + jedis.close(); + } + } + + @Override + public Long scard(String key) { + Jedis jedis = null; + try { + jedis = jedisPool.getResource(); + return jedis.scard(key); + } finally { + if (jedis != null) + jedis.close(); + } + } + + @Override + public Boolean sismember(String key, String member) { + Jedis jedis = null; + try { + jedis = jedisPool.getResource(); + return jedis.sismember(key, member); + } finally { + if (jedis != null) + jedis.close(); + } + } + + @Override + public String srandmember(String key) { + Jedis jedis = null; + try { + jedis = jedisPool.getResource(); + return jedis.srandmember(key); + } finally { + if (jedis != null) + jedis.close(); + } + } + + @Override + public List srandmember(String key, int count) { + Jedis jedis = null; + try { + jedis = jedisPool.getResource(); + return jedis.srandmember(key, count); + } finally { + if (jedis != null) + jedis.close(); + } + } + + @Override + public Long strlen(String key) { + Jedis jedis = null; + try { + jedis = jedisPool.getResource(); + return jedis.strlen(key); + } finally { + if (jedis != null) + jedis.close(); + } + } + + @Override + public Long zadd(String key, double score, String member) { + Jedis jedis = null; + try { + jedis = jedisPool.getResource(); + return jedis.zadd(key, score, member); + } finally { + if (jedis != null) + jedis.close(); + } + } + + @Override + public Long zadd(String key, double score, String member, ZAddParams params) { + Jedis jedis = null; + try { + jedis = jedisPool.getResource(); + return jedis.zadd(key, score, member, params); + } finally { + if (jedis != null) + jedis.close(); + } + } + + @Override + public Long zadd(String key, Map scoreMembers) { + Jedis jedis = null; + try { + jedis = jedisPool.getResource(); + return jedis.zadd(key, scoreMembers); + } finally { + if (jedis != null) + jedis.close(); + } + } + + @Override + public Long zadd(String key, Map scoreMembers, ZAddParams params) { + Jedis jedis = null; + try { + jedis = jedisPool.getResource(); + return jedis.zadd(key, scoreMembers, params); + } finally { + if (jedis != null) + jedis.close(); + } + } + + @Override + public Set zrange(String key, long start, long end) { + Jedis jedis = null; + try { + jedis = jedisPool.getResource(); + return jedis.zrange(key, start, end); + } finally { + if (jedis != null) + jedis.close(); + } + } + + @Override + public Long zrem(String key, String... member) { + Jedis jedis = null; + try { + jedis = jedisPool.getResource(); + return jedis.zrem(key, member); + } finally { + if (jedis != null) + jedis.close(); + } + } + + @Override + public Double zincrby(String key, double score, String member) { + Jedis jedis = null; + try { + jedis = jedisPool.getResource(); + return jedis.zincrby(key, score, member); + } finally { + if (jedis != null) + jedis.close(); + } + } + + @Override + public Double zincrby(String key, double score, String member, ZIncrByParams params) { + Jedis jedis = null; + try { + jedis = jedisPool.getResource(); + return jedis.zincrby(key, score, member, params); + } finally { + if (jedis != null) + jedis.close(); + } + } + + @Override + public Long zrank(String key, String member) { + Jedis jedis = null; + try { + jedis = jedisPool.getResource(); + return jedis.zrank(key, member); + } finally { + if (jedis != null) + jedis.close(); + } + } + + @Override + public Long zrevrank(String key, String member) { + Jedis jedis = null; + try { + jedis = jedisPool.getResource(); + return jedis.zrevrank(key, member); + } finally { + if (jedis != null) + jedis.close(); + } + } + + @Override + public Set zrevrange(String key, long start, long end) { + Jedis jedis = null; + try { + jedis = jedisPool.getResource(); + return jedis.zrevrange(key, start, end); + } finally { + if (jedis != null) + jedis.close(); + } + } + + @Override + public Set zrangeWithScores(String key, long start, long end) { + Jedis jedis = null; + try { + jedis = jedisPool.getResource(); + return jedis.zrangeWithScores(key, start, end); + } finally { + if (jedis != null) + jedis.close(); + } + } + + @Override + public Set zrevrangeWithScores(String key, long start, long end) { + Jedis jedis = null; + try { + jedis = jedisPool.getResource(); + return jedis.zrevrangeWithScores(key, start, end); + } finally { + if (jedis != null) + jedis.close(); + } + } + + @Override + public Long zcard(String key) { + Jedis jedis = null; + try { + jedis = jedisPool.getResource(); + return jedis.zcard(key); + } finally { + if (jedis != null) + jedis.close(); + } + } + + @Override + public Double zscore(String key, String member) { + Jedis jedis = null; + try { + jedis = jedisPool.getResource(); + return jedis.zscore(key, member); + } finally { + if (jedis != null) + jedis.close(); + } + } + + @Override + public List sort(String key) { + Jedis jedis = null; + try { + jedis = jedisPool.getResource(); + return jedis.sort(key); + } finally { + if (jedis != null) + jedis.close(); + } + } + + @Override + public List sort(String key, SortingParams sortingParameters) { + Jedis jedis = null; + try { + jedis = jedisPool.getResource(); + return jedis.sort(key, sortingParameters); + } finally { + if (jedis != null) + jedis.close(); + } + } + + @Override + public Long zcount(String key, double min, double max) { + Jedis jedis = null; + try { + jedis = jedisPool.getResource(); + return jedis.zcount(key, min, max); + } finally { + if (jedis != null) + jedis.close(); + } + } + + @Override + public Long zcount(String key, String min, String max) { + Jedis jedis = null; + try { + jedis = jedisPool.getResource(); + return jedis.zcount(key, min, max); + } finally { + if (jedis != null) + jedis.close(); + } + } + + @Override + public Set zrangeByScore(String key, double min, double max) { + Jedis jedis = null; + try { + jedis = jedisPool.getResource(); + return jedis.zrangeByScore(key, min, max); + } finally { + if (jedis != null) + jedis.close(); + } + } + + @Override + public Set zrangeByScore(String key, String min, String max) { + Jedis jedis = null; + try { + jedis = jedisPool.getResource(); + return jedis.zrangeByScore(key, min, max); + } finally { + if (jedis != null) + jedis.close(); + } + } + + @Override + public Set zrevrangeByScore(String key, double max, double min) { + Jedis jedis = null; + try { + jedis = jedisPool.getResource(); + return jedis.zrevrangeByScore(key, max, min); + } finally { + if (jedis != null) + jedis.close(); + } + } + + @Override + public Set zrangeByScore(String key, double min, double max, int offset, int count) { + Jedis jedis = null; + try { + jedis = jedisPool.getResource(); + return jedis.zrangeByScore(key, min, max, offset, count); + } finally { + if (jedis != null) + jedis.close(); + } + } + + @Override + public Set zrevrangeByScore(String key, String max, String min) { + Jedis jedis = null; + try { + jedis = jedisPool.getResource(); + return jedis.zrevrangeByScore(key, max, min); + } finally { + if (jedis != null) + jedis.close(); + } + } + + @Override + public Set zrangeByScore(String key, String min, String max, int offset, int count) { + Jedis jedis = null; + try { + jedis = jedisPool.getResource(); + return jedis.zrangeByScore(key, min, max, offset, count); + } finally { + if (jedis != null) + jedis.close(); + } + } + + @Override + public Set zrevrangeByScore(String key, double max, double min, int offset, int count) { + Jedis jedis = null; + try { + jedis = jedisPool.getResource(); + return jedis.zrevrangeByScore(key, max, min, offset, count); + } finally { + if (jedis != null) + jedis.close(); + } + } + + @Override + public Set zrangeByScoreWithScores(String key, double min, double max) { + Jedis jedis = null; + try { + jedis = jedisPool.getResource(); + return jedis.zrangeByScoreWithScores(key, min, max); + } finally { + if (jedis != null) + jedis.close(); + } + } + + @Override + public Set zrevrangeByScoreWithScores(String key, double max, double min) { + Jedis jedis = null; + try { + jedis = jedisPool.getResource(); + return jedis.zrevrangeByScoreWithScores(key, max, min); + } finally { + if (jedis != null) + jedis.close(); + } + } + + @Override + public Set zrangeByScoreWithScores(String key, double min, double max, int offset, int count) { + Jedis jedis = null; + try { + jedis = jedisPool.getResource(); + return jedis.zrangeByScoreWithScores(key, min, max, offset, count); + } finally { + if (jedis != null) + jedis.close(); + } + } + + @Override + public Set zrevrangeByScore(String key, String max, String min, int offset, int count) { + Jedis jedis = null; + try { + jedis = jedisPool.getResource(); + return jedis.zrevrangeByScore(key, max, min, offset, count); + } finally { + if (jedis != null) + jedis.close(); + } + } + + @Override + public Set zrangeByScoreWithScores(String key, String min, String max) { + Jedis jedis = null; + try { + jedis = jedisPool.getResource(); + return jedis.zrangeByScoreWithScores(key, min, max); + } finally { + if (jedis != null) + jedis.close(); + } + } + + @Override + public Set zrevrangeByScoreWithScores(String key, String max, String min) { + Jedis jedis = null; + try { + jedis = jedisPool.getResource(); + return jedis.zrevrangeByScoreWithScores(key, max, min); + } finally { + if (jedis != null) + jedis.close(); + } + } + + @Override + public Set zrangeByScoreWithScores(String key, String min, String max, int offset, int count) { + Jedis jedis = null; + try { + jedis = jedisPool.getResource(); + return jedis.zrangeByScoreWithScores(key, min, max, offset, count); + } finally { + if (jedis != null) + jedis.close(); + } + } + + @Override + public Set zrevrangeByScoreWithScores(String key, double max, double min, int offset, int count) { + Jedis jedis = null; + try { + jedis = jedisPool.getResource(); + return jedis.zrevrangeByScoreWithScores(key, max, min, offset, count); + } finally { + if (jedis != null) + jedis.close(); + } + } + + @Override + public Set zrevrangeByScoreWithScores(String key, String max, String min, int offset, int count) { + Jedis jedis = null; + try { + jedis = jedisPool.getResource(); + return jedis.zrevrangeByScoreWithScores(key, max, min, offset, count); + } finally { + if (jedis != null) + jedis.close(); + } + } + + @Override + public Long zremrangeByRank(String key, long start, long end) { + Jedis jedis = null; + try { + jedis = jedisPool.getResource(); + return jedis.zremrangeByRank(key, start, end); + } finally { + if (jedis != null) + jedis.close(); + } + } + + @Override + public Long zremrangeByScore(String key, double start, double end) { + Jedis jedis = null; + try { + jedis = jedisPool.getResource(); + return jedis.zremrangeByScore(key, start, end); + } finally { + if (jedis != null) + jedis.close(); + } + } + + @Override + public Long zremrangeByScore(String key, String start, String end) { + Jedis jedis = null; + try { + jedis = jedisPool.getResource(); + return jedis.zremrangeByScore(key, start, end); + } finally { + if (jedis != null) + jedis.close(); + } + } + + @Override + public Long zlexcount(String key, String min, String max) { + Jedis jedis = null; + try { + jedis = jedisPool.getResource(); + return jedis.zlexcount(key, min, max); + } finally { + if (jedis != null) + jedis.close(); + } + } + + @Override + public Set zrangeByLex(String key, String min, String max) { + Jedis jedis = null; + try { + jedis = jedisPool.getResource(); + return jedis.zrangeByLex(key, min, max); + } finally { + if (jedis != null) + jedis.close(); + } + } + + @Override + public Set zrangeByLex(String key, String min, String max, int offset, int count) { + Jedis jedis = null; + try { + jedis = jedisPool.getResource(); + return jedis.zrangeByLex(key, min, max, offset, count); + } finally { + if (jedis != null) + jedis.close(); + } + } + + @Override + public Set zrevrangeByLex(String key, String max, String min) { + Jedis jedis = null; + try { + jedis = jedisPool.getResource(); + return jedis.zrevrangeByLex(key, max, min); + } finally { + if (jedis != null) + jedis.close(); + } + } + + @Override + public Set zrevrangeByLex(String key, String max, String min, int offset, int count) { + Jedis jedis = null; + try { + jedis = jedisPool.getResource(); + return jedis.zrevrangeByLex(key, max, min, offset, count); + } finally { + if (jedis != null) + jedis.close(); + } + } + + @Override + public Long zremrangeByLex(String key, String min, String max) { + Jedis jedis = null; + try { + jedis = jedisPool.getResource(); + return jedis.zremrangeByLex(key, min, max); + } finally { + if (jedis != null) + jedis.close(); + } + } + + @Override + public Long linsert(String key, LIST_POSITION where, String pivot, String value) { + Jedis jedis = null; + try { + jedis = jedisPool.getResource(); + return jedis.linsert(key, where, pivot, value); + } finally { + if (jedis != null) + jedis.close(); + } + } + + @Override + public Long lpushx(String key, String... string) { + Jedis jedis = null; + try { + jedis = jedisPool.getResource(); + return jedis.lpushx(key, string); + } finally { + if (jedis != null) + jedis.close(); + } + } + + @Override + public Long rpushx(String key, String... string) { + Jedis jedis = null; + try { + jedis = jedisPool.getResource(); + return jedis.rpushx(key, string); + } finally { + if (jedis != null) + jedis.close(); + } + } + + @Override + @Deprecated + public List blpop(String arg) { + Jedis jedis = null; + try { + jedis = jedisPool.getResource(); + return jedis.blpop(arg); + } finally { + if (jedis != null) + jedis.close(); + } + } + + @Override + public List blpop(int timeout, String key) { + Jedis jedis = null; + try { + jedis = jedisPool.getResource(); + return jedis.blpop(timeout, key); + } finally { + if (jedis != null) + jedis.close(); + } + } + + @Override + @Deprecated + public List brpop(String arg) { + Jedis jedis = null; + try { + jedis = jedisPool.getResource(); + return jedis.brpop(arg); + } finally { + if (jedis != null) + jedis.close(); + } + } + + @Override + public List brpop(int timeout, String key) { + Jedis jedis = null; + try { + jedis = jedisPool.getResource(); + return jedis.brpop(timeout, key); + } finally { + if (jedis != null) + jedis.close(); + } + } + + @Override + public Long del(String key) { + Jedis jedis = null; + try { + jedis = jedisPool.getResource(); + return jedis.del(key); + } finally { + if (jedis != null) + jedis.close(); + } + } + + @Override + public String echo(String string) { + Jedis jedis = null; + try { + jedis = jedisPool.getResource(); + return jedis.echo(string); + } finally { + if (jedis != null) + jedis.close(); + } + } + + @Override + public Long move(String key, int dbIndex) { + Jedis jedis = null; + try { + jedis = jedisPool.getResource(); + return jedis.move(key, dbIndex); + } finally { + if (jedis != null) + jedis.close(); + } + } + + @Override + public Long bitcount(String key) { + Jedis jedis = null; + try { + jedis = jedisPool.getResource(); + return jedis.bitcount(key); + } finally { + if (jedis != null) + jedis.close(); + } + } + + @Override + public Long bitcount(String key, long start, long end) { + Jedis jedis = null; + try { + jedis = jedisPool.getResource(); + return jedis.bitcount(key, start, end); + } finally { + if (jedis != null) + jedis.close(); + } + } + + @Override + public Long bitpos(String key, boolean value) { + Jedis jedis = null; + try { + jedis = jedisPool.getResource(); + return jedis.bitpos(key, value); + } finally { + if (jedis != null) + jedis.close(); + } + } + + @Override + public Long bitpos(String key, boolean value, BitPosParams params) { + Jedis jedis = null; + try { + jedis = jedisPool.getResource(); + return jedis.bitpos(key, value, params); + } finally { + if (jedis != null) + jedis.close(); + } + } + + @Override + @Deprecated + public ScanResult> hscan(String key, int cursor) { + Jedis jedis = null; + try { + jedis = jedisPool.getResource(); + return jedis.hscan(key, cursor); + } finally { + if (jedis != null) + jedis.close(); + } + } + + @Override + @Deprecated + public ScanResult sscan(String key, int cursor) { + Jedis jedis = null; + try { + jedis = jedisPool.getResource(); + return jedis.sscan(key, cursor); + } finally { + if (jedis != null) + jedis.close(); + } + } + + @Override + @Deprecated + public ScanResult zscan(String key, int cursor) { + Jedis jedis = null; + try { + jedis = jedisPool.getResource(); + return jedis.zscan(key, cursor); + } finally { + if (jedis != null) + jedis.close(); + } + } + + @Override + public ScanResult> hscan(String key, String cursor) { + Jedis jedis = null; + try { + jedis = jedisPool.getResource(); + return jedis.hscan(key, cursor); + } finally { + if (jedis != null) + jedis.close(); + } + } + + @Override + public ScanResult> hscan(String key, String cursor, ScanParams params) { + Jedis jedis = null; + try { + jedis = jedisPool.getResource(); + return jedis.hscan(key, cursor, params); + } finally { + if (jedis != null) + jedis.close(); + } + } + + @Override + public ScanResult sscan(String key, String cursor) { + Jedis jedis = null; + try { + jedis = jedisPool.getResource(); + return jedis.sscan(key, cursor); + } finally { + if (jedis != null) + jedis.close(); + } + } + + @Override + public ScanResult sscan(String key, String cursor, ScanParams params) { + Jedis jedis = null; + try { + jedis = jedisPool.getResource(); + return jedis.sscan(key, cursor, params); + } finally { + if (jedis != null) + jedis.close(); + } + } + + @Override + public ScanResult zscan(String key, String cursor) { + Jedis jedis = null; + try { + jedis = jedisPool.getResource(); + return jedis.zscan(key, cursor); + } finally { + if (jedis != null) + jedis.close(); + } + } + + @Override + public ScanResult zscan(String key, String cursor, ScanParams params) { + Jedis jedis = null; + try { + jedis = jedisPool.getResource(); + return jedis.zscan(key, cursor, params); + } finally { + if (jedis != null) + jedis.close(); + } + } + + @Override + public Long pfadd(String key, String... elements) { + Jedis jedis = null; + try { + jedis = jedisPool.getResource(); + return jedis.pfadd(key, elements); + } finally { + if (jedis != null) + jedis.close(); + } + } + + @Override + public long pfcount(String key) { + Jedis jedis = null; + try { + jedis = jedisPool.getResource(); + return jedis.pfcount(key); + } finally { + if (jedis != null) + jedis.close(); + } + } + + @Override + public Long geoadd(String key, double longitude, double latitude, String member) { + Jedis jedis = null; + try { + jedis = jedisPool.getResource(); + return jedis.geoadd(key, longitude, latitude, member); + } finally { + if (jedis != null) + jedis.close(); + } + } + + @Override + public Long geoadd(String key, Map memberCoordinateMap) { + Jedis jedis = null; + try { + jedis = jedisPool.getResource(); + return jedis.geoadd(key, memberCoordinateMap); + } finally { + if (jedis != null) + jedis.close(); + } + } + + @Override + public Double geodist(String key, String member1, String member2) { + Jedis jedis = null; + try { + jedis = jedisPool.getResource(); + return jedis.geodist(key, member1, member2); + } finally { + if (jedis != null) + jedis.close(); + } + } + + @Override + public Double geodist(String key, String member1, String member2, GeoUnit unit) { + Jedis jedis = null; + try { + jedis = jedisPool.getResource(); + return jedis.geodist(key, member1, member2, unit); + } finally { + if (jedis != null) + jedis.close(); + } + } + + @Override + public List geohash(String key, String... members) { + Jedis jedis = null; + try { + jedis = jedisPool.getResource(); + return jedis.geohash(key, members); + } finally { + if (jedis != null) + jedis.close(); + } + } + + @Override + public List geopos(String key, String... members) { + Jedis jedis = null; + try { + jedis = jedisPool.getResource(); + return jedis.geopos(key, members); + } finally { + if (jedis != null) + jedis.close(); + } + } + + @Override + public List georadius(String key, double longitude, double latitude, double radius, GeoUnit unit) { + Jedis jedis = null; + try { + jedis = jedisPool.getResource(); + return jedis.georadius(key, longitude, latitude, radius, unit); + } finally { + if (jedis != null) + jedis.close(); + } + } + + @Override + public List georadius(String key, double longitude, double latitude, double radius, GeoUnit unit, + GeoRadiusParam param) { + return null; + } + + @Override + public List georadiusByMember(String key, String member, double radius, GeoUnit unit) { + Jedis jedis = null; + try { + jedis = jedisPool.getResource(); + return jedis.georadiusByMember(key, member, radius, unit); + } finally { + if (jedis != null) + jedis.close(); + } + } + + @Override + public List georadiusByMember(String key, String member, double radius, GeoUnit unit, + GeoRadiusParam param) { + return null; + } + + @Override + public List bitfield(String key, String... arguments) { + Jedis jedis = null; + try { + jedis = jedisPool.getResource(); + return jedis.bitfield(key, arguments); + } finally { + if (jedis != null) + jedis.close(); + } + } + +} \ No newline at end of file diff --git a/redis-persistence/src/main/java/com/netflix/conductor/jedis/RedisSentinelJedisProvider.java b/redis-persistence/src/main/java/com/netflix/conductor/jedis/RedisSentinelJedisProvider.java index ed486ff296..a142c1ce41 100644 --- a/redis-persistence/src/main/java/com/netflix/conductor/jedis/RedisSentinelJedisProvider.java +++ b/redis-persistence/src/main/java/com/netflix/conductor/jedis/RedisSentinelJedisProvider.java @@ -1,7 +1,5 @@ package com.netflix.conductor.jedis; -import com.google.common.collect.Lists; - import com.netflix.conductor.dyno.DynomiteConfiguration; import com.netflix.dyno.connectionpool.Host; import com.netflix.dyno.connectionpool.HostSupplier; @@ -42,12 +40,6 @@ public RedisSentinelJedisProvider(HostSupplier hostSupplier, DynomiteConfigurati @Override public JedisCommands get() { - return jedisPool.getResource(); - } - - @Override - protected void finalize() throws Throwable { - jedisPool.close(); - super.finalize(); + return new JedisClusterSentinel(jedisPool); } } From 82250b41df29070c109e68c48cd9b6a9b4c7261b Mon Sep 17 00:00:00 2001 From: Christoph Manns Date: Thu, 22 Nov 2018 17:30:23 +0100 Subject: [PATCH 3/4] Adds unit tests --- .../jedis/JedisClusterSentinelTest.java | 580 ++++++++++++++++++ 1 file changed, 580 insertions(+) create mode 100644 redis-persistence/src/test/java/com/netflix/conductor/jedis/JedisClusterSentinelTest.java diff --git a/redis-persistence/src/test/java/com/netflix/conductor/jedis/JedisClusterSentinelTest.java b/redis-persistence/src/test/java/com/netflix/conductor/jedis/JedisClusterSentinelTest.java new file mode 100644 index 0000000000..83b1786ce0 --- /dev/null +++ b/redis-persistence/src/test/java/com/netflix/conductor/jedis/JedisClusterSentinelTest.java @@ -0,0 +1,580 @@ +package com.netflix.conductor.jedis; + +import static org.mockito.Mockito.mock; +import static org.mockito.Mockito.when; + +import java.util.HashMap; + +import org.junit.Before; +import org.junit.Test; + +import redis.clients.jedis.BinaryClient.LIST_POSITION; +import redis.clients.jedis.GeoUnit; +import redis.clients.jedis.Jedis; +import redis.clients.jedis.JedisSentinelPool; +import redis.clients.jedis.ScanParams; +import redis.clients.jedis.SortingParams; +import redis.clients.jedis.params.geo.GeoRadiusParam; +import redis.clients.jedis.params.sortedset.ZAddParams; +import redis.clients.jedis.params.sortedset.ZIncrByParams; + +public class JedisClusterSentinelTest { + private final Jedis jedis = mock(Jedis.class); + private final JedisSentinelPool jedisPool = mock(JedisSentinelPool.class); + private final JedisClusterSentinel jedisCluster = new JedisClusterSentinel(jedisPool); + + @Before + public void init() { + when(this.jedisPool.getResource()).thenReturn(this.jedis); + } + + @Test + public void testSet() throws Exception { + jedisCluster.set("key", "value"); + jedisCluster.set("key", "value", "nxxx"); + jedisCluster.set("key", "value", "nxxx", "expx", 1337); + } + + @Test + public void testGet() { + jedisCluster.get("key"); + } + + @Test + public void testExists() { + jedisCluster.exists("key"); + } + + @Test + public void testPersist() { + jedisCluster.persist("key"); + } + + @Test + public void testType() { + jedisCluster.type("key"); + } + + @Test + public void testExpire() { + jedisCluster.expire("key", 1337); + } + + @Test + public void testPexpire() { + jedisCluster.pexpire("key", 1337); + } + + @Test + public void testExpireAt() { + jedisCluster.expireAt("key", 1337); + } + + @Test + public void testPexpireAt() { + jedisCluster.pexpireAt("key", 1337); + } + + @Test + public void testTtl() { + jedisCluster.ttl("key"); + } + + @Test + public void testPttl() { + jedisCluster.pttl("key"); + } + + @Test + public void testSetbit() { + jedisCluster.setbit("key", 1337, "value"); + jedisCluster.setbit("key", 1337, true); + } + + @Test + public void testGetbit() { + jedisCluster.getbit("key", 1337); + } + + @Test + public void testSetrange() { + jedisCluster.setrange("key", 1337, "value"); + } + + @Test + public void testGetrange() { + jedisCluster.getrange("key", 1337, 1338); + } + + @Test + public void testGetSet() { + jedisCluster.getSet("key", "value"); + } + + @Test + public void testSetnx() { + jedisCluster.setnx("test", "value"); + } + + @Test + public void testSetex() { + jedisCluster.setex("key", 1337, "value"); + } + + @Test + public void testPsetex() { + jedisCluster.psetex("key", 1337, "value"); + } + + @Test + public void testDecrBy() { + jedisCluster.decrBy("key", 1337); + } + + @Test + public void testDecr() { + jedisCluster.decr("key"); + } + + @Test + public void testIncrBy() { + jedisCluster.incrBy("key", 1337); + } + + @Test + public void testIncrByFloat() { + jedisCluster.incrByFloat("key", 1337); + } + + @Test + public void testIncr() { + jedisCluster.incr("key"); + } + + @Test + public void testAppend() { + jedisCluster.append("key", "value"); + } + + @Test + public void testSubstr() { + jedisCluster.substr("key", 1337, 1338); + } + + @Test + public void testHset() { + jedisCluster.hset("key", "field", "value"); + } + + @Test + public void testHget() { + jedisCluster.hget("key", "field"); + } + + @Test + public void testHsetnx() { + jedisCluster.hsetnx("key", "field", "value"); + } + + @Test + public void testHmset() { + jedisCluster.hmset("key", new HashMap()); + } + + @Test + public void testHmget() { + jedisCluster.hmget("key", "fields"); + } + + @Test + public void testHincrBy() { + jedisCluster.hincrBy("key", "field", 1337); + } + + @Test + public void testHincrByFloat() { + jedisCluster.hincrByFloat("key", "field", 1337); + } + + @Test + public void testHexists() { + jedisCluster.hexists("key", "field"); + } + + @Test + public void testHdel() { + jedisCluster.hdel("key", "field"); + } + + @Test + public void testHlen() { + jedisCluster.hlen("key"); + } + + @Test + public void testHkeys() { + jedisCluster.hkeys("key"); + } + + @Test + public void testHvals() { + jedisCluster.hvals("key"); + } + + @Test + public void testGgetAll() { + jedisCluster.hgetAll("key"); + } + + @Test + public void testRpush() { + jedisCluster.rpush("key", "string"); + } + + @Test + public void testLpush() { + jedisCluster.lpush("key", "string"); + } + + @Test + public void testLlen() { + jedisCluster.llen("key"); + } + + @Test + public void testLrange() { + jedisCluster.lrange("key", 1337, 1338); + } + + @Test + public void testLtrim() { + jedisCluster.ltrim("key", 1337, 1338); + } + + @Test + public void testLindex() { + jedisCluster.lindex("key", 1337); + } + + @Test + public void testLset() { + jedisCluster.lset("key", 1337, "value"); + } + + @Test + public void testLrem() { + jedisCluster.lrem("key", 1337, "value"); + } + + @Test + public void testLpop() { + jedisCluster.lpop("key"); + } + + @Test + public void testRpop() { + jedisCluster.rpop("key"); + } + + @Test + public void testSadd() { + jedisCluster.sadd("key", "member"); + } + + @Test + public void testSmembers() { + jedisCluster.smembers("key"); + } + + @Test + public void testSrem() { + jedisCluster.srem("key", "member"); + } + + @Test + public void testSpop() { + jedisCluster.spop("key"); + jedisCluster.spop("key", 1337); + } + + @Test + public void testScard() { + jedisCluster.scard("key"); + } + + @Test + public void testSismember() { + jedisCluster.sismember("key", "member"); + } + + @Test + public void testSrandmember() { + jedisCluster.srandmember("key"); + jedisCluster.srandmember("key", 1337); + } + + @Test + public void testStrlen() { + jedisCluster.strlen("key"); + } + + @Test + public void testZadd() { + jedisCluster.zadd("key", new HashMap<>()); + jedisCluster.zadd("key", new HashMap<>(), ZAddParams.zAddParams()); + jedisCluster.zadd("key", 1337, "members"); + jedisCluster.zadd("key", 1337, "members", ZAddParams.zAddParams()); + } + + @Test + public void testZrange() { + jedisCluster.zrange("key", 1337, 1338); + } + + @Test + public void testZrem() { + jedisCluster.zrem("key", "member"); + } + + @Test + public void testZincrby() { + jedisCluster.zincrby("key", 1337, "member"); + jedisCluster.zincrby("key", 1337, "member", ZIncrByParams.zIncrByParams()); + } + + @Test + public void testZrank() { + jedisCluster.zrank("key", "member"); + } + + @Test + public void testZrevrank() { + jedisCluster.zrevrank("key", "member"); + } + + @Test + public void testZrevrange() { + jedisCluster.zrevrange("key", 1337, 1338); + } + + @Test + public void testZrangeWithScores() { + jedisCluster.zrangeWithScores("key", 1337, 1338); + } + + @Test + public void testZrevrangeWithScores() { + jedisCluster.zrevrangeWithScores("key", 1337, 1338); + } + + @Test + public void testZcard() { + jedisCluster.zcard("key"); + } + + @Test + public void testZscore() { + jedisCluster.zscore("key", "member"); + } + + @Test + public void testSort() { + jedisCluster.sort("key"); + jedisCluster.sort("key", new SortingParams()); + } + + @Test + public void testZcount() { + jedisCluster.zcount("key", "min", "max"); + jedisCluster.zcount("key", 1337, 1338); + } + + @Test + public void testZrangeByScore() { + jedisCluster.zrangeByScore("key", "min", "max"); + jedisCluster.zrangeByScore("key", 1337, 1338); + jedisCluster.zrangeByScore("key", "min", "max", 1337, 1338); + jedisCluster.zrangeByScore("key", 1337, 1338, 1339, 1340); + } + + + @Test + public void testZrevrangeByScore() { + jedisCluster.zrevrangeByScore("key", "max", "min"); + jedisCluster.zrevrangeByScore("key", 1337, 1338); + jedisCluster.zrevrangeByScore("key", "max", "min", 1337, 1338); + jedisCluster.zrevrangeByScore("key", 1337, 1338, 1339, 1340); + } + + @Test + public void testZrangeByScoreWithScores() { + jedisCluster.zrangeByScoreWithScores("key", "min", "max"); + jedisCluster.zrangeByScoreWithScores("key", "min", "max", 1337, 1338); + jedisCluster.zrangeByScoreWithScores("key", 1337, 1338); + jedisCluster.zrangeByScoreWithScores("key", 1337, 1338, 1339, 1340); + } + + @Test + public void testZrevrangeByScoreWithScores() { + jedisCluster.zrevrangeByScoreWithScores("key", "max", "min"); + jedisCluster.zrevrangeByScoreWithScores("key", "max", "min", 1337, 1338); + jedisCluster.zrevrangeByScoreWithScores("key", 1337, 1338); + jedisCluster.zrevrangeByScoreWithScores("key", 1337, 1338, 1339, 1340); + } + + @Test + public void testZremrangeByRank() { + jedisCluster.zremrangeByRank("key", 1337, 1338); + } + + @Test + public void testZremrangeByScore() { + jedisCluster.zremrangeByScore("key", "start", "end"); + jedisCluster.zremrangeByScore("key", 1337, 1338); + } + + @Test + public void testZlexcount() { + jedisCluster.zlexcount("key", "min", "max"); + } + + @Test + public void testZrangeByLex() { + jedisCluster.zrangeByLex("key", "min", "max"); + jedisCluster.zrangeByLex("key", "min", "max", 1337, 1338); + } + + @Test + public void testZrevrangeByLex() { + jedisCluster.zrevrangeByLex("key", "max", "min"); + jedisCluster.zrevrangeByLex("key", "max", "min", 1337, 1338); + } + + @Test + public void testZremrangeByLex() { + jedisCluster.zremrangeByLex("key", "min", "max"); + } + + @Test + public void testLinsert() { + jedisCluster.linsert("key", LIST_POSITION.AFTER, "pivot", "value"); + } + + @Test + public void testLpushx() { + jedisCluster.lpushx("key", "string"); + } + + @Test + public void testRpushx() { + jedisCluster.rpushx("key", "string"); + } + + @Test + public void testBlpop() { + jedisCluster.blpop("arg"); + jedisCluster.blpop(1337, "arg"); + } + + @Test + public void testBrpop() { + jedisCluster.brpop("arg"); + jedisCluster.brpop(1337, "arg"); + } + + @Test + public void testDel() { + jedisCluster.del("key"); + } + + @Test + public void testEcho() { + jedisCluster.echo("string"); + } + + @Test + public void testMove() { + jedisCluster.move("key", 1337); + } + + @Test + public void testBitcount() { + jedisCluster.bitcount("key"); + jedisCluster.bitcount("key", 1337, 1338); + } + + @Test + public void testBitpos() { + jedisCluster.bitpos("key", true); + } + + @Test + public void testHscan() { + jedisCluster.hscan("key", "cursor"); + jedisCluster.hscan("key", "cursor", new ScanParams()); + jedisCluster.hscan("key", 1337); + } + + @Test + public void testSscan() { + jedisCluster.sscan("key", "cursor"); + jedisCluster.sscan("key", "cursor", new ScanParams()); + jedisCluster.sscan("key", 1337); + } + + @Test + public void testZscan() { + jedisCluster.zscan("key", "cursor"); + jedisCluster.zscan("key", "cursor", new ScanParams()); + jedisCluster.zscan("key", 1337); + } + + @Test + public void testPfadd() { + jedisCluster.pfadd("key", "elements"); + } + + @Test + public void testPfcount() { + jedisCluster.pfcount("key"); + } + + @Test + public void testGeoadd() { + jedisCluster.geoadd("key", new HashMap<>()); + jedisCluster.geoadd("key", 1337, 1338, "member"); + } + + @Test + public void testGeodist() { + jedisCluster.geodist("key", "member1", "member2"); + jedisCluster.geodist("key", "member1", "member2", GeoUnit.KM); + } + + @Test + public void testGeohash() { + jedisCluster.geohash("key", "members"); + } + + @Test + public void testGeopos() { + jedisCluster.geopos("key", "members"); + } + + @Test + public void testGeoradius() { + jedisCluster.georadius("key", 1337, 1338, 32, GeoUnit.KM); + jedisCluster.georadius("key", 1337, 1338, 32, GeoUnit.KM, GeoRadiusParam.geoRadiusParam()); + } + + @Test + public void testGeoradiusByMember() { + jedisCluster.georadiusByMember("key", "member", 1337, GeoUnit.KM); + jedisCluster.georadiusByMember("key", "member", 1337, GeoUnit.KM, GeoRadiusParam.geoRadiusParam()); + } + + @Test + public void testBitfield() { + jedisCluster.bitfield("key", "arguments"); + } +} \ No newline at end of file From ae12ab097c5b77f38e1d800bad4e678ec8385f3f Mon Sep 17 00:00:00 2001 From: Christoph Manns Date: Mon, 10 Dec 2018 10:44:36 +0100 Subject: [PATCH 4/4] Added documentation about the configuration of redis_sentinel --- docs/docs/server/index.md | 3 ++- server/README.md | 5 +++-- 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/docs/docs/server/index.md b/docs/docs/server/index.md index 3aa0783464..fa5185a53f 100644 --- a/docs/docs/server/index.md +++ b/docs/docs/server/index.md @@ -58,6 +58,7 @@ log4j.properties file path is optional and allows finer control over the logging # memory : The data is stored in memory and lost when the server dies. Useful for testing or demo # redis : non-Dynomite based redis instance # redis_cluster: AWS Elasticache Redis (cluster mode enabled).See [http://docs.aws.amazon.com/AmazonElastiCache/latest/UserGuide/Clusters.Create.CON.RedisCluster.html] +# redis_sentinel: Redis HA with Redis Sentinel. See [https://redis.io/topics/sentinel] # dynomite : Dynomite cluster. Use this for HA configuration. db=dynomite @@ -109,7 +110,7 @@ Conductor server can be used with a standlone Redis or ElastiCache server. To c ```properties db=redis -# For AWS Elasticache Redis (cluster mode enabled) the format is configuration_endpoint:port:us-east-1e. +# For AWS Elasticache Redis (cluster mode enabled) the format is configuration_endpoint:port:us-east-1e. # The region in this case does not matter workflow.dynomite.cluster.hosts=server_address:server_port:us-east-1e workflow.dynomite.connection.maxConnsPerHost=31 diff --git a/server/README.md b/server/README.md index 6b4610f085..ace313b7b6 100644 --- a/server/README.md +++ b/server/README.md @@ -10,13 +10,14 @@ At the minimum, provide these options through VM or Config file: `workflow.elasticsearch.url` `workflow.elasticsearch.index.name` -### Database persistence model -Possible values are memory, redis, redis_cluster and dynomite. +### Database persistence model +Possible values are memory, redis, redis_cluster, redis_sentinel and dynomite. If omitted, the persistence used is memory memory : The data is stored in memory and lost when the server dies. Useful for testing or demo redis : non-Dynomite based redis instance redis_cluster: AWS Elasticache Redis (cluster mode enabled).See [http://docs.aws.amazon.com/AmazonElastiCache/latest/UserGuide/Clusters.Create.CON.RedisCluster.html] +redis_sentinel: Redis HA with Redis Sentinel. See [https://redis.io/topics/sentinel] dynomite : Dynomite cluster. Use this for HA configuration. `db=dynomite`