diff --git a/src/main/java/redis/clients/jedis/JedisCluster.java b/src/main/java/redis/clients/jedis/JedisCluster.java index 1a2bdb99d8..75dbb8b511 100644 --- a/src/main/java/redis/clients/jedis/JedisCluster.java +++ b/src/main/java/redis/clients/jedis/JedisCluster.java @@ -12,14 +12,13 @@ public class JedisCluster implements JedisCommands, BasicCommands, Closeable { public static final short HASHSLOTS = 16384; - private static final int DEFAULT_TIMEOUT = 1; + private static final int DEFAULT_TIMEOUT = 2000; private static final int DEFAULT_MAX_REDIRECTIONS = 5; public static enum Reset { SOFT, HARD } - private int timeout; private int maxRedirections; private JedisClusterConnectionHandler connectionHandler; @@ -46,8 +45,8 @@ public JedisCluster(Set nodes, int timeout, final GenericObjectPool public JedisCluster(Set jedisClusterNode, int timeout, int maxRedirections, final GenericObjectPoolConfig poolConfig) { - this.connectionHandler = new JedisSlotBasedConnectionHandler(jedisClusterNode, poolConfig); - this.timeout = timeout; + this.connectionHandler = new JedisSlotBasedConnectionHandler(jedisClusterNode, poolConfig, + timeout); this.maxRedirections = maxRedirections; } @@ -68,7 +67,7 @@ public void close() { @Override public String set(final String key, final String value) { - return new JedisClusterCommand(connectionHandler, timeout, maxRedirections) { + return new JedisClusterCommand(connectionHandler, maxRedirections) { @Override public String execute(Jedis connection) { return connection.set(key, value); @@ -79,7 +78,7 @@ public String execute(Jedis connection) { @Override public String set(final String key, final String value, final String nxxx, final String expx, final long time) { - return new JedisClusterCommand(connectionHandler, timeout, maxRedirections) { + return new JedisClusterCommand(connectionHandler, maxRedirections) { @Override public String execute(Jedis connection) { return connection.set(key, value, nxxx, expx, time); @@ -89,7 +88,7 @@ public String execute(Jedis connection) { @Override public String get(final String key) { - return new JedisClusterCommand(connectionHandler, timeout, maxRedirections) { + return new JedisClusterCommand(connectionHandler, maxRedirections) { @Override public String execute(Jedis connection) { return connection.get(key); @@ -99,7 +98,7 @@ public String execute(Jedis connection) { @Override public Boolean exists(final String key) { - return new JedisClusterCommand(connectionHandler, timeout, maxRedirections) { + return new JedisClusterCommand(connectionHandler, maxRedirections) { @Override public Boolean execute(Jedis connection) { return connection.exists(key); @@ -109,7 +108,7 @@ public Boolean execute(Jedis connection) { @Override public Long persist(final String key) { - return new JedisClusterCommand(connectionHandler, timeout, maxRedirections) { + return new JedisClusterCommand(connectionHandler, maxRedirections) { @Override public Long execute(Jedis connection) { return connection.persist(key); @@ -119,7 +118,7 @@ public Long execute(Jedis connection) { @Override public String type(final String key) { - return new JedisClusterCommand(connectionHandler, timeout, maxRedirections) { + return new JedisClusterCommand(connectionHandler, maxRedirections) { @Override public String execute(Jedis connection) { return connection.type(key); @@ -129,7 +128,7 @@ public String execute(Jedis connection) { @Override public Long expire(final String key, final int seconds) { - return new JedisClusterCommand(connectionHandler, timeout, maxRedirections) { + return new JedisClusterCommand(connectionHandler, maxRedirections) { @Override public Long execute(Jedis connection) { return connection.expire(key, seconds); @@ -139,7 +138,7 @@ public Long execute(Jedis connection) { @Override public Long pexpire(final String key, final long milliseconds) { - return new JedisClusterCommand(connectionHandler, timeout, maxRedirections) { + return new JedisClusterCommand(connectionHandler, maxRedirections) { @Override public Long execute(Jedis connection) { return connection.pexpire(key, milliseconds); @@ -149,7 +148,7 @@ public Long execute(Jedis connection) { @Override public Long expireAt(final String key, final long unixTime) { - return new JedisClusterCommand(connectionHandler, timeout, maxRedirections) { + return new JedisClusterCommand(connectionHandler, maxRedirections) { @Override public Long execute(Jedis connection) { return connection.expireAt(key, unixTime); @@ -159,7 +158,7 @@ public Long execute(Jedis connection) { @Override public Long pexpireAt(final String key, final long millisecondsTimestamp) { - return new JedisClusterCommand(connectionHandler, timeout, maxRedirections) { + return new JedisClusterCommand(connectionHandler, maxRedirections) { @Override public Long execute(Jedis connection) { return connection.pexpireAt(key, millisecondsTimestamp); @@ -169,7 +168,7 @@ public Long execute(Jedis connection) { @Override public Long ttl(final String key) { - return new JedisClusterCommand(connectionHandler, timeout, maxRedirections) { + return new JedisClusterCommand(connectionHandler, maxRedirections) { @Override public Long execute(Jedis connection) { return connection.ttl(key); @@ -179,7 +178,7 @@ public Long execute(Jedis connection) { @Override public Boolean setbit(final String key, final long offset, final boolean value) { - return new JedisClusterCommand(connectionHandler, timeout, maxRedirections) { + return new JedisClusterCommand(connectionHandler, maxRedirections) { @Override public Boolean execute(Jedis connection) { return connection.setbit(key, offset, value); @@ -189,7 +188,7 @@ public Boolean execute(Jedis connection) { @Override public Boolean setbit(final String key, final long offset, final String value) { - return new JedisClusterCommand(connectionHandler, timeout, maxRedirections) { + return new JedisClusterCommand(connectionHandler, maxRedirections) { @Override public Boolean execute(Jedis connection) { return connection.setbit(key, offset, value); @@ -199,7 +198,7 @@ public Boolean execute(Jedis connection) { @Override public Boolean getbit(final String key, final long offset) { - return new JedisClusterCommand(connectionHandler, timeout, maxRedirections) { + return new JedisClusterCommand(connectionHandler, maxRedirections) { @Override public Boolean execute(Jedis connection) { return connection.getbit(key, offset); @@ -209,7 +208,7 @@ public Boolean execute(Jedis connection) { @Override public Long setrange(final String key, final long offset, final String value) { - return new JedisClusterCommand(connectionHandler, timeout, maxRedirections) { + return new JedisClusterCommand(connectionHandler, maxRedirections) { @Override public Long execute(Jedis connection) { return connection.setrange(key, offset, value); @@ -219,7 +218,7 @@ public Long execute(Jedis connection) { @Override public String getrange(final String key, final long startOffset, final long endOffset) { - return new JedisClusterCommand(connectionHandler, timeout, maxRedirections) { + return new JedisClusterCommand(connectionHandler, maxRedirections) { @Override public String execute(Jedis connection) { return connection.getrange(key, startOffset, endOffset); @@ -229,7 +228,7 @@ public String execute(Jedis connection) { @Override public String getSet(final String key, final String value) { - return new JedisClusterCommand(connectionHandler, timeout, maxRedirections) { + return new JedisClusterCommand(connectionHandler, maxRedirections) { @Override public String execute(Jedis connection) { return connection.getSet(key, value); @@ -239,7 +238,7 @@ public String execute(Jedis connection) { @Override public Long setnx(final String key, final String value) { - return new JedisClusterCommand(connectionHandler, timeout, maxRedirections) { + return new JedisClusterCommand(connectionHandler, maxRedirections) { @Override public Long execute(Jedis connection) { return connection.setnx(key, value); @@ -249,7 +248,7 @@ public Long execute(Jedis connection) { @Override public String setex(final String key, final int seconds, final String value) { - return new JedisClusterCommand(connectionHandler, timeout, maxRedirections) { + return new JedisClusterCommand(connectionHandler, maxRedirections) { @Override public String execute(Jedis connection) { return connection.setex(key, seconds, value); @@ -259,7 +258,7 @@ public String execute(Jedis connection) { @Override public Long decrBy(final String key, final long integer) { - return new JedisClusterCommand(connectionHandler, timeout, maxRedirections) { + return new JedisClusterCommand(connectionHandler, maxRedirections) { @Override public Long execute(Jedis connection) { return connection.decrBy(key, integer); @@ -269,7 +268,7 @@ public Long execute(Jedis connection) { @Override public Long decr(final String key) { - return new JedisClusterCommand(connectionHandler, timeout, maxRedirections) { + return new JedisClusterCommand(connectionHandler, maxRedirections) { @Override public Long execute(Jedis connection) { return connection.decr(key); @@ -279,7 +278,7 @@ public Long execute(Jedis connection) { @Override public Long incrBy(final String key, final long integer) { - return new JedisClusterCommand(connectionHandler, timeout, maxRedirections) { + return new JedisClusterCommand(connectionHandler, maxRedirections) { @Override public Long execute(Jedis connection) { return connection.incrBy(key, integer); @@ -289,7 +288,7 @@ public Long execute(Jedis connection) { @Override public Long incr(final String key) { - return new JedisClusterCommand(connectionHandler, timeout, maxRedirections) { + return new JedisClusterCommand(connectionHandler, maxRedirections) { @Override public Long execute(Jedis connection) { return connection.incr(key); @@ -299,7 +298,7 @@ public Long execute(Jedis connection) { @Override public Long append(final String key, final String value) { - return new JedisClusterCommand(connectionHandler, timeout, maxRedirections) { + return new JedisClusterCommand(connectionHandler, maxRedirections) { @Override public Long execute(Jedis connection) { return connection.append(key, value); @@ -309,7 +308,7 @@ public Long execute(Jedis connection) { @Override public String substr(final String key, final int start, final int end) { - return new JedisClusterCommand(connectionHandler, timeout, maxRedirections) { + return new JedisClusterCommand(connectionHandler, maxRedirections) { @Override public String execute(Jedis connection) { return connection.substr(key, start, end); @@ -319,7 +318,7 @@ public String execute(Jedis connection) { @Override public Long hset(final String key, final String field, final String value) { - return new JedisClusterCommand(connectionHandler, timeout, maxRedirections) { + return new JedisClusterCommand(connectionHandler, maxRedirections) { @Override public Long execute(Jedis connection) { return connection.hset(key, field, value); @@ -329,7 +328,7 @@ public Long execute(Jedis connection) { @Override public String hget(final String key, final String field) { - return new JedisClusterCommand(connectionHandler, timeout, maxRedirections) { + return new JedisClusterCommand(connectionHandler, maxRedirections) { @Override public String execute(Jedis connection) { return connection.hget(key, field); @@ -339,7 +338,7 @@ public String execute(Jedis connection) { @Override public Long hsetnx(final String key, final String field, final String value) { - return new JedisClusterCommand(connectionHandler, timeout, maxRedirections) { + return new JedisClusterCommand(connectionHandler, maxRedirections) { @Override public Long execute(Jedis connection) { return connection.hsetnx(key, field, value); @@ -349,7 +348,7 @@ public Long execute(Jedis connection) { @Override public String hmset(final String key, final Map hash) { - return new JedisClusterCommand(connectionHandler, timeout, maxRedirections) { + return new JedisClusterCommand(connectionHandler, maxRedirections) { @Override public String execute(Jedis connection) { return connection.hmset(key, hash); @@ -359,7 +358,7 @@ public String execute(Jedis connection) { @Override public List hmget(final String key, final String... fields) { - return new JedisClusterCommand>(connectionHandler, timeout, maxRedirections) { + return new JedisClusterCommand>(connectionHandler, maxRedirections) { @Override public List execute(Jedis connection) { return connection.hmget(key, fields); @@ -369,7 +368,7 @@ public List execute(Jedis connection) { @Override public Long hincrBy(final String key, final String field, final long value) { - return new JedisClusterCommand(connectionHandler, timeout, maxRedirections) { + return new JedisClusterCommand(connectionHandler, maxRedirections) { @Override public Long execute(Jedis connection) { return connection.hincrBy(key, field, value); @@ -379,7 +378,7 @@ public Long execute(Jedis connection) { @Override public Boolean hexists(final String key, final String field) { - return new JedisClusterCommand(connectionHandler, timeout, maxRedirections) { + return new JedisClusterCommand(connectionHandler, maxRedirections) { @Override public Boolean execute(Jedis connection) { return connection.hexists(key, field); @@ -389,7 +388,7 @@ public Boolean execute(Jedis connection) { @Override public Long hdel(final String key, final String... field) { - return new JedisClusterCommand(connectionHandler, timeout, maxRedirections) { + return new JedisClusterCommand(connectionHandler, maxRedirections) { @Override public Long execute(Jedis connection) { return connection.hdel(key, field); @@ -399,7 +398,7 @@ public Long execute(Jedis connection) { @Override public Long hlen(final String key) { - return new JedisClusterCommand(connectionHandler, timeout, maxRedirections) { + return new JedisClusterCommand(connectionHandler, maxRedirections) { @Override public Long execute(Jedis connection) { return connection.hlen(key); @@ -409,7 +408,7 @@ public Long execute(Jedis connection) { @Override public Set hkeys(final String key) { - return new JedisClusterCommand>(connectionHandler, timeout, maxRedirections) { + return new JedisClusterCommand>(connectionHandler, maxRedirections) { @Override public Set execute(Jedis connection) { return connection.hkeys(key); @@ -419,7 +418,7 @@ public Set execute(Jedis connection) { @Override public List hvals(final String key) { - return new JedisClusterCommand>(connectionHandler, timeout, maxRedirections) { + return new JedisClusterCommand>(connectionHandler, maxRedirections) { @Override public List execute(Jedis connection) { return connection.hvals(key); @@ -429,7 +428,7 @@ public List execute(Jedis connection) { @Override public Map hgetAll(final String key) { - return new JedisClusterCommand>(connectionHandler, timeout, maxRedirections) { + return new JedisClusterCommand>(connectionHandler, maxRedirections) { @Override public Map execute(Jedis connection) { return connection.hgetAll(key); @@ -439,7 +438,7 @@ public Map execute(Jedis connection) { @Override public Long rpush(final String key, final String... string) { - return new JedisClusterCommand(connectionHandler, timeout, maxRedirections) { + return new JedisClusterCommand(connectionHandler, maxRedirections) { @Override public Long execute(Jedis connection) { return connection.rpush(key, string); @@ -449,7 +448,7 @@ public Long execute(Jedis connection) { @Override public Long lpush(final String key, final String... string) { - return new JedisClusterCommand(connectionHandler, timeout, maxRedirections) { + return new JedisClusterCommand(connectionHandler, maxRedirections) { @Override public Long execute(Jedis connection) { return connection.lpush(key, string); @@ -459,7 +458,7 @@ public Long execute(Jedis connection) { @Override public Long llen(final String key) { - return new JedisClusterCommand(connectionHandler, timeout, maxRedirections) { + return new JedisClusterCommand(connectionHandler, maxRedirections) { @Override public Long execute(Jedis connection) { return connection.llen(key); @@ -469,7 +468,7 @@ public Long execute(Jedis connection) { @Override public List lrange(final String key, final long start, final long end) { - return new JedisClusterCommand>(connectionHandler, timeout, maxRedirections) { + return new JedisClusterCommand>(connectionHandler, maxRedirections) { @Override public List execute(Jedis connection) { return connection.lrange(key, start, end); @@ -479,7 +478,7 @@ public List execute(Jedis connection) { @Override public String ltrim(final String key, final long start, final long end) { - return new JedisClusterCommand(connectionHandler, timeout, maxRedirections) { + return new JedisClusterCommand(connectionHandler, maxRedirections) { @Override public String execute(Jedis connection) { return connection.ltrim(key, start, end); @@ -489,7 +488,7 @@ public String execute(Jedis connection) { @Override public String lindex(final String key, final long index) { - return new JedisClusterCommand(connectionHandler, timeout, maxRedirections) { + return new JedisClusterCommand(connectionHandler, maxRedirections) { @Override public String execute(Jedis connection) { return connection.lindex(key, index); @@ -499,7 +498,7 @@ public String execute(Jedis connection) { @Override public String lset(final String key, final long index, final String value) { - return new JedisClusterCommand(connectionHandler, timeout, maxRedirections) { + return new JedisClusterCommand(connectionHandler, maxRedirections) { @Override public String execute(Jedis connection) { return connection.lset(key, index, value); @@ -509,7 +508,7 @@ public String execute(Jedis connection) { @Override public Long lrem(final String key, final long count, final String value) { - return new JedisClusterCommand(connectionHandler, timeout, maxRedirections) { + return new JedisClusterCommand(connectionHandler, maxRedirections) { @Override public Long execute(Jedis connection) { return connection.lrem(key, count, value); @@ -519,7 +518,7 @@ public Long execute(Jedis connection) { @Override public String lpop(final String key) { - return new JedisClusterCommand(connectionHandler, timeout, maxRedirections) { + return new JedisClusterCommand(connectionHandler, maxRedirections) { @Override public String execute(Jedis connection) { return connection.lpop(key); @@ -529,7 +528,7 @@ public String execute(Jedis connection) { @Override public String rpop(final String key) { - return new JedisClusterCommand(connectionHandler, timeout, maxRedirections) { + return new JedisClusterCommand(connectionHandler, maxRedirections) { @Override public String execute(Jedis connection) { return connection.rpop(key); @@ -539,7 +538,7 @@ public String execute(Jedis connection) { @Override public Long sadd(final String key, final String... member) { - return new JedisClusterCommand(connectionHandler, timeout, maxRedirections) { + return new JedisClusterCommand(connectionHandler, maxRedirections) { @Override public Long execute(Jedis connection) { return connection.sadd(key, member); @@ -549,7 +548,7 @@ public Long execute(Jedis connection) { @Override public Set smembers(final String key) { - return new JedisClusterCommand>(connectionHandler, timeout, maxRedirections) { + return new JedisClusterCommand>(connectionHandler, maxRedirections) { @Override public Set execute(Jedis connection) { return connection.smembers(key); @@ -559,7 +558,7 @@ public Set execute(Jedis connection) { @Override public Long srem(final String key, final String... member) { - return new JedisClusterCommand(connectionHandler, timeout, maxRedirections) { + return new JedisClusterCommand(connectionHandler, maxRedirections) { @Override public Long execute(Jedis connection) { return connection.srem(key, member); @@ -569,7 +568,7 @@ public Long execute(Jedis connection) { @Override public String spop(final String key) { - return new JedisClusterCommand(connectionHandler, timeout, maxRedirections) { + return new JedisClusterCommand(connectionHandler, maxRedirections) { @Override public String execute(Jedis connection) { return connection.spop(key); @@ -579,7 +578,7 @@ public String execute(Jedis connection) { @Override public Long scard(final String key) { - return new JedisClusterCommand(connectionHandler, timeout, maxRedirections) { + return new JedisClusterCommand(connectionHandler, maxRedirections) { @Override public Long execute(Jedis connection) { return connection.scard(key); @@ -589,7 +588,7 @@ public Long execute(Jedis connection) { @Override public Boolean sismember(final String key, final String member) { - return new JedisClusterCommand(connectionHandler, timeout, maxRedirections) { + return new JedisClusterCommand(connectionHandler, maxRedirections) { @Override public Boolean execute(Jedis connection) { return connection.sismember(key, member); @@ -599,7 +598,7 @@ public Boolean execute(Jedis connection) { @Override public String srandmember(final String key) { - return new JedisClusterCommand(connectionHandler, timeout, maxRedirections) { + return new JedisClusterCommand(connectionHandler, maxRedirections) { @Override public String execute(Jedis connection) { return connection.srandmember(key); @@ -609,7 +608,7 @@ public String execute(Jedis connection) { @Override public List srandmember(final String key, final int count) { - return new JedisClusterCommand>(connectionHandler, timeout, maxRedirections) { + return new JedisClusterCommand>(connectionHandler, maxRedirections) { @Override public List execute(Jedis connection) { return connection.srandmember(key, count); @@ -619,7 +618,7 @@ public List execute(Jedis connection) { @Override public Long strlen(final String key) { - return new JedisClusterCommand(connectionHandler, timeout, maxRedirections) { + return new JedisClusterCommand(connectionHandler, maxRedirections) { @Override public Long execute(Jedis connection) { return connection.strlen(key); @@ -629,7 +628,7 @@ public Long execute(Jedis connection) { @Override public Long zadd(final String key, final double score, final String member) { - return new JedisClusterCommand(connectionHandler, timeout, maxRedirections) { + return new JedisClusterCommand(connectionHandler, maxRedirections) { @Override public Long execute(Jedis connection) { return connection.zadd(key, score, member); @@ -639,7 +638,7 @@ public Long execute(Jedis connection) { @Override public Long zadd(final String key, final Map scoreMembers) { - return new JedisClusterCommand(connectionHandler, timeout, maxRedirections) { + return new JedisClusterCommand(connectionHandler, maxRedirections) { @Override public Long execute(Jedis connection) { return connection.zadd(key, scoreMembers); @@ -649,7 +648,7 @@ public Long execute(Jedis connection) { @Override public Set zrange(final String key, final long start, final long end) { - return new JedisClusterCommand>(connectionHandler, timeout, maxRedirections) { + return new JedisClusterCommand>(connectionHandler, maxRedirections) { @Override public Set execute(Jedis connection) { return connection.zrange(key, start, end); @@ -659,7 +658,7 @@ public Set execute(Jedis connection) { @Override public Long zrem(final String key, final String... member) { - return new JedisClusterCommand(connectionHandler, timeout, maxRedirections) { + return new JedisClusterCommand(connectionHandler, maxRedirections) { @Override public Long execute(Jedis connection) { return connection.zrem(key, member); @@ -669,7 +668,7 @@ public Long execute(Jedis connection) { @Override public Double zincrby(final String key, final double score, final String member) { - return new JedisClusterCommand(connectionHandler, timeout, maxRedirections) { + return new JedisClusterCommand(connectionHandler, maxRedirections) { @Override public Double execute(Jedis connection) { return connection.zincrby(key, score, member); @@ -679,7 +678,7 @@ public Double execute(Jedis connection) { @Override public Long zrank(final String key, final String member) { - return new JedisClusterCommand(connectionHandler, timeout, maxRedirections) { + return new JedisClusterCommand(connectionHandler, maxRedirections) { @Override public Long execute(Jedis connection) { return connection.zrank(key, member); @@ -689,7 +688,7 @@ public Long execute(Jedis connection) { @Override public Long zrevrank(final String key, final String member) { - return new JedisClusterCommand(connectionHandler, timeout, maxRedirections) { + return new JedisClusterCommand(connectionHandler, maxRedirections) { @Override public Long execute(Jedis connection) { return connection.zrevrank(key, member); @@ -699,7 +698,7 @@ public Long execute(Jedis connection) { @Override public Set zrevrange(final String key, final long start, final long end) { - return new JedisClusterCommand>(connectionHandler, timeout, maxRedirections) { + return new JedisClusterCommand>(connectionHandler, maxRedirections) { @Override public Set execute(Jedis connection) { return connection.zrevrange(key, start, end); @@ -709,7 +708,7 @@ public Set execute(Jedis connection) { @Override public Set zrangeWithScores(final String key, final long start, final long end) { - return new JedisClusterCommand>(connectionHandler, timeout, maxRedirections) { + return new JedisClusterCommand>(connectionHandler, maxRedirections) { @Override public Set execute(Jedis connection) { return connection.zrangeWithScores(key, start, end); @@ -719,7 +718,7 @@ public Set execute(Jedis connection) { @Override public Set zrevrangeWithScores(final String key, final long start, final long end) { - return new JedisClusterCommand>(connectionHandler, timeout, maxRedirections) { + return new JedisClusterCommand>(connectionHandler, maxRedirections) { @Override public Set execute(Jedis connection) { return connection.zrevrangeWithScores(key, start, end); @@ -729,7 +728,7 @@ public Set execute(Jedis connection) { @Override public Long zcard(final String key) { - return new JedisClusterCommand(connectionHandler, timeout, maxRedirections) { + return new JedisClusterCommand(connectionHandler, maxRedirections) { @Override public Long execute(Jedis connection) { return connection.zcard(key); @@ -739,7 +738,7 @@ public Long execute(Jedis connection) { @Override public Double zscore(final String key, final String member) { - return new JedisClusterCommand(connectionHandler, timeout, maxRedirections) { + return new JedisClusterCommand(connectionHandler, maxRedirections) { @Override public Double execute(Jedis connection) { return connection.zscore(key, member); @@ -749,7 +748,7 @@ public Double execute(Jedis connection) { @Override public List sort(final String key) { - return new JedisClusterCommand>(connectionHandler, timeout, maxRedirections) { + return new JedisClusterCommand>(connectionHandler, maxRedirections) { @Override public List execute(Jedis connection) { return connection.sort(key); @@ -759,7 +758,7 @@ public List execute(Jedis connection) { @Override public List sort(final String key, final SortingParams sortingParameters) { - return new JedisClusterCommand>(connectionHandler, timeout, maxRedirections) { + return new JedisClusterCommand>(connectionHandler, maxRedirections) { @Override public List execute(Jedis connection) { return connection.sort(key, sortingParameters); @@ -769,7 +768,7 @@ public List execute(Jedis connection) { @Override public Long zcount(final String key, final double min, final double max) { - return new JedisClusterCommand(connectionHandler, timeout, maxRedirections) { + return new JedisClusterCommand(connectionHandler, maxRedirections) { @Override public Long execute(Jedis connection) { return connection.zcount(key, min, max); @@ -779,7 +778,7 @@ public Long execute(Jedis connection) { @Override public Long zcount(final String key, final String min, final String max) { - return new JedisClusterCommand(connectionHandler, timeout, maxRedirections) { + return new JedisClusterCommand(connectionHandler, maxRedirections) { @Override public Long execute(Jedis connection) { return connection.zcount(key, min, max); @@ -789,7 +788,7 @@ public Long execute(Jedis connection) { @Override public Set zrangeByScore(final String key, final double min, final double max) { - return new JedisClusterCommand>(connectionHandler, timeout, maxRedirections) { + return new JedisClusterCommand>(connectionHandler, maxRedirections) { @Override public Set execute(Jedis connection) { return connection.zrangeByScore(key, min, max); @@ -799,7 +798,7 @@ public Set execute(Jedis connection) { @Override public Set zrangeByScore(final String key, final String min, final String max) { - return new JedisClusterCommand>(connectionHandler, timeout, maxRedirections) { + return new JedisClusterCommand>(connectionHandler, maxRedirections) { @Override public Set execute(Jedis connection) { return connection.zrangeByScore(key, min, max); @@ -809,7 +808,7 @@ public Set execute(Jedis connection) { @Override public Set zrevrangeByScore(final String key, final double max, final double min) { - return new JedisClusterCommand>(connectionHandler, timeout, maxRedirections) { + return new JedisClusterCommand>(connectionHandler, maxRedirections) { @Override public Set execute(Jedis connection) { return connection.zrevrangeByScore(key, max, min); @@ -820,7 +819,7 @@ public Set execute(Jedis connection) { @Override public Set zrangeByScore(final String key, final double min, final double max, final int offset, final int count) { - return new JedisClusterCommand>(connectionHandler, timeout, maxRedirections) { + return new JedisClusterCommand>(connectionHandler, maxRedirections) { @Override public Set execute(Jedis connection) { return connection.zrangeByScore(key, min, max, offset, count); @@ -830,7 +829,7 @@ public Set execute(Jedis connection) { @Override public Set zrevrangeByScore(final String key, final String max, final String min) { - return new JedisClusterCommand>(connectionHandler, timeout, maxRedirections) { + return new JedisClusterCommand>(connectionHandler, maxRedirections) { @Override public Set execute(Jedis connection) { return connection.zrevrangeByScore(key, max, min); @@ -841,7 +840,7 @@ public Set execute(Jedis connection) { @Override public Set zrangeByScore(final String key, final String min, final String max, final int offset, final int count) { - return new JedisClusterCommand>(connectionHandler, timeout, maxRedirections) { + return new JedisClusterCommand>(connectionHandler, maxRedirections) { @Override public Set execute(Jedis connection) { return connection.zrangeByScore(key, min, max, offset, count); @@ -852,7 +851,7 @@ public Set execute(Jedis connection) { @Override public Set zrevrangeByScore(final String key, final double max, final double min, final int offset, final int count) { - return new JedisClusterCommand>(connectionHandler, timeout, maxRedirections) { + return new JedisClusterCommand>(connectionHandler, maxRedirections) { @Override public Set execute(Jedis connection) { return connection.zrevrangeByScore(key, max, min, offset, count); @@ -862,7 +861,7 @@ public Set execute(Jedis connection) { @Override public Set zrangeByScoreWithScores(final String key, final double min, final double max) { - return new JedisClusterCommand>(connectionHandler, timeout, maxRedirections) { + return new JedisClusterCommand>(connectionHandler, maxRedirections) { @Override public Set execute(Jedis connection) { return connection.zrangeByScoreWithScores(key, min, max); @@ -872,7 +871,7 @@ public Set execute(Jedis connection) { @Override public Set zrevrangeByScoreWithScores(final String key, final double max, final double min) { - return new JedisClusterCommand>(connectionHandler, timeout, maxRedirections) { + return new JedisClusterCommand>(connectionHandler, maxRedirections) { @Override public Set execute(Jedis connection) { return connection.zrevrangeByScoreWithScores(key, max, min); @@ -883,7 +882,7 @@ public Set execute(Jedis connection) { @Override public Set zrangeByScoreWithScores(final String key, final double min, final double max, final int offset, final int count) { - return new JedisClusterCommand>(connectionHandler, timeout, maxRedirections) { + return new JedisClusterCommand>(connectionHandler, maxRedirections) { @Override public Set execute(Jedis connection) { return connection.zrangeByScoreWithScores(key, min, max, offset, count); @@ -894,7 +893,7 @@ public Set execute(Jedis connection) { @Override public Set zrevrangeByScore(final String key, final String max, final String min, final int offset, final int count) { - return new JedisClusterCommand>(connectionHandler, timeout, maxRedirections) { + return new JedisClusterCommand>(connectionHandler, maxRedirections) { @Override public Set execute(Jedis connection) { return connection.zrevrangeByScore(key, max, min, offset, count); @@ -904,7 +903,7 @@ public Set execute(Jedis connection) { @Override public Set zrangeByScoreWithScores(final String key, final String min, final String max) { - return new JedisClusterCommand>(connectionHandler, timeout, maxRedirections) { + return new JedisClusterCommand>(connectionHandler, maxRedirections) { @Override public Set execute(Jedis connection) { return connection.zrangeByScoreWithScores(key, min, max); @@ -914,7 +913,7 @@ public Set execute(Jedis connection) { @Override public Set zrevrangeByScoreWithScores(final String key, final String max, final String min) { - return new JedisClusterCommand>(connectionHandler, timeout, maxRedirections) { + return new JedisClusterCommand>(connectionHandler, maxRedirections) { @Override public Set execute(Jedis connection) { return connection.zrevrangeByScoreWithScores(key, max, min); @@ -925,7 +924,7 @@ public Set execute(Jedis connection) { @Override public Set zrangeByScoreWithScores(final String key, final String min, final String max, final int offset, final int count) { - return new JedisClusterCommand>(connectionHandler, timeout, maxRedirections) { + return new JedisClusterCommand>(connectionHandler, maxRedirections) { @Override public Set execute(Jedis connection) { return connection.zrangeByScoreWithScores(key, min, max, offset, count); @@ -936,7 +935,7 @@ public Set execute(Jedis connection) { @Override public Set zrevrangeByScoreWithScores(final String key, final double max, final double min, final int offset, final int count) { - return new JedisClusterCommand>(connectionHandler, timeout, maxRedirections) { + return new JedisClusterCommand>(connectionHandler, maxRedirections) { @Override public Set execute(Jedis connection) { return connection.zrevrangeByScoreWithScores(key, max, min, offset, count); @@ -947,7 +946,7 @@ public Set execute(Jedis connection) { @Override public Set zrevrangeByScoreWithScores(final String key, final String max, final String min, final int offset, final int count) { - return new JedisClusterCommand>(connectionHandler, timeout, maxRedirections) { + return new JedisClusterCommand>(connectionHandler, maxRedirections) { @Override public Set execute(Jedis connection) { return connection.zrevrangeByScoreWithScores(key, max, min, offset, count); @@ -957,7 +956,7 @@ public Set execute(Jedis connection) { @Override public Long zremrangeByRank(final String key, final long start, final long end) { - return new JedisClusterCommand(connectionHandler, timeout, maxRedirections) { + return new JedisClusterCommand(connectionHandler, maxRedirections) { @Override public Long execute(Jedis connection) { return connection.zremrangeByRank(key, start, end); @@ -967,7 +966,7 @@ public Long execute(Jedis connection) { @Override public Long zremrangeByScore(final String key, final double start, final double end) { - return new JedisClusterCommand(connectionHandler, timeout, maxRedirections) { + return new JedisClusterCommand(connectionHandler, maxRedirections) { @Override public Long execute(Jedis connection) { return connection.zremrangeByScore(key, start, end); @@ -977,7 +976,7 @@ public Long execute(Jedis connection) { @Override public Long zremrangeByScore(final String key, final String start, final String end) { - return new JedisClusterCommand(connectionHandler, timeout, maxRedirections) { + return new JedisClusterCommand(connectionHandler, maxRedirections) { @Override public Long execute(Jedis connection) { return connection.zremrangeByScore(key, start, end); @@ -987,7 +986,7 @@ public Long execute(Jedis connection) { @Override public Long zlexcount(final String key, final String min, final String max) { - return new JedisClusterCommand(connectionHandler, timeout, maxRedirections) { + return new JedisClusterCommand(connectionHandler, maxRedirections) { @Override public Long execute(Jedis connection) { return connection.zlexcount(key, min, max); @@ -997,7 +996,7 @@ public Long execute(Jedis connection) { @Override public Set zrangeByLex(final String key, final String min, final String max) { - return new JedisClusterCommand>(connectionHandler, timeout, maxRedirections) { + return new JedisClusterCommand>(connectionHandler, maxRedirections) { @Override public Set execute(Jedis connection) { return connection.zrangeByLex(key, min, max); @@ -1008,7 +1007,7 @@ public Set execute(Jedis connection) { @Override public Set zrangeByLex(final String key, final String min, final String max, final int offset, final int count) { - return new JedisClusterCommand>(connectionHandler, timeout, maxRedirections) { + return new JedisClusterCommand>(connectionHandler, maxRedirections) { @Override public Set execute(Jedis connection) { return connection.zrangeByLex(key, min, max, offset, count); @@ -1018,7 +1017,7 @@ public Set execute(Jedis connection) { @Override public Long zremrangeByLex(final String key, final String min, final String max) { - return new JedisClusterCommand(connectionHandler, timeout, maxRedirections) { + return new JedisClusterCommand(connectionHandler, maxRedirections) { @Override public Long execute(Jedis connection) { return connection.zremrangeByLex(key, min, max); @@ -1029,7 +1028,7 @@ public Long execute(Jedis connection) { @Override public Long linsert(final String key, final LIST_POSITION where, final String pivot, final String value) { - return new JedisClusterCommand(connectionHandler, timeout, maxRedirections) { + return new JedisClusterCommand(connectionHandler, maxRedirections) { @Override public Long execute(Jedis connection) { return connection.linsert(key, where, pivot, value); @@ -1039,7 +1038,7 @@ public Long execute(Jedis connection) { @Override public Long lpushx(final String key, final String... string) { - return new JedisClusterCommand(connectionHandler, timeout, maxRedirections) { + return new JedisClusterCommand(connectionHandler, maxRedirections) { @Override public Long execute(Jedis connection) { return connection.lpushx(key, string); @@ -1049,7 +1048,7 @@ public Long execute(Jedis connection) { @Override public Long rpushx(final String key, final String... string) { - return new JedisClusterCommand(connectionHandler, timeout, maxRedirections) { + return new JedisClusterCommand(connectionHandler, maxRedirections) { @Override public Long execute(Jedis connection) { return connection.rpushx(key, string); @@ -1063,7 +1062,7 @@ public Long execute(Jedis connection) { @Override @Deprecated public List blpop(final String arg) { - return new JedisClusterCommand>(connectionHandler, timeout, maxRedirections) { + return new JedisClusterCommand>(connectionHandler, maxRedirections) { @Override public List execute(Jedis connection) { return connection.blpop(arg); @@ -1077,7 +1076,7 @@ public List execute(Jedis connection) { @Override @Deprecated public List brpop(final String arg) { - return new JedisClusterCommand>(connectionHandler, timeout, maxRedirections) { + return new JedisClusterCommand>(connectionHandler, maxRedirections) { @Override public List execute(Jedis connection) { return connection.brpop(arg); @@ -1087,7 +1086,7 @@ public List execute(Jedis connection) { @Override public Long del(final String key) { - return new JedisClusterCommand(connectionHandler, timeout, maxRedirections) { + return new JedisClusterCommand(connectionHandler, maxRedirections) { @Override public Long execute(Jedis connection) { return connection.del(key); @@ -1097,7 +1096,7 @@ public Long execute(Jedis connection) { @Override public String echo(final String string) { - return new JedisClusterCommand(connectionHandler, timeout, maxRedirections) { + return new JedisClusterCommand(connectionHandler, maxRedirections) { @Override public String execute(Jedis connection) { return connection.echo(string); @@ -1107,7 +1106,7 @@ public String execute(Jedis connection) { @Override public Long move(final String key, final int dbIndex) { - return new JedisClusterCommand(connectionHandler, timeout, maxRedirections) { + return new JedisClusterCommand(connectionHandler, maxRedirections) { @Override public Long execute(Jedis connection) { return connection.move(key, dbIndex); @@ -1117,7 +1116,7 @@ public Long execute(Jedis connection) { @Override public Long bitcount(final String key) { - return new JedisClusterCommand(connectionHandler, timeout, maxRedirections) { + return new JedisClusterCommand(connectionHandler, maxRedirections) { @Override public Long execute(Jedis connection) { return connection.bitcount(key); @@ -1127,7 +1126,7 @@ public Long execute(Jedis connection) { @Override public Long bitcount(final String key, final long start, final long end) { - return new JedisClusterCommand(connectionHandler, timeout, maxRedirections) { + return new JedisClusterCommand(connectionHandler, maxRedirections) { @Override public Long execute(Jedis connection) { return connection.bitcount(key, start, end); @@ -1141,7 +1140,7 @@ public Long execute(Jedis connection) { @Deprecated @Override public String ping() { - return new JedisClusterCommand(connectionHandler, timeout, maxRedirections) { + return new JedisClusterCommand(connectionHandler, maxRedirections) { @Override public String execute(Jedis connection) { return connection.ping(); @@ -1155,7 +1154,7 @@ public String execute(Jedis connection) { @Deprecated @Override public String quit() { - return new JedisClusterCommand(connectionHandler, timeout, maxRedirections) { + return new JedisClusterCommand(connectionHandler, maxRedirections) { @Override public String execute(Jedis connection) { return connection.quit(); @@ -1169,7 +1168,7 @@ public String execute(Jedis connection) { @Deprecated @Override public String flushDB() { - return new JedisClusterCommand(connectionHandler, timeout, maxRedirections) { + return new JedisClusterCommand(connectionHandler, maxRedirections) { @Override public String execute(Jedis connection) { return connection.flushDB(); @@ -1183,7 +1182,7 @@ public String execute(Jedis connection) { @Deprecated @Override public Long dbSize() { - return new JedisClusterCommand(connectionHandler, timeout, maxRedirections) { + return new JedisClusterCommand(connectionHandler, maxRedirections) { @Override public Long execute(Jedis connection) { return connection.dbSize(); @@ -1197,7 +1196,7 @@ public Long execute(Jedis connection) { @Deprecated @Override public String select(final int index) { - return new JedisClusterCommand(connectionHandler, timeout, maxRedirections) { + return new JedisClusterCommand(connectionHandler, maxRedirections) { @Override public String execute(Jedis connection) { return connection.select(index); @@ -1211,7 +1210,7 @@ public String execute(Jedis connection) { @Deprecated @Override public String flushAll() { - return new JedisClusterCommand(connectionHandler, timeout, maxRedirections) { + return new JedisClusterCommand(connectionHandler, maxRedirections) { @Override public String execute(Jedis connection) { return connection.flushAll(); @@ -1225,7 +1224,7 @@ public String execute(Jedis connection) { @Deprecated @Override public String auth(final String password) { - return new JedisClusterCommand(connectionHandler, timeout, maxRedirections) { + return new JedisClusterCommand(connectionHandler, maxRedirections) { @Override public String execute(Jedis connection) { return connection.auth(password); @@ -1239,7 +1238,7 @@ public String execute(Jedis connection) { @Deprecated @Override public String save() { - return new JedisClusterCommand(connectionHandler, timeout, maxRedirections) { + return new JedisClusterCommand(connectionHandler, maxRedirections) { @Override public String execute(Jedis connection) { return connection.save(); @@ -1253,7 +1252,7 @@ public String execute(Jedis connection) { @Deprecated @Override public String bgsave() { - return new JedisClusterCommand(connectionHandler, timeout, maxRedirections) { + return new JedisClusterCommand(connectionHandler, maxRedirections) { @Override public String execute(Jedis connection) { return connection.bgsave(); @@ -1267,7 +1266,7 @@ public String execute(Jedis connection) { @Deprecated @Override public String bgrewriteaof() { - return new JedisClusterCommand(connectionHandler, timeout, maxRedirections) { + return new JedisClusterCommand(connectionHandler, maxRedirections) { @Override public String execute(Jedis connection) { return connection.bgrewriteaof(); @@ -1281,7 +1280,7 @@ public String execute(Jedis connection) { @Deprecated @Override public Long lastsave() { - return new JedisClusterCommand(connectionHandler, timeout, maxRedirections) { + return new JedisClusterCommand(connectionHandler, maxRedirections) { @Override public Long execute(Jedis connection) { return connection.lastsave(); @@ -1295,7 +1294,7 @@ public Long execute(Jedis connection) { @Deprecated @Override public String shutdown() { - return new JedisClusterCommand(connectionHandler, timeout, maxRedirections) { + return new JedisClusterCommand(connectionHandler, maxRedirections) { @Override public String execute(Jedis connection) { return connection.shutdown(); @@ -1309,7 +1308,7 @@ public String execute(Jedis connection) { @Deprecated @Override public String info() { - return new JedisClusterCommand(connectionHandler, timeout, maxRedirections) { + return new JedisClusterCommand(connectionHandler, maxRedirections) { @Override public String execute(Jedis connection) { return connection.info(); @@ -1323,7 +1322,7 @@ public String execute(Jedis connection) { @Deprecated @Override public String info(final String section) { - return new JedisClusterCommand(connectionHandler, timeout, maxRedirections) { + return new JedisClusterCommand(connectionHandler, maxRedirections) { @Override public String execute(Jedis connection) { return connection.info(section); @@ -1337,7 +1336,7 @@ public String execute(Jedis connection) { @Deprecated @Override public String slaveof(final String host, final int port) { - return new JedisClusterCommand(connectionHandler, timeout, maxRedirections) { + return new JedisClusterCommand(connectionHandler, maxRedirections) { @Override public String execute(Jedis connection) { return connection.slaveof(host, port); @@ -1351,7 +1350,7 @@ public String execute(Jedis connection) { @Deprecated @Override public String slaveofNoOne() { - return new JedisClusterCommand(connectionHandler, timeout, maxRedirections) { + return new JedisClusterCommand(connectionHandler, maxRedirections) { @Override public String execute(Jedis connection) { return connection.slaveofNoOne(); @@ -1365,7 +1364,7 @@ public String execute(Jedis connection) { @Deprecated @Override public Long getDB() { - return new JedisClusterCommand(connectionHandler, timeout, maxRedirections) { + return new JedisClusterCommand(connectionHandler, maxRedirections) { @Override public Long execute(Jedis connection) { return connection.getDB(); @@ -1379,7 +1378,7 @@ public Long execute(Jedis connection) { @Deprecated @Override public String debug(final DebugParams params) { - return new JedisClusterCommand(connectionHandler, timeout, maxRedirections) { + return new JedisClusterCommand(connectionHandler, maxRedirections) { @Override public String execute(Jedis connection) { return connection.debug(params); @@ -1393,7 +1392,7 @@ public String execute(Jedis connection) { @Deprecated @Override public String configResetStat() { - return new JedisClusterCommand(connectionHandler, timeout, maxRedirections) { + return new JedisClusterCommand(connectionHandler, maxRedirections) { @Override public String execute(Jedis connection) { return connection.configResetStat(); @@ -1423,7 +1422,7 @@ public Long waitReplicas(int replicas, long timeout) { */ @Override public ScanResult> hscan(final String key, final int cursor) { - return new JedisClusterCommand>>(connectionHandler, timeout, + return new JedisClusterCommand>>(connectionHandler, maxRedirections) { @Override public ScanResult> execute(Jedis connection) { @@ -1440,7 +1439,7 @@ public ScanResult> execute(Jedis connection) { */ @Override public ScanResult sscan(final String key, final int cursor) { - return new JedisClusterCommand>(connectionHandler, timeout, maxRedirections) { + return new JedisClusterCommand>(connectionHandler, maxRedirections) { @Override public ScanResult execute(Jedis connection) { return connection.sscan(key, cursor); @@ -1456,7 +1455,7 @@ public ScanResult execute(Jedis connection) { */ @Override public ScanResult zscan(final String key, final int cursor) { - return new JedisClusterCommand>(connectionHandler, timeout, maxRedirections) { + return new JedisClusterCommand>(connectionHandler, maxRedirections) { @Override public ScanResult execute(Jedis connection) { return connection.zscan(key, cursor); @@ -1466,7 +1465,7 @@ public ScanResult execute(Jedis connection) { @Override public ScanResult> hscan(final String key, final String cursor) { - return new JedisClusterCommand>>(connectionHandler, timeout, + return new JedisClusterCommand>>(connectionHandler, maxRedirections) { @Override public ScanResult> execute(Jedis connection) { @@ -1477,7 +1476,7 @@ public ScanResult> execute(Jedis connection) { @Override public ScanResult sscan(final String key, final String cursor) { - return new JedisClusterCommand>(connectionHandler, timeout, maxRedirections) { + return new JedisClusterCommand>(connectionHandler, maxRedirections) { @Override public ScanResult execute(Jedis connection) { return connection.sscan(key, cursor); @@ -1487,7 +1486,7 @@ public ScanResult execute(Jedis connection) { @Override public ScanResult zscan(final String key, final String cursor) { - return new JedisClusterCommand>(connectionHandler, timeout, maxRedirections) { + return new JedisClusterCommand>(connectionHandler, maxRedirections) { @Override public ScanResult execute(Jedis connection) { return connection.zscan(key, cursor); @@ -1497,7 +1496,7 @@ public ScanResult execute(Jedis connection) { @Override public Long pfadd(final String key, final String... elements) { - return new JedisClusterCommand(connectionHandler, timeout, maxRedirections) { + return new JedisClusterCommand(connectionHandler, maxRedirections) { @Override public Long execute(Jedis connection) { return connection.pfadd(key, elements); @@ -1507,7 +1506,7 @@ public Long execute(Jedis connection) { @Override public long pfcount(final String key) { - return new JedisClusterCommand(connectionHandler, timeout, maxRedirections) { + return new JedisClusterCommand(connectionHandler, maxRedirections) { @Override public Long execute(Jedis connection) { return connection.pfcount(key); @@ -1517,7 +1516,7 @@ public Long execute(Jedis connection) { @Override public List blpop(final int timeout, final String key) { - return new JedisClusterCommand>(connectionHandler, timeout, maxRedirections) { + return new JedisClusterCommand>(connectionHandler, maxRedirections) { @Override public List execute(Jedis connection) { return connection.blpop(timeout, key); @@ -1527,7 +1526,7 @@ public List execute(Jedis connection) { @Override public List brpop(final int timeout, final String key) { - return new JedisClusterCommand>(connectionHandler, timeout, maxRedirections) { + return new JedisClusterCommand>(connectionHandler, maxRedirections) { @Override public List execute(Jedis connection) { return connection.brpop(timeout, key); diff --git a/src/main/java/redis/clients/jedis/JedisClusterCommand.java b/src/main/java/redis/clients/jedis/JedisClusterCommand.java index 5861e4555e..1a112b5097 100644 --- a/src/main/java/redis/clients/jedis/JedisClusterCommand.java +++ b/src/main/java/redis/clients/jedis/JedisClusterCommand.java @@ -11,14 +11,11 @@ public abstract class JedisClusterCommand { private JedisClusterConnectionHandler connectionHandler; - private int commandTimeout; private int redirections; private ThreadLocal askConnection = new ThreadLocal(); - public JedisClusterCommand(JedisClusterConnectionHandler connectionHandler, int timeout, - int maxRedirections) { + public JedisClusterCommand(JedisClusterConnectionHandler connectionHandler, int maxRedirections) { this.connectionHandler = connectionHandler; - this.commandTimeout = timeout; this.redirections = maxRedirections; } diff --git a/src/main/java/redis/clients/jedis/JedisClusterConnectionHandler.java b/src/main/java/redis/clients/jedis/JedisClusterConnectionHandler.java index b0e4c58334..65ced432af 100644 --- a/src/main/java/redis/clients/jedis/JedisClusterConnectionHandler.java +++ b/src/main/java/redis/clients/jedis/JedisClusterConnectionHandler.java @@ -14,6 +14,8 @@ public abstract class JedisClusterConnectionHandler { abstract Jedis getConnection(); + private int timeout; + public void returnConnection(Jedis connection) { cache.getNode(getNodeKey(connection.getClient())).returnResource(connection); } @@ -30,8 +32,8 @@ public Jedis getConnectionFromNode(HostAndPort node) { } public JedisClusterConnectionHandler(Set nodes, - final GenericObjectPoolConfig poolConfig) { - this.cache = new JedisClusterInfoCache(poolConfig); + final GenericObjectPoolConfig poolConfig, int timeout) { + this.cache = new JedisClusterInfoCache(poolConfig, timeout); initializeSlotsCache(nodes, poolConfig); } diff --git a/src/main/java/redis/clients/jedis/JedisClusterInfoCache.java b/src/main/java/redis/clients/jedis/JedisClusterInfoCache.java index 261bd0422f..c869667897 100644 --- a/src/main/java/redis/clients/jedis/JedisClusterInfoCache.java +++ b/src/main/java/redis/clients/jedis/JedisClusterInfoCache.java @@ -24,7 +24,10 @@ public class JedisClusterInfoCache { private final Lock w = rwl.writeLock(); private final GenericObjectPoolConfig poolConfig; - public JedisClusterInfoCache(final GenericObjectPoolConfig poolConfig) { + private int timeout; + + public JedisClusterInfoCache(final GenericObjectPoolConfig poolConfig, int timeout) { + this.timeout = timeout; this.poolConfig = poolConfig; } @@ -94,7 +97,7 @@ public void setNodeIfNotExist(HostAndPort node) { String nodeKey = getNodeKey(node); if (nodes.containsKey(nodeKey)) return; - JedisPool nodePool = new JedisPool(poolConfig, node.getHost(), node.getPort()); + JedisPool nodePool = new JedisPool(poolConfig, node.getHost(), node.getPort(), timeout); nodes.put(nodeKey, nodePool); } finally { w.unlock(); diff --git a/src/main/java/redis/clients/jedis/JedisSlotBasedConnectionHandler.java b/src/main/java/redis/clients/jedis/JedisSlotBasedConnectionHandler.java index 74066c3897..190979eabe 100644 --- a/src/main/java/redis/clients/jedis/JedisSlotBasedConnectionHandler.java +++ b/src/main/java/redis/clients/jedis/JedisSlotBasedConnectionHandler.java @@ -12,8 +12,8 @@ public class JedisSlotBasedConnectionHandler extends JedisClusterConnectionHandler { public JedisSlotBasedConnectionHandler(Set nodes, - final GenericObjectPoolConfig poolConfig) { - super(nodes, poolConfig); + final GenericObjectPoolConfig poolConfig, int timeout) { + super(nodes, poolConfig, timeout); } public Jedis getConnection() { diff --git a/src/test/java/redis/clients/jedis/tests/JedisSentinelPoolTest.java b/src/test/java/redis/clients/jedis/tests/JedisSentinelPoolTest.java index 2fd61a83bd..ba4e5470ae 100644 --- a/src/test/java/redis/clients/jedis/tests/JedisSentinelPoolTest.java +++ b/src/test/java/redis/clients/jedis/tests/JedisSentinelPoolTest.java @@ -112,7 +112,7 @@ public void returnResourceShouldResetState() { jedis2 = null; } } finally { - if (jedis2 != null) pool.returnResource(jedis2); + if (jedis2 != null) jedis2.close(); pool.destroy(); }