diff --git a/pom.xml b/pom.xml index 69d56c082c..033a6df716 100644 --- a/pom.xml +++ b/pom.xml @@ -92,6 +92,12 @@ 2.3.2 test + + org.mockito + mockito-core + 3.7.7 + test + diff --git a/src/main/java/redis/clients/jedis/BinaryJedis.java b/src/main/java/redis/clients/jedis/BinaryJedis.java index cfedb64e15..2e3046098f 100644 --- a/src/main/java/redis/clients/jedis/BinaryJedis.java +++ b/src/main/java/redis/clients/jedis/BinaryJedis.java @@ -292,6 +292,11 @@ public BinaryJedis(final JedisSocketFactory jedisSocketFactory, final JedisClien initializeFromClientConfig(clientConfig); } + @Override + public String toString() { + return "BinaryJedis{" + client + '}'; + } + public boolean isConnected() { return client.isConnected(); } diff --git a/src/main/java/redis/clients/jedis/BinaryJedisCluster.java b/src/main/java/redis/clients/jedis/BinaryJedisCluster.java index 21575113c2..821248d268 100644 --- a/src/main/java/redis/clients/jedis/BinaryJedisCluster.java +++ b/src/main/java/redis/clients/jedis/BinaryJedisCluster.java @@ -12,6 +12,7 @@ import redis.clients.jedis.util.SafeEncoder; import java.io.Closeable; +import java.time.Duration; import java.util.List; import java.util.Map; import java.util.Map.Entry; @@ -26,11 +27,22 @@ public class BinaryJedisCluster implements BinaryJedisClusterCommands, MultiKeyBinaryJedisClusterCommands, JedisClusterBinaryScriptingCommands, Closeable { public static final int HASHSLOTS = 16384; - protected static final int DEFAULT_TIMEOUT = 2000; - protected static final int DEFAULT_MAX_ATTEMPTS = 5; + + /** + * Default timeout in milliseconds. + */ + public static final int DEFAULT_TIMEOUT = 2000; + public static final int DEFAULT_MAX_ATTEMPTS = 5; protected int maxAttempts; + /** + * After this amount of time we will do no more retries and report the operation as failed. + * + * Defaults to {@link #DEFAULT_TIMEOUT} if unset, or {@code soTimeout} if available. + */ + protected Duration maxTotalRetriesDuration; + protected JedisClusterConnectionHandler connectionHandler; public BinaryJedisCluster(Set nodes) { @@ -69,6 +81,7 @@ public BinaryJedisCluster(Set jedisClusterNode, int connectionTimeo this.connectionHandler = new JedisSlotBasedConnectionHandler(jedisClusterNode, poolConfig, connectionTimeout, soTimeout, user, password, clientName); this.maxAttempts = maxAttempts; + this.maxTotalRetriesDuration = Duration.ofMillis(soTimeout); } public BinaryJedisCluster(Set jedisClusterNode, int connectionTimeout, @@ -77,6 +90,7 @@ public BinaryJedisCluster(Set jedisClusterNode, int connectionTimeo this.connectionHandler = new JedisSlotBasedConnectionHandler(jedisClusterNode, poolConfig, connectionTimeout, soTimeout, infiniteSoTimeout, user, password, clientName); this.maxAttempts = maxAttempts; + this.maxTotalRetriesDuration = Duration.ofMillis(soTimeout); } public BinaryJedisCluster(Set jedisClusterNode, int connectionTimeout, @@ -129,17 +143,41 @@ public BinaryJedisCluster(Set jedisClusterNode, int connectionTimeo String clientName, GenericObjectPoolConfig poolConfig, boolean ssl, SSLSocketFactory sslSocketFactory, SSLParameters sslParameters, HostnameVerifier hostnameVerifier, JedisClusterHostAndPortMap hostAndPortMap) { + this(jedisClusterNode, connectionTimeout, soTimeout, infiniteSoTimeout, maxAttempts, user, + password, clientName, poolConfig, ssl, sslSocketFactory, sslParameters, hostnameVerifier, + hostAndPortMap, Duration.ofMillis((long) soTimeout * maxAttempts)); + } + + /** + * @param maxTotalRetriesDuration After this amount of time we will do no more retries and report + * the operation as failed. + * @deprecated This constructor will be removed in future. + */ + @Deprecated + public BinaryJedisCluster(Set jedisClusterNode, int connectionTimeout, int soTimeout, + int infiniteSoTimeout, int maxAttempts, String user, String password, String clientName, + GenericObjectPoolConfig poolConfig, boolean ssl, SSLSocketFactory sslSocketFactory, + SSLParameters sslParameters, HostnameVerifier hostnameVerifier, + JedisClusterHostAndPortMap hostAndPortMap, Duration maxTotalRetriesDuration) { this.connectionHandler = new JedisSlotBasedConnectionHandler(jedisClusterNode, poolConfig, connectionTimeout, soTimeout, infiniteSoTimeout, user, password, clientName, ssl, sslSocketFactory, sslParameters, hostnameVerifier, hostAndPortMap); this.maxAttempts = maxAttempts; + this.maxTotalRetriesDuration = maxTotalRetriesDuration; } public BinaryJedisCluster(Set jedisClusterNode, JedisClientConfig clientConfig, int maxAttempts, GenericObjectPoolConfig poolConfig) { + this(jedisClusterNode, clientConfig, maxAttempts, + Duration.ofMillis((long) DEFAULT_TIMEOUT * maxAttempts), poolConfig); + } + + public BinaryJedisCluster(Set jedisClusterNode, JedisClientConfig clientConfig, + int maxAttempts, Duration maxTotalRetriesDuration, GenericObjectPoolConfig poolConfig) { this.connectionHandler = new JedisSlotBasedConnectionHandler(jedisClusterNode, poolConfig, clientConfig); this.maxAttempts = maxAttempts; + this.maxTotalRetriesDuration = maxTotalRetriesDuration; } @Override @@ -159,7 +197,7 @@ public Jedis getConnectionFromSlot(int slot) { @Override public Boolean copy(byte[] srcKey, byte[] dstKey, boolean replace) { - return new JedisClusterCommand(connectionHandler, maxAttempts) { + return new JedisClusterCommand(connectionHandler, maxAttempts, maxTotalRetriesDuration) { @Override public Boolean execute(Jedis connection) { return connection.copy(srcKey, dstKey, replace); @@ -169,7 +207,7 @@ public Boolean execute(Jedis connection) { @Override public String set(final byte[] key, final byte[] value) { - return new JedisClusterCommand(connectionHandler, maxAttempts) { + return new JedisClusterCommand(connectionHandler, maxAttempts, maxTotalRetriesDuration) { @Override public String execute(Jedis connection) { return connection.set(key, value); @@ -179,7 +217,7 @@ public String execute(Jedis connection) { @Override public String set(final byte[] key, final byte[] value, final SetParams params) { - return new JedisClusterCommand(connectionHandler, maxAttempts) { + return new JedisClusterCommand(connectionHandler, maxAttempts, maxTotalRetriesDuration) { @Override public String execute(Jedis connection) { return connection.set(key, value, params); @@ -189,7 +227,7 @@ public String execute(Jedis connection) { @Override public byte[] get(final byte[] key) { - return new JedisClusterCommand(connectionHandler, maxAttempts) { + return new JedisClusterCommand(connectionHandler, maxAttempts, maxTotalRetriesDuration) { @Override public byte[] execute(Jedis connection) { return connection.get(key); @@ -199,7 +237,7 @@ public byte[] execute(Jedis connection) { @Override public byte[] getDel(final byte[] key) { - return new JedisClusterCommand(connectionHandler, maxAttempts) { + return new JedisClusterCommand(connectionHandler, maxAttempts, maxTotalRetriesDuration) { @Override public byte[] execute(Jedis connection) { return connection.getDel(key); @@ -209,7 +247,7 @@ public byte[] execute(Jedis connection) { @Override public byte[] getEx(byte[] key, GetExParams params) { - return new JedisClusterCommand(connectionHandler, maxAttempts) { + return new JedisClusterCommand(connectionHandler, maxAttempts, maxTotalRetriesDuration) { @Override public byte[] execute(Jedis connection) { return connection.getEx(key, params); @@ -219,7 +257,7 @@ public byte[] execute(Jedis connection) { @Override public Long exists(final byte[]... keys) { - return new JedisClusterCommand(connectionHandler, maxAttempts) { + return new JedisClusterCommand(connectionHandler, maxAttempts, maxTotalRetriesDuration) { @Override public Long execute(Jedis connection) { return connection.exists(keys); @@ -229,7 +267,7 @@ public Long execute(Jedis connection) { @Override public Boolean exists(final byte[] key) { - return new JedisClusterCommand(connectionHandler, maxAttempts) { + return new JedisClusterCommand(connectionHandler, maxAttempts, maxTotalRetriesDuration) { @Override public Boolean execute(Jedis connection) { return connection.exists(key); @@ -239,7 +277,7 @@ public Boolean execute(Jedis connection) { @Override public Long persist(final byte[] key) { - return new JedisClusterCommand(connectionHandler, maxAttempts) { + return new JedisClusterCommand(connectionHandler, maxAttempts, maxTotalRetriesDuration) { @Override public Long execute(Jedis connection) { return connection.persist(key); @@ -249,7 +287,7 @@ public Long execute(Jedis connection) { @Override public String type(final byte[] key) { - return new JedisClusterCommand(connectionHandler, maxAttempts) { + return new JedisClusterCommand(connectionHandler, maxAttempts, maxTotalRetriesDuration) { @Override public String execute(Jedis connection) { return connection.type(key); @@ -259,7 +297,7 @@ public String execute(Jedis connection) { @Override public byte[] dump(final byte[] key) { - return new JedisClusterCommand(connectionHandler, maxAttempts) { + return new JedisClusterCommand(connectionHandler, maxAttempts, maxTotalRetriesDuration) { @Override public byte[] execute(Jedis connection) { return connection.dump(key); @@ -269,7 +307,7 @@ public byte[] execute(Jedis connection) { @Override public String restore(final byte[] key, final long ttl, final byte[] serializedValue) { - return new JedisClusterCommand(connectionHandler, maxAttempts) { + return new JedisClusterCommand(connectionHandler, maxAttempts, maxTotalRetriesDuration) { @Override public String execute(Jedis connection) { return connection.restore(key, ttl, serializedValue); @@ -280,7 +318,7 @@ public String execute(Jedis connection) { @Override public String restore(final byte[] key, final long ttl, final byte[] serializedValue, final RestoreParams params) { - return new JedisClusterCommand(connectionHandler, maxAttempts) { + return new JedisClusterCommand(connectionHandler, maxAttempts, maxTotalRetriesDuration) { @Override public String execute(Jedis connection) { return connection.restore(key, ttl, serializedValue, params); @@ -290,7 +328,7 @@ public String execute(Jedis connection) { @Override public Long expire(final byte[] key, final int seconds) { - return new JedisClusterCommand(connectionHandler, maxAttempts) { + return new JedisClusterCommand(connectionHandler, maxAttempts, maxTotalRetriesDuration) { @Override public Long execute(Jedis connection) { return connection.expire(key, seconds); @@ -300,7 +338,7 @@ public Long execute(Jedis connection) { @Override public Long pexpire(final byte[] key, final long milliseconds) { - return new JedisClusterCommand(connectionHandler, maxAttempts) { + return new JedisClusterCommand(connectionHandler, maxAttempts, maxTotalRetriesDuration) { @Override public Long execute(Jedis connection) { return connection.pexpire(key, milliseconds); @@ -310,7 +348,7 @@ public Long execute(Jedis connection) { @Override public Long expireAt(final byte[] key, final long unixTime) { - return new JedisClusterCommand(connectionHandler, maxAttempts) { + return new JedisClusterCommand(connectionHandler, maxAttempts, maxTotalRetriesDuration) { @Override public Long execute(Jedis connection) { return connection.expireAt(key, unixTime); @@ -320,7 +358,7 @@ public Long execute(Jedis connection) { @Override public Long pexpireAt(final byte[] key, final long millisecondsTimestamp) { - return new JedisClusterCommand(connectionHandler, maxAttempts) { + return new JedisClusterCommand(connectionHandler, maxAttempts, maxTotalRetriesDuration) { @Override public Long execute(Jedis connection) { return connection.pexpireAt(key, millisecondsTimestamp); @@ -330,7 +368,7 @@ public Long execute(Jedis connection) { @Override public Long ttl(final byte[] key) { - return new JedisClusterCommand(connectionHandler, maxAttempts) { + return new JedisClusterCommand(connectionHandler, maxAttempts, maxTotalRetriesDuration) { @Override public Long execute(Jedis connection) { return connection.ttl(key); @@ -340,7 +378,7 @@ public Long execute(Jedis connection) { @Override public Long pttl(final byte[] key) { - return new JedisClusterCommand(connectionHandler, maxAttempts) { + return new JedisClusterCommand(connectionHandler, maxAttempts, maxTotalRetriesDuration) { @Override public Long execute(Jedis connection) { return connection.pttl(key); @@ -350,7 +388,7 @@ public Long execute(Jedis connection) { @Override public Long touch(final byte[] key) { - return new JedisClusterCommand(connectionHandler, maxAttempts) { + return new JedisClusterCommand(connectionHandler, maxAttempts, maxTotalRetriesDuration) { @Override public Long execute(Jedis connection) { return connection.touch(key); @@ -360,7 +398,7 @@ public Long execute(Jedis connection) { @Override public Long touch(final byte[]... keys) { - return new JedisClusterCommand(connectionHandler, maxAttempts) { + return new JedisClusterCommand(connectionHandler, maxAttempts, maxTotalRetriesDuration) { @Override public Long execute(Jedis connection) { return connection.touch(keys); @@ -370,7 +408,7 @@ public Long execute(Jedis connection) { @Override public Boolean setbit(final byte[] key, final long offset, final boolean value) { - return new JedisClusterCommand(connectionHandler, maxAttempts) { + return new JedisClusterCommand(connectionHandler, maxAttempts, maxTotalRetriesDuration) { @Override public Boolean execute(Jedis connection) { return connection.setbit(key, offset, value); @@ -380,7 +418,7 @@ public Boolean execute(Jedis connection) { @Override public Boolean setbit(final byte[] key, final long offset, final byte[] value) { - return new JedisClusterCommand(connectionHandler, maxAttempts) { + return new JedisClusterCommand(connectionHandler, maxAttempts, maxTotalRetriesDuration) { @Override public Boolean execute(Jedis connection) { return connection.setbit(key, offset, value); @@ -390,7 +428,7 @@ public Boolean execute(Jedis connection) { @Override public Boolean getbit(final byte[] key, final long offset) { - return new JedisClusterCommand(connectionHandler, maxAttempts) { + return new JedisClusterCommand(connectionHandler, maxAttempts, maxTotalRetriesDuration) { @Override public Boolean execute(Jedis connection) { return connection.getbit(key, offset); @@ -400,7 +438,7 @@ public Boolean execute(Jedis connection) { @Override public Long setrange(final byte[] key, final long offset, final byte[] value) { - return new JedisClusterCommand(connectionHandler, maxAttempts) { + return new JedisClusterCommand(connectionHandler, maxAttempts, maxTotalRetriesDuration) { @Override public Long execute(Jedis connection) { return connection.setrange(key, offset, value); @@ -410,7 +448,7 @@ public Long execute(Jedis connection) { @Override public byte[] getrange(final byte[] key, final long startOffset, final long endOffset) { - return new JedisClusterCommand(connectionHandler, maxAttempts) { + return new JedisClusterCommand(connectionHandler, maxAttempts, maxTotalRetriesDuration) { @Override public byte[] execute(Jedis connection) { return connection.getrange(key, startOffset, endOffset); @@ -420,7 +458,7 @@ public byte[] execute(Jedis connection) { @Override public byte[] getSet(final byte[] key, final byte[] value) { - return new JedisClusterCommand(connectionHandler, maxAttempts) { + return new JedisClusterCommand(connectionHandler, maxAttempts, maxTotalRetriesDuration) { @Override public byte[] execute(Jedis connection) { return connection.getSet(key, value); @@ -430,7 +468,7 @@ public byte[] execute(Jedis connection) { @Override public Long setnx(final byte[] key, final byte[] value) { - return new JedisClusterCommand(connectionHandler, maxAttempts) { + return new JedisClusterCommand(connectionHandler, maxAttempts, maxTotalRetriesDuration) { @Override public Long execute(Jedis connection) { return connection.setnx(key, value); @@ -440,7 +478,7 @@ public Long execute(Jedis connection) { @Override public String psetex(final byte[] key, final long milliseconds, final byte[] value) { - return new JedisClusterCommand(connectionHandler, maxAttempts) { + return new JedisClusterCommand(connectionHandler, maxAttempts, maxTotalRetriesDuration) { @Override public String execute(Jedis connection) { return connection.psetex(key, milliseconds, value); @@ -450,7 +488,7 @@ public String execute(Jedis connection) { @Override public String setex(final byte[] key, final long seconds, final byte[] value) { - return new JedisClusterCommand(connectionHandler, maxAttempts) { + return new JedisClusterCommand(connectionHandler, maxAttempts, maxTotalRetriesDuration) { @Override public String execute(Jedis connection) { return connection.setex(key, seconds, value); @@ -460,7 +498,7 @@ public String execute(Jedis connection) { @Override public Long decrBy(final byte[] key, final long decrement) { - return new JedisClusterCommand(connectionHandler, maxAttempts) { + return new JedisClusterCommand(connectionHandler, maxAttempts, maxTotalRetriesDuration) { @Override public Long execute(Jedis connection) { return connection.decrBy(key, decrement); @@ -470,7 +508,7 @@ public Long execute(Jedis connection) { @Override public Long decr(final byte[] key) { - return new JedisClusterCommand(connectionHandler, maxAttempts) { + return new JedisClusterCommand(connectionHandler, maxAttempts, maxTotalRetriesDuration) { @Override public Long execute(Jedis connection) { return connection.decr(key); @@ -480,7 +518,7 @@ public Long execute(Jedis connection) { @Override public Long incrBy(final byte[] key, final long increment) { - return new JedisClusterCommand(connectionHandler, maxAttempts) { + return new JedisClusterCommand(connectionHandler, maxAttempts, maxTotalRetriesDuration) { @Override public Long execute(Jedis connection) { return connection.incrBy(key, increment); @@ -490,7 +528,7 @@ public Long execute(Jedis connection) { @Override public Double incrByFloat(final byte[] key, final double increment) { - return new JedisClusterCommand(connectionHandler, maxAttempts) { + return new JedisClusterCommand(connectionHandler, maxAttempts, maxTotalRetriesDuration) { @Override public Double execute(Jedis connection) { return connection.incrByFloat(key, increment); @@ -500,7 +538,7 @@ public Double execute(Jedis connection) { @Override public Long incr(final byte[] key) { - return new JedisClusterCommand(connectionHandler, maxAttempts) { + return new JedisClusterCommand(connectionHandler, maxAttempts, maxTotalRetriesDuration) { @Override public Long execute(Jedis connection) { return connection.incr(key); @@ -510,7 +548,7 @@ public Long execute(Jedis connection) { @Override public Long append(final byte[] key, final byte[] value) { - return new JedisClusterCommand(connectionHandler, maxAttempts) { + return new JedisClusterCommand(connectionHandler, maxAttempts, maxTotalRetriesDuration) { @Override public Long execute(Jedis connection) { return connection.append(key, value); @@ -520,7 +558,7 @@ public Long execute(Jedis connection) { @Override public byte[] substr(final byte[] key, final int start, final int end) { - return new JedisClusterCommand(connectionHandler, maxAttempts) { + return new JedisClusterCommand(connectionHandler, maxAttempts, maxTotalRetriesDuration) { @Override public byte[] execute(Jedis connection) { return connection.substr(key, start, end); @@ -530,7 +568,7 @@ public byte[] execute(Jedis connection) { @Override public Long hset(final byte[] key, final byte[] field, final byte[] value) { - return new JedisClusterCommand(connectionHandler, maxAttempts) { + return new JedisClusterCommand(connectionHandler, maxAttempts, maxTotalRetriesDuration) { @Override public Long execute(Jedis connection) { return connection.hset(key, field, value); @@ -540,7 +578,7 @@ public Long execute(Jedis connection) { @Override public Long hset(final byte[] key, final Map hash) { - return new JedisClusterCommand(connectionHandler, maxAttempts) { + return new JedisClusterCommand(connectionHandler, maxAttempts, maxTotalRetriesDuration) { @Override public Long execute(Jedis connection) { return connection.hset(key, hash); @@ -550,7 +588,7 @@ public Long execute(Jedis connection) { @Override public byte[] hget(final byte[] key, final byte[] field) { - return new JedisClusterCommand(connectionHandler, maxAttempts) { + return new JedisClusterCommand(connectionHandler, maxAttempts, maxTotalRetriesDuration) { @Override public byte[] execute(Jedis connection) { return connection.hget(key, field); @@ -560,7 +598,7 @@ public byte[] execute(Jedis connection) { @Override public Long hsetnx(final byte[] key, final byte[] field, final byte[] value) { - return new JedisClusterCommand(connectionHandler, maxAttempts) { + return new JedisClusterCommand(connectionHandler, maxAttempts, maxTotalRetriesDuration) { @Override public Long execute(Jedis connection) { return connection.hsetnx(key, field, value); @@ -570,7 +608,7 @@ public Long execute(Jedis connection) { @Override public String hmset(final byte[] key, final Map hash) { - return new JedisClusterCommand(connectionHandler, maxAttempts) { + return new JedisClusterCommand(connectionHandler, maxAttempts, maxTotalRetriesDuration) { @Override public String execute(Jedis connection) { return connection.hmset(key, hash); @@ -580,7 +618,7 @@ public String execute(Jedis connection) { @Override public List hmget(final byte[] key, final byte[]... fields) { - return new JedisClusterCommand>(connectionHandler, maxAttempts) { + return new JedisClusterCommand>(connectionHandler, maxAttempts, maxTotalRetriesDuration) { @Override public List execute(Jedis connection) { return connection.hmget(key, fields); @@ -590,7 +628,7 @@ public List execute(Jedis connection) { @Override public Long hincrBy(final byte[] key, final byte[] field, final long value) { - return new JedisClusterCommand(connectionHandler, maxAttempts) { + return new JedisClusterCommand(connectionHandler, maxAttempts, maxTotalRetriesDuration) { @Override public Long execute(Jedis connection) { return connection.hincrBy(key, field, value); @@ -600,7 +638,7 @@ public Long execute(Jedis connection) { @Override public Double hincrByFloat(final byte[] key, final byte[] field, final double value) { - return new JedisClusterCommand(connectionHandler, maxAttempts) { + return new JedisClusterCommand(connectionHandler, maxAttempts, maxTotalRetriesDuration) { @Override public Double execute(Jedis connection) { return connection.hincrByFloat(key, field, value); @@ -610,7 +648,7 @@ public Double execute(Jedis connection) { @Override public Boolean hexists(final byte[] key, final byte[] field) { - return new JedisClusterCommand(connectionHandler, maxAttempts) { + return new JedisClusterCommand(connectionHandler, maxAttempts, maxTotalRetriesDuration) { @Override public Boolean execute(Jedis connection) { return connection.hexists(key, field); @@ -620,7 +658,7 @@ public Boolean execute(Jedis connection) { @Override public Long hdel(final byte[] key, final byte[]... field) { - return new JedisClusterCommand(connectionHandler, maxAttempts) { + return new JedisClusterCommand(connectionHandler, maxAttempts, maxTotalRetriesDuration) { @Override public Long execute(Jedis connection) { return connection.hdel(key, field); @@ -630,7 +668,7 @@ public Long execute(Jedis connection) { @Override public Long hlen(final byte[] key) { - return new JedisClusterCommand(connectionHandler, maxAttempts) { + return new JedisClusterCommand(connectionHandler, maxAttempts, maxTotalRetriesDuration) { @Override public Long execute(Jedis connection) { return connection.hlen(key); @@ -640,7 +678,7 @@ public Long execute(Jedis connection) { @Override public Set hkeys(final byte[] key) { - return new JedisClusterCommand>(connectionHandler, maxAttempts) { + return new JedisClusterCommand>(connectionHandler, maxAttempts, maxTotalRetriesDuration) { @Override public Set execute(Jedis connection) { return connection.hkeys(key); @@ -650,7 +688,7 @@ public Set execute(Jedis connection) { @Override public List hvals(final byte[] key) { - return new JedisClusterCommand>(connectionHandler, maxAttempts) { + return new JedisClusterCommand>(connectionHandler, maxAttempts, maxTotalRetriesDuration) { @Override public List execute(Jedis connection) { return connection.hvals(key); @@ -660,7 +698,7 @@ public List execute(Jedis connection) { @Override public Map hgetAll(final byte[] key) { - return new JedisClusterCommand>(connectionHandler, maxAttempts) { + return new JedisClusterCommand>(connectionHandler, maxAttempts, maxTotalRetriesDuration) { @Override public Map execute(Jedis connection) { return connection.hgetAll(key); @@ -670,7 +708,7 @@ public Map execute(Jedis connection) { @Override public byte[] hrandfield(final byte[] key) { - return new JedisClusterCommand(connectionHandler, maxAttempts) { + return new JedisClusterCommand(connectionHandler, maxAttempts, maxTotalRetriesDuration) { @Override public byte[] execute(Jedis connection) { return connection.hrandfield(key); @@ -680,7 +718,7 @@ public byte[] execute(Jedis connection) { @Override public List hrandfield(final byte[] key, final long count) { - return new JedisClusterCommand>(connectionHandler, maxAttempts) { + return new JedisClusterCommand>(connectionHandler, maxAttempts, maxTotalRetriesDuration) { @Override public List execute(Jedis connection) { return connection.hrandfield(key, count); @@ -690,7 +728,7 @@ public List execute(Jedis connection) { @Override public Map hrandfieldWithValues(final byte[] key, final long count) { - return new JedisClusterCommand>(connectionHandler, maxAttempts) { + return new JedisClusterCommand>(connectionHandler, maxAttempts, maxTotalRetriesDuration) { @Override public Map execute(Jedis connection) { return connection.hrandfieldWithValues(key, count); @@ -700,7 +738,7 @@ public Map execute(Jedis connection) { @Override public Long rpush(final byte[] key, final byte[]... args) { - return new JedisClusterCommand(connectionHandler, maxAttempts) { + return new JedisClusterCommand(connectionHandler, maxAttempts, maxTotalRetriesDuration) { @Override public Long execute(Jedis connection) { return connection.rpush(key, args); @@ -710,7 +748,7 @@ public Long execute(Jedis connection) { @Override public Long lpush(final byte[] key, final byte[]... args) { - return new JedisClusterCommand(connectionHandler, maxAttempts) { + return new JedisClusterCommand(connectionHandler, maxAttempts, maxTotalRetriesDuration) { @Override public Long execute(Jedis connection) { return connection.lpush(key, args); @@ -720,7 +758,7 @@ public Long execute(Jedis connection) { @Override public Long llen(final byte[] key) { - return new JedisClusterCommand(connectionHandler, maxAttempts) { + return new JedisClusterCommand(connectionHandler, maxAttempts, maxTotalRetriesDuration) { @Override public Long execute(Jedis connection) { return connection.llen(key); @@ -730,7 +768,7 @@ public Long execute(Jedis connection) { @Override public List lrange(final byte[] key, final long start, final long stop) { - return new JedisClusterCommand>(connectionHandler, maxAttempts) { + return new JedisClusterCommand>(connectionHandler, maxAttempts, maxTotalRetriesDuration) { @Override public List execute(Jedis connection) { return connection.lrange(key, start, stop); @@ -740,7 +778,7 @@ public List execute(Jedis connection) { @Override public String ltrim(final byte[] key, final long start, final long stop) { - return new JedisClusterCommand(connectionHandler, maxAttempts) { + return new JedisClusterCommand(connectionHandler, maxAttempts, maxTotalRetriesDuration) { @Override public String execute(Jedis connection) { return connection.ltrim(key, start, stop); @@ -750,7 +788,7 @@ public String execute(Jedis connection) { @Override public byte[] lindex(final byte[] key, final long index) { - return new JedisClusterCommand(connectionHandler, maxAttempts) { + return new JedisClusterCommand(connectionHandler, maxAttempts, maxTotalRetriesDuration) { @Override public byte[] execute(Jedis connection) { return connection.lindex(key, index); @@ -760,7 +798,7 @@ public byte[] execute(Jedis connection) { @Override public String lset(final byte[] key, final long index, final byte[] value) { - return new JedisClusterCommand(connectionHandler, maxAttempts) { + return new JedisClusterCommand(connectionHandler, maxAttempts, maxTotalRetriesDuration) { @Override public String execute(Jedis connection) { return connection.lset(key, index, value); @@ -770,7 +808,7 @@ public String execute(Jedis connection) { @Override public Long lrem(final byte[] key, final long count, final byte[] value) { - return new JedisClusterCommand(connectionHandler, maxAttempts) { + return new JedisClusterCommand(connectionHandler, maxAttempts, maxTotalRetriesDuration) { @Override public Long execute(Jedis connection) { return connection.lrem(key, count, value); @@ -780,7 +818,7 @@ public Long execute(Jedis connection) { @Override public byte[] lpop(final byte[] key) { - return new JedisClusterCommand(connectionHandler, maxAttempts) { + return new JedisClusterCommand(connectionHandler, maxAttempts, maxTotalRetriesDuration) { @Override public byte[] execute(Jedis connection) { return connection.lpop(key); @@ -790,7 +828,7 @@ public byte[] execute(Jedis connection) { @Override public List lpop(final byte[] key, final int count) { - return new JedisClusterCommand>(connectionHandler, maxAttempts) { + return new JedisClusterCommand>(connectionHandler, maxAttempts, maxTotalRetriesDuration) { @Override public List execute(Jedis connection) { return connection.lpop(key, count); @@ -800,7 +838,7 @@ public List execute(Jedis connection) { @Override public Long lpos(final byte[] key, final byte[] element) { - return new JedisClusterCommand(connectionHandler, maxAttempts) { + return new JedisClusterCommand(connectionHandler, maxAttempts, maxTotalRetriesDuration) { @Override public Long execute(Jedis connection) { return connection.lpos(key, element); @@ -810,7 +848,7 @@ public Long execute(Jedis connection) { @Override public Long lpos(final byte[] key, final byte[] element, final LPosParams params) { - return new JedisClusterCommand(connectionHandler, maxAttempts) { + return new JedisClusterCommand(connectionHandler, maxAttempts, maxTotalRetriesDuration) { @Override public Long execute(Jedis connection) { return connection.lpos(key, element, params); @@ -821,7 +859,7 @@ public Long execute(Jedis connection) { @Override public List lpos(final byte[] key, final byte[] element, final LPosParams params, final long count) { - return new JedisClusterCommand>(connectionHandler, maxAttempts) { + return new JedisClusterCommand>(connectionHandler, maxAttempts, maxTotalRetriesDuration) { @Override public List execute(Jedis connection) { return connection.lpos(key, element, params, count); @@ -831,7 +869,7 @@ public List execute(Jedis connection) { @Override public byte[] rpop(final byte[] key) { - return new JedisClusterCommand(connectionHandler, maxAttempts) { + return new JedisClusterCommand(connectionHandler, maxAttempts, maxTotalRetriesDuration) { @Override public byte[] execute(Jedis connection) { return connection.rpop(key); @@ -841,7 +879,7 @@ public byte[] execute(Jedis connection) { @Override public List rpop(final byte[] key, final int count) { - return new JedisClusterCommand>(connectionHandler, maxAttempts) { + return new JedisClusterCommand>(connectionHandler, maxAttempts, maxTotalRetriesDuration) { @Override public List execute(Jedis connection) { return connection.rpop(key, count); @@ -851,7 +889,7 @@ public List execute(Jedis connection) { @Override public Long sadd(final byte[] key, final byte[]... member) { - return new JedisClusterCommand(connectionHandler, maxAttempts) { + return new JedisClusterCommand(connectionHandler, maxAttempts, maxTotalRetriesDuration) { @Override public Long execute(Jedis connection) { return connection.sadd(key, member); @@ -861,7 +899,7 @@ public Long execute(Jedis connection) { @Override public Set smembers(final byte[] key) { - return new JedisClusterCommand>(connectionHandler, maxAttempts) { + return new JedisClusterCommand>(connectionHandler, maxAttempts, maxTotalRetriesDuration) { @Override public Set execute(Jedis connection) { return connection.smembers(key); @@ -871,7 +909,7 @@ public Set execute(Jedis connection) { @Override public Long srem(final byte[] key, final byte[]... member) { - return new JedisClusterCommand(connectionHandler, maxAttempts) { + return new JedisClusterCommand(connectionHandler, maxAttempts, maxTotalRetriesDuration) { @Override public Long execute(Jedis connection) { return connection.srem(key, member); @@ -881,7 +919,7 @@ public Long execute(Jedis connection) { @Override public byte[] spop(final byte[] key) { - return new JedisClusterCommand(connectionHandler, maxAttempts) { + return new JedisClusterCommand(connectionHandler, maxAttempts, maxTotalRetriesDuration) { @Override public byte[] execute(Jedis connection) { return connection.spop(key); @@ -891,7 +929,7 @@ public byte[] execute(Jedis connection) { @Override public Set spop(final byte[] key, final long count) { - return new JedisClusterCommand>(connectionHandler, maxAttempts) { + return new JedisClusterCommand>(connectionHandler, maxAttempts, maxTotalRetriesDuration) { @Override public Set execute(Jedis connection) { return connection.spop(key, count); @@ -901,7 +939,7 @@ public Set execute(Jedis connection) { @Override public Long scard(final byte[] key) { - return new JedisClusterCommand(connectionHandler, maxAttempts) { + return new JedisClusterCommand(connectionHandler, maxAttempts, maxTotalRetriesDuration) { @Override public Long execute(Jedis connection) { return connection.scard(key); @@ -911,7 +949,7 @@ public Long execute(Jedis connection) { @Override public Boolean sismember(final byte[] key, final byte[] member) { - return new JedisClusterCommand(connectionHandler, maxAttempts) { + return new JedisClusterCommand(connectionHandler, maxAttempts, maxTotalRetriesDuration) { @Override public Boolean execute(Jedis connection) { return connection.sismember(key, member); @@ -921,7 +959,7 @@ public Boolean execute(Jedis connection) { @Override public List smismember(final byte[] key, final byte[]... members) { - return new JedisClusterCommand>(connectionHandler, maxAttempts) { + return new JedisClusterCommand>(connectionHandler, maxAttempts, maxTotalRetriesDuration) { @Override public List execute(Jedis connection) { return connection.smismember(key, members); @@ -931,7 +969,7 @@ public List execute(Jedis connection) { @Override public byte[] srandmember(final byte[] key) { - return new JedisClusterCommand(connectionHandler, maxAttempts) { + return new JedisClusterCommand(connectionHandler, maxAttempts, maxTotalRetriesDuration) { @Override public byte[] execute(Jedis connection) { return connection.srandmember(key); @@ -941,7 +979,7 @@ public byte[] execute(Jedis connection) { @Override public Long strlen(final byte[] key) { - return new JedisClusterCommand(connectionHandler, maxAttempts) { + return new JedisClusterCommand(connectionHandler, maxAttempts, maxTotalRetriesDuration) { @Override public Long execute(Jedis connection) { return connection.strlen(key); @@ -951,7 +989,7 @@ public Long execute(Jedis connection) { @Override public Long zadd(final byte[] key, final double score, final byte[] member) { - return new JedisClusterCommand(connectionHandler, maxAttempts) { + return new JedisClusterCommand(connectionHandler, maxAttempts, maxTotalRetriesDuration) { @Override public Long execute(Jedis connection) { return connection.zadd(key, score, member); @@ -962,7 +1000,7 @@ public Long execute(Jedis connection) { @Override public Long zadd(final byte[] key, final double score, final byte[] member, final ZAddParams params) { - return new JedisClusterCommand(connectionHandler, maxAttempts) { + return new JedisClusterCommand(connectionHandler, maxAttempts, maxTotalRetriesDuration) { @Override public Long execute(Jedis connection) { return connection.zadd(key, score, member, params); @@ -972,7 +1010,7 @@ public Long execute(Jedis connection) { @Override public Long zadd(final byte[] key, final Map scoreMembers) { - return new JedisClusterCommand(connectionHandler, maxAttempts) { + return new JedisClusterCommand(connectionHandler, maxAttempts, maxTotalRetriesDuration) { @Override public Long execute(Jedis connection) { return connection.zadd(key, scoreMembers); @@ -982,7 +1020,7 @@ public Long execute(Jedis connection) { @Override public Long zadd(final byte[] key, final Map scoreMembers, final ZAddParams params) { - return new JedisClusterCommand(connectionHandler, maxAttempts) { + return new JedisClusterCommand(connectionHandler, maxAttempts, maxTotalRetriesDuration) { @Override public Long execute(Jedis connection) { return connection.zadd(key, scoreMembers, params); @@ -992,7 +1030,7 @@ public Long execute(Jedis connection) { @Override public Double zaddIncr(byte[] key, double score, byte[] member, ZAddParams params) { - return new JedisClusterCommand(connectionHandler, maxAttempts) { + return new JedisClusterCommand(connectionHandler, maxAttempts, maxTotalRetriesDuration) { @Override public Double execute(Jedis connection) { return connection.zaddIncr(key, score, member, params); @@ -1002,7 +1040,7 @@ public Double execute(Jedis connection) { @Override public Set zdiff(final byte[]... keys) { - return new JedisClusterCommand>(connectionHandler, maxAttempts) { + return new JedisClusterCommand>(connectionHandler, maxAttempts, maxTotalRetriesDuration) { @Override public Set execute(Jedis connection) { return connection.zdiff(keys); @@ -1012,7 +1050,7 @@ public Set execute(Jedis connection) { @Override public Set zdiffWithScores(final byte[]... keys) { - return new JedisClusterCommand>(connectionHandler, maxAttempts) { + return new JedisClusterCommand>(connectionHandler, maxAttempts, maxTotalRetriesDuration) { @Override public Set execute(Jedis connection) { return connection.zdiffWithScores(keys); @@ -1023,7 +1061,7 @@ public Set execute(Jedis connection) { @Override public Long zdiffStore(final byte[] dstkey, final byte[]... keys) { byte[][] wholeKeys = KeyMergeUtil.merge(dstkey, keys); - return new JedisClusterCommand(connectionHandler, maxAttempts) { + return new JedisClusterCommand(connectionHandler, maxAttempts, maxTotalRetriesDuration) { @Override public Long execute(Jedis connection) { return connection.zdiffStore(dstkey, keys); @@ -1033,7 +1071,7 @@ public Long execute(Jedis connection) { @Override public Set zrange(final byte[] key, final long start, final long stop) { - return new JedisClusterCommand>(connectionHandler, maxAttempts) { + return new JedisClusterCommand>(connectionHandler, maxAttempts, maxTotalRetriesDuration) { @Override public Set execute(Jedis connection) { return connection.zrange(key, start, stop); @@ -1043,7 +1081,7 @@ public Set execute(Jedis connection) { @Override public Long zrem(final byte[] key, final byte[]... members) { - return new JedisClusterCommand(connectionHandler, maxAttempts) { + return new JedisClusterCommand(connectionHandler, maxAttempts, maxTotalRetriesDuration) { @Override public Long execute(Jedis connection) { return connection.zrem(key, members); @@ -1053,7 +1091,7 @@ public Long execute(Jedis connection) { @Override public Double zincrby(final byte[] key, final double increment, final byte[] member) { - return new JedisClusterCommand(connectionHandler, maxAttempts) { + return new JedisClusterCommand(connectionHandler, maxAttempts, maxTotalRetriesDuration) { @Override public Double execute(Jedis connection) { return connection.zincrby(key, increment, member); @@ -1064,7 +1102,7 @@ public Double execute(Jedis connection) { @Override public Double zincrby(final byte[] key, final double increment, final byte[] member, final ZIncrByParams params) { - return new JedisClusterCommand(connectionHandler, maxAttempts) { + return new JedisClusterCommand(connectionHandler, maxAttempts, maxTotalRetriesDuration) { @Override public Double execute(Jedis connection) { return connection.zincrby(key, increment, member, params); @@ -1074,7 +1112,7 @@ public Double execute(Jedis connection) { @Override public Long zrank(final byte[] key, final byte[] member) { - return new JedisClusterCommand(connectionHandler, maxAttempts) { + return new JedisClusterCommand(connectionHandler, maxAttempts, maxTotalRetriesDuration) { @Override public Long execute(Jedis connection) { return connection.zrank(key, member); @@ -1084,7 +1122,7 @@ public Long execute(Jedis connection) { @Override public Long zrevrank(final byte[] key, final byte[] member) { - return new JedisClusterCommand(connectionHandler, maxAttempts) { + return new JedisClusterCommand(connectionHandler, maxAttempts, maxTotalRetriesDuration) { @Override public Long execute(Jedis connection) { return connection.zrevrank(key, member); @@ -1094,7 +1132,7 @@ public Long execute(Jedis connection) { @Override public Set zrevrange(final byte[] key, final long start, final long stop) { - return new JedisClusterCommand>(connectionHandler, maxAttempts) { + return new JedisClusterCommand>(connectionHandler, maxAttempts, maxTotalRetriesDuration) { @Override public Set execute(Jedis connection) { return connection.zrevrange(key, start, stop); @@ -1104,7 +1142,7 @@ public Set execute(Jedis connection) { @Override public Set zrangeWithScores(final byte[] key, final long start, final long stop) { - return new JedisClusterCommand>(connectionHandler, maxAttempts) { + return new JedisClusterCommand>(connectionHandler, maxAttempts, maxTotalRetriesDuration) { @Override public Set execute(Jedis connection) { return connection.zrangeWithScores(key, start, stop); @@ -1114,7 +1152,7 @@ public Set execute(Jedis connection) { @Override public Set zrevrangeWithScores(final byte[] key, final long start, final long stop) { - return new JedisClusterCommand>(connectionHandler, maxAttempts) { + return new JedisClusterCommand>(connectionHandler, maxAttempts, maxTotalRetriesDuration) { @Override public Set execute(Jedis connection) { return connection.zrevrangeWithScores(key, start, stop); @@ -1124,7 +1162,7 @@ public Set execute(Jedis connection) { @Override public byte[] zrandmember(final byte[] key) { - return new JedisClusterCommand(connectionHandler, maxAttempts) { + return new JedisClusterCommand(connectionHandler, maxAttempts, maxTotalRetriesDuration) { @Override public byte[] execute(Jedis connection) { return connection.zrandmember(key); @@ -1134,7 +1172,7 @@ public byte[] execute(Jedis connection) { @Override public Set zrandmember(final byte[] key, final long count) { - return new JedisClusterCommand>(connectionHandler, maxAttempts) { + return new JedisClusterCommand>(connectionHandler, maxAttempts, maxTotalRetriesDuration) { @Override public Set execute(Jedis connection) { return connection.zrandmember(key, count); @@ -1144,7 +1182,7 @@ public Set execute(Jedis connection) { @Override public Set zrandmemberWithScores(final byte[] key, final long count) { - return new JedisClusterCommand>(connectionHandler, maxAttempts) { + return new JedisClusterCommand>(connectionHandler, maxAttempts, maxTotalRetriesDuration) { @Override public Set execute(Jedis connection) { return connection.zrandmemberWithScores(key, count); @@ -1154,7 +1192,7 @@ public Set execute(Jedis connection) { @Override public Long zcard(final byte[] key) { - return new JedisClusterCommand(connectionHandler, maxAttempts) { + return new JedisClusterCommand(connectionHandler, maxAttempts, maxTotalRetriesDuration) { @Override public Long execute(Jedis connection) { return connection.zcard(key); @@ -1164,7 +1202,7 @@ public Long execute(Jedis connection) { @Override public Double zscore(final byte[] key, final byte[] member) { - return new JedisClusterCommand(connectionHandler, maxAttempts) { + return new JedisClusterCommand(connectionHandler, maxAttempts, maxTotalRetriesDuration) { @Override public Double execute(Jedis connection) { return connection.zscore(key, member); @@ -1174,7 +1212,7 @@ public Double execute(Jedis connection) { @Override public List zmscore(final byte[] key, final byte[]... members) { - return new JedisClusterCommand>(connectionHandler, maxAttempts) { + return new JedisClusterCommand>(connectionHandler, maxAttempts, maxTotalRetriesDuration) { @Override public List execute(Jedis connection) { return connection.zmscore(key, members); @@ -1184,7 +1222,7 @@ public List execute(Jedis connection) { @Override public Tuple zpopmax(final byte[] key) { - return new JedisClusterCommand(connectionHandler, maxAttempts) { + return new JedisClusterCommand(connectionHandler, maxAttempts, maxTotalRetriesDuration) { @Override public Tuple execute(Jedis connection) { return connection.zpopmax(key); @@ -1194,7 +1232,7 @@ public Tuple execute(Jedis connection) { @Override public Set zpopmax(final byte[] key, final int count) { - return new JedisClusterCommand>(connectionHandler, maxAttempts) { + return new JedisClusterCommand>(connectionHandler, maxAttempts, maxTotalRetriesDuration) { @Override public Set execute(Jedis connection) { return connection.zpopmax(key, count); @@ -1204,7 +1242,7 @@ public Set execute(Jedis connection) { @Override public Tuple zpopmin(final byte[] key) { - return new JedisClusterCommand(connectionHandler, maxAttempts) { + return new JedisClusterCommand(connectionHandler, maxAttempts, maxTotalRetriesDuration) { @Override public Tuple execute(Jedis connection) { return connection.zpopmin(key); @@ -1214,7 +1252,7 @@ public Tuple execute(Jedis connection) { @Override public Set zpopmin(final byte[] key, final int count) { - return new JedisClusterCommand>(connectionHandler, maxAttempts) { + return new JedisClusterCommand>(connectionHandler, maxAttempts, maxTotalRetriesDuration) { @Override public Set execute(Jedis connection) { return connection.zpopmin(key, count); @@ -1224,7 +1262,7 @@ public Set execute(Jedis connection) { @Override public List sort(final byte[] key) { - return new JedisClusterCommand>(connectionHandler, maxAttempts) { + return new JedisClusterCommand>(connectionHandler, maxAttempts, maxTotalRetriesDuration) { @Override public List execute(Jedis connection) { return connection.sort(key); @@ -1234,7 +1272,7 @@ public List execute(Jedis connection) { @Override public List sort(final byte[] key, final SortingParams sortingParameters) { - return new JedisClusterCommand>(connectionHandler, maxAttempts) { + return new JedisClusterCommand>(connectionHandler, maxAttempts, maxTotalRetriesDuration) { @Override public List execute(Jedis connection) { return connection.sort(key, sortingParameters); @@ -1244,7 +1282,7 @@ public List execute(Jedis connection) { @Override public Long zcount(final byte[] key, final double min, final double max) { - return new JedisClusterCommand(connectionHandler, maxAttempts) { + return new JedisClusterCommand(connectionHandler, maxAttempts, maxTotalRetriesDuration) { @Override public Long execute(Jedis connection) { return connection.zcount(key, min, max); @@ -1254,7 +1292,7 @@ public Long execute(Jedis connection) { @Override public Long zcount(final byte[] key, final byte[] min, final byte[] max) { - return new JedisClusterCommand(connectionHandler, maxAttempts) { + return new JedisClusterCommand(connectionHandler, maxAttempts, maxTotalRetriesDuration) { @Override public Long execute(Jedis connection) { return connection.zcount(key, min, max); @@ -1264,7 +1302,7 @@ public Long execute(Jedis connection) { @Override public Set zrangeByScore(final byte[] key, final double min, final double max) { - return new JedisClusterCommand>(connectionHandler, maxAttempts) { + return new JedisClusterCommand>(connectionHandler, maxAttempts, maxTotalRetriesDuration) { @Override public Set execute(Jedis connection) { return connection.zrangeByScore(key, min, max); @@ -1274,7 +1312,7 @@ public Set execute(Jedis connection) { @Override public Set zrangeByScore(final byte[] key, final byte[] min, final byte[] max) { - return new JedisClusterCommand>(connectionHandler, maxAttempts) { + return new JedisClusterCommand>(connectionHandler, maxAttempts, maxTotalRetriesDuration) { @Override public Set execute(Jedis connection) { return connection.zrangeByScore(key, min, max); @@ -1284,7 +1322,7 @@ public Set execute(Jedis connection) { @Override public Set zrevrangeByScore(final byte[] key, final double max, final double min) { - return new JedisClusterCommand>(connectionHandler, maxAttempts) { + return new JedisClusterCommand>(connectionHandler, maxAttempts, maxTotalRetriesDuration) { @Override public Set execute(Jedis connection) { return connection.zrevrangeByScore(key, max, min); @@ -1295,7 +1333,7 @@ public Set execute(Jedis connection) { @Override public Set zrangeByScore(final byte[] key, final double min, final double max, final int offset, final int count) { - return new JedisClusterCommand>(connectionHandler, maxAttempts) { + return new JedisClusterCommand>(connectionHandler, maxAttempts, maxTotalRetriesDuration) { @Override public Set execute(Jedis connection) { return connection.zrangeByScore(key, min, max, offset, count); @@ -1305,7 +1343,7 @@ public Set execute(Jedis connection) { @Override public Set zrevrangeByScore(final byte[] key, final byte[] max, final byte[] min) { - return new JedisClusterCommand>(connectionHandler, maxAttempts) { + return new JedisClusterCommand>(connectionHandler, maxAttempts, maxTotalRetriesDuration) { @Override public Set execute(Jedis connection) { return connection.zrevrangeByScore(key, max, min); @@ -1316,7 +1354,7 @@ public Set execute(Jedis connection) { @Override public Set zrangeByScore(final byte[] key, final byte[] min, final byte[] max, final int offset, final int count) { - return new JedisClusterCommand>(connectionHandler, maxAttempts) { + return new JedisClusterCommand>(connectionHandler, maxAttempts, maxTotalRetriesDuration) { @Override public Set execute(Jedis connection) { return connection.zrangeByScore(key, min, max, offset, count); @@ -1327,7 +1365,7 @@ public Set execute(Jedis connection) { @Override public Set zrevrangeByScore(final byte[] key, final double max, final double min, final int offset, final int count) { - return new JedisClusterCommand>(connectionHandler, maxAttempts) { + return new JedisClusterCommand>(connectionHandler, maxAttempts, maxTotalRetriesDuration) { @Override public Set execute(Jedis connection) { return connection.zrevrangeByScore(key, max, min, offset, count); @@ -1337,7 +1375,7 @@ public Set execute(Jedis connection) { @Override public Set zrangeByScoreWithScores(final byte[] key, final double min, final double max) { - return new JedisClusterCommand>(connectionHandler, maxAttempts) { + return new JedisClusterCommand>(connectionHandler, maxAttempts, maxTotalRetriesDuration) { @Override public Set execute(Jedis connection) { return connection.zrangeByScoreWithScores(key, min, max); @@ -1347,7 +1385,7 @@ public Set execute(Jedis connection) { @Override public Set zrevrangeByScoreWithScores(final byte[] key, final double max, final double min) { - return new JedisClusterCommand>(connectionHandler, maxAttempts) { + return new JedisClusterCommand>(connectionHandler, maxAttempts, maxTotalRetriesDuration) { @Override public Set execute(Jedis connection) { return connection.zrevrangeByScoreWithScores(key, max, min); @@ -1358,7 +1396,7 @@ public Set execute(Jedis connection) { @Override public Set zrangeByScoreWithScores(final byte[] key, final double min, final double max, final int offset, final int count) { - return new JedisClusterCommand>(connectionHandler, maxAttempts) { + return new JedisClusterCommand>(connectionHandler, maxAttempts, maxTotalRetriesDuration) { @Override public Set execute(Jedis connection) { return connection.zrangeByScoreWithScores(key, min, max, offset, count); @@ -1369,7 +1407,7 @@ public Set execute(Jedis connection) { @Override public Set zrevrangeByScore(final byte[] key, final byte[] max, final byte[] min, final int offset, final int count) { - return new JedisClusterCommand>(connectionHandler, maxAttempts) { + return new JedisClusterCommand>(connectionHandler, maxAttempts, maxTotalRetriesDuration) { @Override public Set execute(Jedis connection) { return connection.zrevrangeByScore(key, max, min, offset, count); @@ -1379,7 +1417,7 @@ public Set execute(Jedis connection) { @Override public Set zrangeByScoreWithScores(final byte[] key, final byte[] min, final byte[] max) { - return new JedisClusterCommand>(connectionHandler, maxAttempts) { + return new JedisClusterCommand>(connectionHandler, maxAttempts, maxTotalRetriesDuration) { @Override public Set execute(Jedis connection) { return connection.zrangeByScoreWithScores(key, min, max); @@ -1389,7 +1427,7 @@ public Set execute(Jedis connection) { @Override public Set zrevrangeByScoreWithScores(final byte[] key, final byte[] max, final byte[] min) { - return new JedisClusterCommand>(connectionHandler, maxAttempts) { + return new JedisClusterCommand>(connectionHandler, maxAttempts, maxTotalRetriesDuration) { @Override public Set execute(Jedis connection) { return connection.zrevrangeByScoreWithScores(key, max, min); @@ -1400,7 +1438,7 @@ public Set execute(Jedis connection) { @Override public Set zrangeByScoreWithScores(final byte[] key, final byte[] min, final byte[] max, final int offset, final int count) { - return new JedisClusterCommand>(connectionHandler, maxAttempts) { + return new JedisClusterCommand>(connectionHandler, maxAttempts, maxTotalRetriesDuration) { @Override public Set execute(Jedis connection) { return connection.zrangeByScoreWithScores(key, min, max, offset, count); @@ -1411,7 +1449,7 @@ public Set execute(Jedis connection) { @Override public Set zrevrangeByScoreWithScores(final byte[] key, final double max, final double min, final int offset, final int count) { - return new JedisClusterCommand>(connectionHandler, maxAttempts) { + return new JedisClusterCommand>(connectionHandler, maxAttempts, maxTotalRetriesDuration) { @Override public Set execute(Jedis connection) { return connection.zrevrangeByScoreWithScores(key, max, min, offset, count); @@ -1422,7 +1460,7 @@ public Set execute(Jedis connection) { @Override public Set zrevrangeByScoreWithScores(final byte[] key, final byte[] max, final byte[] min, final int offset, final int count) { - return new JedisClusterCommand>(connectionHandler, maxAttempts) { + return new JedisClusterCommand>(connectionHandler, maxAttempts, maxTotalRetriesDuration) { @Override public Set execute(Jedis connection) { return connection.zrevrangeByScoreWithScores(key, max, min, offset, count); @@ -1432,7 +1470,7 @@ public Set execute(Jedis connection) { @Override public Long zremrangeByRank(final byte[] key, final long start, final long stop) { - return new JedisClusterCommand(connectionHandler, maxAttempts) { + return new JedisClusterCommand(connectionHandler, maxAttempts, maxTotalRetriesDuration) { @Override public Long execute(Jedis connection) { return connection.zremrangeByRank(key, start, stop); @@ -1442,7 +1480,7 @@ public Long execute(Jedis connection) { @Override public Long zremrangeByScore(final byte[] key, final double min, final double max) { - return new JedisClusterCommand(connectionHandler, maxAttempts) { + return new JedisClusterCommand(connectionHandler, maxAttempts, maxTotalRetriesDuration) { @Override public Long execute(Jedis connection) { return connection.zremrangeByScore(key, min, max); @@ -1452,7 +1490,7 @@ public Long execute(Jedis connection) { @Override public Long zremrangeByScore(final byte[] key, final byte[] min, final byte[] max) { - return new JedisClusterCommand(connectionHandler, maxAttempts) { + return new JedisClusterCommand(connectionHandler, maxAttempts, maxTotalRetriesDuration) { @Override public Long execute(Jedis connection) { return connection.zremrangeByScore(key, min, max); @@ -1463,7 +1501,7 @@ public Long execute(Jedis connection) { @Override public Long linsert(final byte[] key, final ListPosition where, final byte[] pivot, final byte[] value) { - return new JedisClusterCommand(connectionHandler, maxAttempts) { + return new JedisClusterCommand(connectionHandler, maxAttempts, maxTotalRetriesDuration) { @Override public Long execute(Jedis connection) { return connection.linsert(key, where, pivot, value); @@ -1473,7 +1511,7 @@ public Long execute(Jedis connection) { @Override public Long lpushx(final byte[] key, final byte[]... arg) { - return new JedisClusterCommand(connectionHandler, maxAttempts) { + return new JedisClusterCommand(connectionHandler, maxAttempts, maxTotalRetriesDuration) { @Override public Long execute(Jedis connection) { return connection.lpushx(key, arg); @@ -1483,7 +1521,7 @@ public Long execute(Jedis connection) { @Override public Long rpushx(final byte[] key, final byte[]... arg) { - return new JedisClusterCommand(connectionHandler, maxAttempts) { + return new JedisClusterCommand(connectionHandler, maxAttempts, maxTotalRetriesDuration) { @Override public Long execute(Jedis connection) { return connection.rpushx(key, arg); @@ -1493,7 +1531,7 @@ public Long execute(Jedis connection) { @Override public Long del(final byte[] key) { - return new JedisClusterCommand(connectionHandler, maxAttempts) { + return new JedisClusterCommand(connectionHandler, maxAttempts, maxTotalRetriesDuration) { @Override public Long execute(Jedis connection) { return connection.del(key); @@ -1503,7 +1541,7 @@ public Long execute(Jedis connection) { @Override public Long unlink(final byte[] key) { - return new JedisClusterCommand(connectionHandler, maxAttempts) { + return new JedisClusterCommand(connectionHandler, maxAttempts, maxTotalRetriesDuration) { @Override public Long execute(Jedis connection) { return connection.unlink(key); @@ -1513,7 +1551,7 @@ public Long execute(Jedis connection) { @Override public Long unlink(final byte[]... keys) { - return new JedisClusterCommand(connectionHandler, maxAttempts) { + return new JedisClusterCommand(connectionHandler, maxAttempts, maxTotalRetriesDuration) { @Override public Long execute(Jedis connection) { return connection.unlink(keys); @@ -1524,7 +1562,7 @@ public Long execute(Jedis connection) { @Override public byte[] echo(final byte[] arg) { // note that it'll be run from arbitary node - return new JedisClusterCommand(connectionHandler, maxAttempts) { + return new JedisClusterCommand(connectionHandler, maxAttempts, maxTotalRetriesDuration) { @Override public byte[] execute(Jedis connection) { return connection.echo(arg); @@ -1534,7 +1572,7 @@ public byte[] execute(Jedis connection) { @Override public Long bitcount(final byte[] key) { - return new JedisClusterCommand(connectionHandler, maxAttempts) { + return new JedisClusterCommand(connectionHandler, maxAttempts, maxTotalRetriesDuration) { @Override public Long execute(Jedis connection) { return connection.bitcount(key); @@ -1544,7 +1582,7 @@ public Long execute(Jedis connection) { @Override public Long bitcount(final byte[] key, final long start, final long end) { - return new JedisClusterCommand(connectionHandler, maxAttempts) { + return new JedisClusterCommand(connectionHandler, maxAttempts, maxTotalRetriesDuration) { @Override public Long execute(Jedis connection) { return connection.bitcount(key, start, end); @@ -1554,7 +1592,7 @@ public Long execute(Jedis connection) { @Override public Long pfadd(final byte[] key, final byte[]... elements) { - return new JedisClusterCommand(connectionHandler, maxAttempts) { + return new JedisClusterCommand(connectionHandler, maxAttempts, maxTotalRetriesDuration) { @Override public Long execute(Jedis connection) { return connection.pfadd(key, elements); @@ -1564,7 +1602,7 @@ public Long execute(Jedis connection) { @Override public long pfcount(final byte[] key) { - return new JedisClusterCommand(connectionHandler, maxAttempts) { + return new JedisClusterCommand(connectionHandler, maxAttempts, maxTotalRetriesDuration) { @Override public Long execute(Jedis connection) { return connection.pfcount(key); @@ -1574,7 +1612,7 @@ public Long execute(Jedis connection) { @Override public List srandmember(final byte[] key, final int count) { - return new JedisClusterCommand>(connectionHandler, maxAttempts) { + return new JedisClusterCommand>(connectionHandler, maxAttempts, maxTotalRetriesDuration) { @Override public List execute(Jedis connection) { return connection.srandmember(key, count); @@ -1584,7 +1622,7 @@ public List execute(Jedis connection) { @Override public Long zlexcount(final byte[] key, final byte[] min, final byte[] max) { - return new JedisClusterCommand(connectionHandler, maxAttempts) { + return new JedisClusterCommand(connectionHandler, maxAttempts, maxTotalRetriesDuration) { @Override public Long execute(Jedis connection) { return connection.zlexcount(key, min, max); @@ -1594,7 +1632,7 @@ public Long execute(Jedis connection) { @Override public Set zrangeByLex(final byte[] key, final byte[] min, final byte[] max) { - return new JedisClusterCommand>(connectionHandler, maxAttempts) { + return new JedisClusterCommand>(connectionHandler, maxAttempts, maxTotalRetriesDuration) { @Override public Set execute(Jedis connection) { return connection.zrangeByLex(key, min, max); @@ -1605,7 +1643,7 @@ public Set execute(Jedis connection) { @Override public Set zrangeByLex(final byte[] key, final byte[] min, final byte[] max, final int offset, final int count) { - return new JedisClusterCommand>(connectionHandler, maxAttempts) { + return new JedisClusterCommand>(connectionHandler, maxAttempts, maxTotalRetriesDuration) { @Override public Set execute(Jedis connection) { return connection.zrangeByLex(key, min, max, offset, count); @@ -1615,7 +1653,7 @@ public Set execute(Jedis connection) { @Override public Set zrevrangeByLex(final byte[] key, final byte[] max, final byte[] min) { - return new JedisClusterCommand>(connectionHandler, maxAttempts) { + return new JedisClusterCommand>(connectionHandler, maxAttempts, maxTotalRetriesDuration) { @Override public Set execute(Jedis connection) { return connection.zrevrangeByLex(key, max, min); @@ -1626,7 +1664,7 @@ public Set execute(Jedis connection) { @Override public Set zrevrangeByLex(final byte[] key, final byte[] max, final byte[] min, final int offset, final int count) { - return new JedisClusterCommand>(connectionHandler, maxAttempts) { + return new JedisClusterCommand>(connectionHandler, maxAttempts, maxTotalRetriesDuration) { @Override public Set execute(Jedis connection) { return connection.zrevrangeByLex(key, max, min, offset, count); @@ -1636,7 +1674,7 @@ public Set execute(Jedis connection) { @Override public Long zremrangeByLex(final byte[] key, final byte[] min, final byte[] max) { - return new JedisClusterCommand(connectionHandler, maxAttempts) { + return new JedisClusterCommand(connectionHandler, maxAttempts, maxTotalRetriesDuration) { @Override public Long execute(Jedis connection) { return connection.zremrangeByLex(key, min, max); @@ -1646,7 +1684,7 @@ public Long execute(Jedis connection) { @Override public Object eval(final byte[] script, final byte[] keyCount, final byte[]... params) { - return new JedisClusterCommand(connectionHandler, maxAttempts) { + return new JedisClusterCommand(connectionHandler, maxAttempts, maxTotalRetriesDuration) { @Override public Object execute(Jedis connection) { return connection.eval(script, keyCount, params); @@ -1656,7 +1694,7 @@ public Object execute(Jedis connection) { @Override public Object eval(final byte[] script, final int keyCount, final byte[]... params) { - return new JedisClusterCommand(connectionHandler, maxAttempts) { + return new JedisClusterCommand(connectionHandler, maxAttempts, maxTotalRetriesDuration) { @Override public Object execute(Jedis connection) { return connection.eval(script, keyCount, params); @@ -1666,7 +1704,7 @@ public Object execute(Jedis connection) { @Override public Object eval(final byte[] script, final List keys, final List args) { - return new JedisClusterCommand(connectionHandler, maxAttempts) { + return new JedisClusterCommand(connectionHandler, maxAttempts, maxTotalRetriesDuration) { @Override public Object execute(Jedis connection) { return connection.eval(script, keys, args); @@ -1676,7 +1714,7 @@ public Object execute(Jedis connection) { @Override public Object eval(final byte[] script, final byte[] sampleKey) { - return new JedisClusterCommand(connectionHandler, maxAttempts) { + return new JedisClusterCommand(connectionHandler, maxAttempts, maxTotalRetriesDuration) { @Override public Object execute(Jedis connection) { return connection.eval(script); @@ -1686,7 +1724,7 @@ public Object execute(Jedis connection) { @Override public Object evalsha(final byte[] sha1, final byte[] sampleKey) { - return new JedisClusterCommand(connectionHandler, maxAttempts) { + return new JedisClusterCommand(connectionHandler, maxAttempts, maxTotalRetriesDuration) { @Override public Object execute(Jedis connection) { return connection.evalsha(sha1); @@ -1696,7 +1734,7 @@ public Object execute(Jedis connection) { @Override public Object evalsha(final byte[] sha1, final List keys, final List args) { - return new JedisClusterCommand(connectionHandler, maxAttempts) { + return new JedisClusterCommand(connectionHandler, maxAttempts, maxTotalRetriesDuration) { @Override public Object execute(Jedis connection) { return connection.evalsha(sha1, keys, args); @@ -1706,7 +1744,7 @@ public Object execute(Jedis connection) { @Override public Object evalsha(final byte[] sha1, final int keyCount, final byte[]... params) { - return new JedisClusterCommand(connectionHandler, maxAttempts) { + return new JedisClusterCommand(connectionHandler, maxAttempts, maxTotalRetriesDuration) { @Override public Object execute(Jedis connection) { return connection.evalsha(sha1, keyCount, params); @@ -1716,7 +1754,7 @@ public Object execute(Jedis connection) { @Override public List scriptExists(final byte[] sampleKey, final byte[]... sha1) { - return new JedisClusterCommand>(connectionHandler, maxAttempts) { + return new JedisClusterCommand>(connectionHandler, maxAttempts, maxTotalRetriesDuration) { @Override public List execute(Jedis connection) { return connection.scriptExists(sha1); @@ -1726,7 +1764,7 @@ public List execute(Jedis connection) { @Override public byte[] scriptLoad(final byte[] script, final byte[] sampleKey) { - return new JedisClusterCommand(connectionHandler, maxAttempts) { + return new JedisClusterCommand(connectionHandler, maxAttempts, maxTotalRetriesDuration) { @Override public byte[] execute(Jedis connection) { return connection.scriptLoad(script); @@ -1736,7 +1774,7 @@ public byte[] execute(Jedis connection) { @Override public String scriptFlush(final byte[] sampleKey) { - return new JedisClusterCommand(connectionHandler, maxAttempts) { + return new JedisClusterCommand(connectionHandler, maxAttempts, maxTotalRetriesDuration) { @Override public String execute(Jedis connection) { return connection.scriptFlush(); @@ -1746,7 +1784,7 @@ public String execute(Jedis connection) { @Override public String scriptFlush(final byte[] sampleKey, final FlushMode flushMode) { - return new JedisClusterCommand(connectionHandler, maxAttempts) { + return new JedisClusterCommand(connectionHandler, maxAttempts, maxTotalRetriesDuration) { @Override public String execute(Jedis connection) { return connection.scriptFlush(flushMode); @@ -1756,7 +1794,7 @@ public String execute(Jedis connection) { @Override public String scriptKill(final byte[] sampleKey) { - return new JedisClusterCommand(connectionHandler, maxAttempts) { + return new JedisClusterCommand(connectionHandler, maxAttempts, maxTotalRetriesDuration) { @Override public String execute(Jedis connection) { return connection.scriptKill(); @@ -1766,7 +1804,7 @@ public String execute(Jedis connection) { @Override public Long del(final byte[]... keys) { - return new JedisClusterCommand(connectionHandler, maxAttempts) { + return new JedisClusterCommand(connectionHandler, maxAttempts, maxTotalRetriesDuration) { @Override public Long execute(Jedis connection) { return connection.del(keys); @@ -1777,7 +1815,7 @@ public Long execute(Jedis connection) { @Override public byte[] lmove(final byte[] srcKey, final byte[] dstKey, final ListDirection from, final ListDirection to) { - return new JedisClusterCommand(connectionHandler, maxAttempts) { + return new JedisClusterCommand(connectionHandler, maxAttempts, maxTotalRetriesDuration) { @Override public byte[] execute(Jedis connection) { return connection.lmove(srcKey, dstKey, from, to); @@ -1788,7 +1826,7 @@ public byte[] execute(Jedis connection) { @Override public byte[] blmove(final byte[] srcKey, final byte[] dstKey, final ListDirection from, final ListDirection to, final double timeout) { - return new JedisClusterCommand(connectionHandler, maxAttempts) { + return new JedisClusterCommand(connectionHandler, maxAttempts, maxTotalRetriesDuration) { @Override public byte[] execute(Jedis connection) { return connection.blmove(srcKey, dstKey, from, to, timeout); @@ -1798,7 +1836,7 @@ public byte[] execute(Jedis connection) { @Override public List blpop(final int timeout, final byte[]... keys) { - return new JedisClusterCommand>(connectionHandler, maxAttempts) { + return new JedisClusterCommand>(connectionHandler, maxAttempts, maxTotalRetriesDuration) { @Override public List execute(Jedis connection) { return connection.blpop(timeout, keys); @@ -1808,7 +1846,7 @@ public List execute(Jedis connection) { @Override public List blpop(final double timeout, final byte[]... keys) { - return new JedisClusterCommand>(connectionHandler, maxAttempts) { + return new JedisClusterCommand>(connectionHandler, maxAttempts, maxTotalRetriesDuration) { @Override public List execute(Jedis connection) { return connection.blpop(timeout, keys); @@ -1818,7 +1856,7 @@ public List execute(Jedis connection) { @Override public List brpop(final int timeout, final byte[]... keys) { - return new JedisClusterCommand>(connectionHandler, maxAttempts) { + return new JedisClusterCommand>(connectionHandler, maxAttempts, maxTotalRetriesDuration) { @Override public List execute(Jedis connection) { return connection.brpop(timeout, keys); @@ -1828,7 +1866,7 @@ public List execute(Jedis connection) { @Override public List brpop(final double timeout, final byte[]... keys) { - return new JedisClusterCommand>(connectionHandler, maxAttempts) { + return new JedisClusterCommand>(connectionHandler, maxAttempts, maxTotalRetriesDuration) { @Override public List execute(Jedis connection) { return connection.brpop(timeout, keys); @@ -1838,7 +1876,7 @@ public List execute(Jedis connection) { @Override public List bzpopmax(double timeout, byte[]... keys) { - return new JedisClusterCommand>(connectionHandler, maxAttempts) { + return new JedisClusterCommand>(connectionHandler, maxAttempts, maxTotalRetriesDuration) { @Override public List execute(Jedis connection) { return connection.bzpopmax(timeout, keys); @@ -1848,7 +1886,7 @@ public List execute(Jedis connection) { @Override public List bzpopmin(double timeout, byte[]... keys) { - return new JedisClusterCommand>(connectionHandler, maxAttempts) { + return new JedisClusterCommand>(connectionHandler, maxAttempts, maxTotalRetriesDuration) { @Override public List execute(Jedis connection) { return connection.bzpopmin(timeout, keys); @@ -1858,7 +1896,7 @@ public List execute(Jedis connection) { @Override public List mget(final byte[]... keys) { - return new JedisClusterCommand>(connectionHandler, maxAttempts) { + return new JedisClusterCommand>(connectionHandler, maxAttempts, maxTotalRetriesDuration) { @Override public List execute(Jedis connection) { return connection.mget(keys); @@ -1874,7 +1912,7 @@ public String mset(final byte[]... keysvalues) { keys[keyIdx] = keysvalues[keyIdx * 2]; } - return new JedisClusterCommand(connectionHandler, maxAttempts) { + return new JedisClusterCommand(connectionHandler, maxAttempts, maxTotalRetriesDuration) { @Override public String execute(Jedis connection) { return connection.mset(keysvalues); @@ -1890,7 +1928,7 @@ public Long msetnx(final byte[]... keysvalues) { keys[keyIdx] = keysvalues[keyIdx * 2]; } - return new JedisClusterCommand(connectionHandler, maxAttempts) { + return new JedisClusterCommand(connectionHandler, maxAttempts, maxTotalRetriesDuration) { @Override public Long execute(Jedis connection) { return connection.msetnx(keysvalues); @@ -1900,7 +1938,7 @@ public Long execute(Jedis connection) { @Override public String rename(final byte[] oldkey, final byte[] newkey) { - return new JedisClusterCommand(connectionHandler, maxAttempts) { + return new JedisClusterCommand(connectionHandler, maxAttempts, maxTotalRetriesDuration) { @Override public String execute(Jedis connection) { return connection.rename(oldkey, newkey); @@ -1910,7 +1948,7 @@ public String execute(Jedis connection) { @Override public Long renamenx(final byte[] oldkey, final byte[] newkey) { - return new JedisClusterCommand(connectionHandler, maxAttempts) { + return new JedisClusterCommand(connectionHandler, maxAttempts, maxTotalRetriesDuration) { @Override public Long execute(Jedis connection) { return connection.renamenx(oldkey, newkey); @@ -1920,7 +1958,7 @@ public Long execute(Jedis connection) { @Override public byte[] rpoplpush(final byte[] srckey, final byte[] dstkey) { - return new JedisClusterCommand(connectionHandler, maxAttempts) { + return new JedisClusterCommand(connectionHandler, maxAttempts, maxTotalRetriesDuration) { @Override public byte[] execute(Jedis connection) { return connection.rpoplpush(srckey, dstkey); @@ -1930,7 +1968,7 @@ public byte[] execute(Jedis connection) { @Override public Set sdiff(final byte[]... keys) { - return new JedisClusterCommand>(connectionHandler, maxAttempts) { + return new JedisClusterCommand>(connectionHandler, maxAttempts, maxTotalRetriesDuration) { @Override public Set execute(Jedis connection) { return connection.sdiff(keys); @@ -1942,7 +1980,7 @@ public Set execute(Jedis connection) { public Long sdiffstore(final byte[] dstkey, final byte[]... keys) { byte[][] wholeKeys = KeyMergeUtil.merge(dstkey, keys); - return new JedisClusterCommand(connectionHandler, maxAttempts) { + return new JedisClusterCommand(connectionHandler, maxAttempts, maxTotalRetriesDuration) { @Override public Long execute(Jedis connection) { return connection.sdiffstore(dstkey, keys); @@ -1952,7 +1990,7 @@ public Long execute(Jedis connection) { @Override public Set sinter(final byte[]... keys) { - return new JedisClusterCommand>(connectionHandler, maxAttempts) { + return new JedisClusterCommand>(connectionHandler, maxAttempts, maxTotalRetriesDuration) { @Override public Set execute(Jedis connection) { return connection.sinter(keys); @@ -1964,7 +2002,7 @@ public Set execute(Jedis connection) { public Long sinterstore(final byte[] dstkey, final byte[]... keys) { byte[][] wholeKeys = KeyMergeUtil.merge(dstkey, keys); - return new JedisClusterCommand(connectionHandler, maxAttempts) { + return new JedisClusterCommand(connectionHandler, maxAttempts, maxTotalRetriesDuration) { @Override public Long execute(Jedis connection) { return connection.sinterstore(dstkey, keys); @@ -1974,7 +2012,7 @@ public Long execute(Jedis connection) { @Override public Long smove(final byte[] srckey, final byte[] dstkey, final byte[] member) { - return new JedisClusterCommand(connectionHandler, maxAttempts) { + return new JedisClusterCommand(connectionHandler, maxAttempts, maxTotalRetriesDuration) { @Override public Long execute(Jedis connection) { return connection.smove(srckey, dstkey, member); @@ -1984,7 +2022,7 @@ public Long execute(Jedis connection) { @Override public Long sort(final byte[] key, final SortingParams sortingParameters, final byte[] dstkey) { - return new JedisClusterCommand(connectionHandler, maxAttempts) { + return new JedisClusterCommand(connectionHandler, maxAttempts, maxTotalRetriesDuration) { @Override public Long execute(Jedis connection) { return connection.sort(key, sortingParameters, dstkey); @@ -1994,7 +2032,7 @@ public Long execute(Jedis connection) { @Override public Long sort(final byte[] key, final byte[] dstkey) { - return new JedisClusterCommand(connectionHandler, maxAttempts) { + return new JedisClusterCommand(connectionHandler, maxAttempts, maxTotalRetriesDuration) { @Override public Long execute(Jedis connection) { return connection.sort(key, dstkey); @@ -2004,7 +2042,7 @@ public Long execute(Jedis connection) { @Override public Set sunion(final byte[]... keys) { - return new JedisClusterCommand>(connectionHandler, maxAttempts) { + return new JedisClusterCommand>(connectionHandler, maxAttempts, maxTotalRetriesDuration) { @Override public Set execute(Jedis connection) { return connection.sunion(keys); @@ -2016,7 +2054,7 @@ public Set execute(Jedis connection) { public Long sunionstore(final byte[] dstkey, final byte[]... keys) { byte[][] wholeKeys = KeyMergeUtil.merge(dstkey, keys); - return new JedisClusterCommand(connectionHandler, maxAttempts) { + return new JedisClusterCommand(connectionHandler, maxAttempts, maxTotalRetriesDuration) { @Override public Long execute(Jedis connection) { return connection.sunionstore(dstkey, keys); @@ -2026,7 +2064,7 @@ public Long execute(Jedis connection) { @Override public Set zinter(final ZParams params, final byte[]... keys) { - return new JedisClusterCommand>(connectionHandler, maxAttempts) { + return new JedisClusterCommand>(connectionHandler, maxAttempts, maxTotalRetriesDuration) { @Override public Set execute(Jedis connection) { return connection.zinter(params, keys); @@ -2036,7 +2074,7 @@ public Set execute(Jedis connection) { @Override public Set zinterWithScores(final ZParams params, final byte[]... keys) { - return new JedisClusterCommand>(connectionHandler, maxAttempts) { + return new JedisClusterCommand>(connectionHandler, maxAttempts, maxTotalRetriesDuration) { @Override public Set execute(Jedis connection) { return connection.zinterWithScores(params, keys); @@ -2048,7 +2086,7 @@ public Set execute(Jedis connection) { public Long zinterstore(final byte[] dstkey, final byte[]... sets) { byte[][] wholeKeys = KeyMergeUtil.merge(dstkey, sets); - return new JedisClusterCommand(connectionHandler, maxAttempts) { + return new JedisClusterCommand(connectionHandler, maxAttempts, maxTotalRetriesDuration) { @Override public Long execute(Jedis connection) { return connection.zinterstore(dstkey, sets); @@ -2060,7 +2098,7 @@ public Long execute(Jedis connection) { public Long zinterstore(final byte[] dstkey, final ZParams params, final byte[]... sets) { byte[][] wholeKeys = KeyMergeUtil.merge(dstkey, sets); - return new JedisClusterCommand(connectionHandler, maxAttempts) { + return new JedisClusterCommand(connectionHandler, maxAttempts, maxTotalRetriesDuration) { @Override public Long execute(Jedis connection) { return connection.zinterstore(dstkey, params, sets); @@ -2070,7 +2108,7 @@ public Long execute(Jedis connection) { @Override public Set zunion(final ZParams params, final byte[]... keys) { - return new JedisClusterCommand>(connectionHandler, maxAttempts) { + return new JedisClusterCommand>(connectionHandler, maxAttempts, maxTotalRetriesDuration) { @Override public Set execute(Jedis connection) { return connection.zunion(params, keys); @@ -2080,7 +2118,7 @@ public Set execute(Jedis connection) { @Override public Set zunionWithScores(final ZParams params, final byte[]... keys) { - return new JedisClusterCommand>(connectionHandler, maxAttempts) { + return new JedisClusterCommand>(connectionHandler, maxAttempts, maxTotalRetriesDuration) { @Override public Set execute(Jedis connection) { return connection.zunionWithScores(params, keys); @@ -2092,7 +2130,7 @@ public Set execute(Jedis connection) { public Long zunionstore(final byte[] dstkey, final byte[]... sets) { byte[][] wholeKeys = KeyMergeUtil.merge(dstkey, sets); - return new JedisClusterCommand(connectionHandler, maxAttempts) { + return new JedisClusterCommand(connectionHandler, maxAttempts, maxTotalRetriesDuration) { @Override public Long execute(Jedis connection) { return connection.zunionstore(dstkey, sets); @@ -2104,7 +2142,7 @@ public Long execute(Jedis connection) { public Long zunionstore(final byte[] dstkey, final ZParams params, final byte[]... sets) { byte[][] wholeKeys = KeyMergeUtil.merge(dstkey, sets); - return new JedisClusterCommand(connectionHandler, maxAttempts) { + return new JedisClusterCommand(connectionHandler, maxAttempts, maxTotalRetriesDuration) { @Override public Long execute(Jedis connection) { return connection.zunionstore(dstkey, params, sets); @@ -2114,7 +2152,7 @@ public Long execute(Jedis connection) { @Override public byte[] brpoplpush(final byte[] source, final byte[] destination, final int timeout) { - return new JedisClusterCommand(connectionHandler, maxAttempts) { + return new JedisClusterCommand(connectionHandler, maxAttempts, maxTotalRetriesDuration) { @Override public byte[] execute(Jedis connection) { return connection.brpoplpush(source, destination, timeout); @@ -2124,7 +2162,7 @@ public byte[] execute(Jedis connection) { @Override public Long publish(final byte[] channel, final byte[] message) { - return new JedisClusterCommand(connectionHandler, maxAttempts) { + return new JedisClusterCommand(connectionHandler, maxAttempts, maxTotalRetriesDuration) { @Override public Long execute(Jedis connection) { return connection.publish(channel, message); @@ -2134,7 +2172,7 @@ public Long execute(Jedis connection) { @Override public void subscribe(final BinaryJedisPubSub jedisPubSub, final byte[]... channels) { - new JedisClusterCommand(connectionHandler, maxAttempts) { + new JedisClusterCommand(connectionHandler, maxAttempts, maxTotalRetriesDuration) { @Override public Integer execute(Jedis connection) { connection.subscribe(jedisPubSub, channels); @@ -2145,7 +2183,7 @@ public Integer execute(Jedis connection) { @Override public void psubscribe(final BinaryJedisPubSub jedisPubSub, final byte[]... patterns) { - new JedisClusterCommand(connectionHandler, maxAttempts) { + new JedisClusterCommand(connectionHandler, maxAttempts, maxTotalRetriesDuration) { @Override public Integer execute(Jedis connection) { connection.psubscribe(jedisPubSub, patterns); @@ -2158,7 +2196,7 @@ public Integer execute(Jedis connection) { public Long bitop(final BitOP op, final byte[] destKey, final byte[]... srcKeys) { byte[][] wholeKeys = KeyMergeUtil.merge(destKey, srcKeys); - return new JedisClusterCommand(connectionHandler, maxAttempts) { + return new JedisClusterCommand(connectionHandler, maxAttempts, maxTotalRetriesDuration) { @Override public Long execute(Jedis connection) { return connection.bitop(op, destKey, srcKeys); @@ -2170,7 +2208,7 @@ public Long execute(Jedis connection) { public String pfmerge(final byte[] destkey, final byte[]... sourcekeys) { byte[][] wholeKeys = KeyMergeUtil.merge(destkey, sourcekeys); - return new JedisClusterCommand(connectionHandler, maxAttempts) { + return new JedisClusterCommand(connectionHandler, maxAttempts, maxTotalRetriesDuration) { @Override public String execute(Jedis connection) { return connection.pfmerge(destkey, sourcekeys); @@ -2180,7 +2218,7 @@ public String execute(Jedis connection) { @Override public Long pfcount(final byte[]... keys) { - return new JedisClusterCommand(connectionHandler, maxAttempts) { + return new JedisClusterCommand(connectionHandler, maxAttempts, maxTotalRetriesDuration) { @Override public Long execute(Jedis connection) { return connection.pfcount(keys); @@ -2191,7 +2229,7 @@ public Long execute(Jedis connection) { @Override public Long geoadd(final byte[] key, final double longitude, final double latitude, final byte[] member) { - return new JedisClusterCommand(connectionHandler, maxAttempts) { + return new JedisClusterCommand(connectionHandler, maxAttempts, maxTotalRetriesDuration) { @Override public Long execute(Jedis connection) { return connection.geoadd(key, longitude, latitude, member); @@ -2201,7 +2239,7 @@ public Long execute(Jedis connection) { @Override public Long geoadd(final byte[] key, final Map memberCoordinateMap) { - return new JedisClusterCommand(connectionHandler, maxAttempts) { + return new JedisClusterCommand(connectionHandler, maxAttempts, maxTotalRetriesDuration) { @Override public Long execute(Jedis connection) { return connection.geoadd(key, memberCoordinateMap); @@ -2211,7 +2249,7 @@ public Long execute(Jedis connection) { @Override public Long geoadd(byte[] key, GeoAddParams params, Map memberCoordinateMap) { - return new JedisClusterCommand(connectionHandler, maxAttempts) { + return new JedisClusterCommand(connectionHandler, maxAttempts, maxTotalRetriesDuration) { @Override public Long execute(Jedis connection) { return connection.geoadd(key, params, memberCoordinateMap); @@ -2221,7 +2259,7 @@ public Long execute(Jedis connection) { @Override public Double geodist(final byte[] key, final byte[] member1, final byte[] member2) { - return new JedisClusterCommand(connectionHandler, maxAttempts) { + return new JedisClusterCommand(connectionHandler, maxAttempts, maxTotalRetriesDuration) { @Override public Double execute(Jedis connection) { return connection.geodist(key, member1, member2); @@ -2232,7 +2270,7 @@ public Double execute(Jedis connection) { @Override public Double geodist(final byte[] key, final byte[] member1, final byte[] member2, final GeoUnit unit) { - return new JedisClusterCommand(connectionHandler, maxAttempts) { + return new JedisClusterCommand(connectionHandler, maxAttempts, maxTotalRetriesDuration) { @Override public Double execute(Jedis connection) { return connection.geodist(key, member1, member2, unit); @@ -2242,7 +2280,7 @@ public Double execute(Jedis connection) { @Override public List geohash(final byte[] key, final byte[]... members) { - return new JedisClusterCommand>(connectionHandler, maxAttempts) { + return new JedisClusterCommand>(connectionHandler, maxAttempts, maxTotalRetriesDuration) { @Override public List execute(Jedis connection) { return connection.geohash(key, members); @@ -2252,7 +2290,7 @@ public List execute(Jedis connection) { @Override public List geopos(final byte[] key, final byte[]... members) { - return new JedisClusterCommand>(connectionHandler, maxAttempts) { + return new JedisClusterCommand>(connectionHandler, maxAttempts, maxTotalRetriesDuration) { @Override public List execute(Jedis connection) { return connection.geopos(key, members); @@ -2263,7 +2301,7 @@ public List execute(Jedis connection) { @Override public List georadius(final byte[] key, final double longitude, final double latitude, final double radius, final GeoUnit unit) { - return new JedisClusterCommand>(connectionHandler, maxAttempts) { + return new JedisClusterCommand>(connectionHandler, maxAttempts, maxTotalRetriesDuration) { @Override public List execute(Jedis connection) { return connection.georadius(key, longitude, latitude, radius, unit); @@ -2274,7 +2312,7 @@ public List execute(Jedis connection) { @Override public List georadiusReadonly(final byte[] key, final double longitude, final double latitude, final double radius, final GeoUnit unit) { - return new JedisClusterCommand>(connectionHandler, maxAttempts) { + return new JedisClusterCommand>(connectionHandler, maxAttempts, maxTotalRetriesDuration) { @Override public List execute(Jedis connection) { return connection.georadiusReadonly(key, longitude, latitude, radius, unit); @@ -2285,7 +2323,7 @@ public List execute(Jedis connection) { @Override public List georadius(final byte[] key, final double longitude, final double latitude, final double radius, final GeoUnit unit, final GeoRadiusParam param) { - return new JedisClusterCommand>(connectionHandler, maxAttempts) { + return new JedisClusterCommand>(connectionHandler, maxAttempts, maxTotalRetriesDuration) { @Override public List execute(Jedis connection) { return connection.georadius(key, longitude, latitude, radius, unit, param); @@ -2298,7 +2336,7 @@ public Long georadiusStore(final byte[] key, final double longitude, final doubl final double radius, final GeoUnit unit, final GeoRadiusParam param, final GeoRadiusStoreParam storeParam) { byte[][] keys = storeParam.getByteKeys(key); - return new JedisClusterCommand(connectionHandler, maxAttempts) { + return new JedisClusterCommand(connectionHandler, maxAttempts, maxTotalRetriesDuration) { @Override public Long execute(Jedis connection) { return connection.georadiusStore(key, longitude, latitude, radius, unit, param, storeParam); @@ -2309,7 +2347,7 @@ public Long execute(Jedis connection) { @Override public List georadiusReadonly(final byte[] key, final double longitude, final double latitude, final double radius, final GeoUnit unit, final GeoRadiusParam param) { - return new JedisClusterCommand>(connectionHandler, maxAttempts) { + return new JedisClusterCommand>(connectionHandler, maxAttempts, maxTotalRetriesDuration) { @Override public List execute(Jedis connection) { return connection.georadiusReadonly(key, longitude, latitude, radius, unit, param); @@ -2320,7 +2358,7 @@ public List execute(Jedis connection) { @Override public List georadiusByMember(final byte[] key, final byte[] member, final double radius, final GeoUnit unit) { - return new JedisClusterCommand>(connectionHandler, maxAttempts) { + return new JedisClusterCommand>(connectionHandler, maxAttempts, maxTotalRetriesDuration) { @Override public List execute(Jedis connection) { return connection.georadiusByMember(key, member, radius, unit); @@ -2331,7 +2369,7 @@ public List execute(Jedis connection) { @Override public List georadiusByMemberReadonly(final byte[] key, final byte[] member, final double radius, final GeoUnit unit) { - return new JedisClusterCommand>(connectionHandler, maxAttempts) { + return new JedisClusterCommand>(connectionHandler, maxAttempts, maxTotalRetriesDuration) { @Override public List execute(Jedis connection) { return connection.georadiusByMemberReadonly(key, member, radius, unit); @@ -2342,7 +2380,7 @@ public List execute(Jedis connection) { @Override public List georadiusByMember(final byte[] key, final byte[] member, final double radius, final GeoUnit unit, final GeoRadiusParam param) { - return new JedisClusterCommand>(connectionHandler, maxAttempts) { + return new JedisClusterCommand>(connectionHandler, maxAttempts, maxTotalRetriesDuration) { @Override public List execute(Jedis connection) { return connection.georadiusByMember(key, member, radius, unit, param); @@ -2354,7 +2392,7 @@ public List execute(Jedis connection) { public Long georadiusByMemberStore(final byte[] key, final byte[] member, final double radius, final GeoUnit unit, final GeoRadiusParam param, final GeoRadiusStoreParam storeParam) { byte[][] keys = storeParam.getByteKeys(key); - return new JedisClusterCommand(connectionHandler, maxAttempts) { + return new JedisClusterCommand(connectionHandler, maxAttempts, maxTotalRetriesDuration) { @Override public Long execute(Jedis connection) { return connection.georadiusByMemberStore(key, member, radius, unit, param, storeParam); @@ -2365,7 +2403,7 @@ public Long execute(Jedis connection) { @Override public List georadiusByMemberReadonly(final byte[] key, final byte[] member, final double radius, final GeoUnit unit, final GeoRadiusParam param) { - return new JedisClusterCommand>(connectionHandler, maxAttempts) { + return new JedisClusterCommand>(connectionHandler, maxAttempts, maxTotalRetriesDuration) { @Override public List execute(Jedis connection) { return connection.georadiusByMemberReadonly(key, member, radius, unit, param); @@ -2385,7 +2423,7 @@ public Set keys(final byte[] pattern) { + " only supports KEYS commands with patterns containing hash-tags " + "( curly-brackets enclosed strings )"); } - return new JedisClusterCommand>(connectionHandler, maxAttempts) { + return new JedisClusterCommand>(connectionHandler, maxAttempts, maxTotalRetriesDuration) { @Override public Set execute(Jedis connection) { return connection.keys(pattern); @@ -2410,7 +2448,8 @@ public ScanResult scan(final byte[] cursor, final ScanParams params) { + " ( curly-brackets enclosed strings )"); } - return new JedisClusterCommand>(connectionHandler, maxAttempts) { + return new JedisClusterCommand>(connectionHandler, maxAttempts, + maxTotalRetriesDuration) { @Override public ScanResult execute(Jedis connection) { return connection.scan(cursor, params); @@ -2421,7 +2460,7 @@ public ScanResult execute(Jedis connection) { @Override public ScanResult> hscan(final byte[] key, final byte[] cursor) { return new JedisClusterCommand>>(connectionHandler, - maxAttempts) { + maxAttempts, maxTotalRetriesDuration) { @Override public ScanResult> execute(Jedis connection) { return connection.hscan(key, cursor); @@ -2433,7 +2472,7 @@ public ScanResult> execute(Jedis connection) { public ScanResult> hscan(final byte[] key, final byte[] cursor, final ScanParams params) { return new JedisClusterCommand>>(connectionHandler, - maxAttempts) { + maxAttempts, maxTotalRetriesDuration) { @Override public ScanResult> execute(Jedis connection) { return connection.hscan(key, cursor, params); @@ -2443,7 +2482,7 @@ public ScanResult> execute(Jedis connection) { @Override public ScanResult sscan(final byte[] key, final byte[] cursor) { - return new JedisClusterCommand>(connectionHandler, maxAttempts) { + return new JedisClusterCommand>(connectionHandler, maxAttempts, maxTotalRetriesDuration) { @Override public ScanResult execute(Jedis connection) { return connection.sscan(key, cursor); @@ -2453,7 +2492,7 @@ public ScanResult execute(Jedis connection) { @Override public ScanResult sscan(final byte[] key, final byte[] cursor, final ScanParams params) { - return new JedisClusterCommand>(connectionHandler, maxAttempts) { + return new JedisClusterCommand>(connectionHandler, maxAttempts, maxTotalRetriesDuration) { @Override public ScanResult execute(Jedis connection) { return connection.sscan(key, cursor, params); @@ -2463,7 +2502,7 @@ public ScanResult execute(Jedis connection) { @Override public ScanResult zscan(final byte[] key, final byte[] cursor) { - return new JedisClusterCommand>(connectionHandler, maxAttempts) { + return new JedisClusterCommand>(connectionHandler, maxAttempts, maxTotalRetriesDuration) { @Override public ScanResult execute(Jedis connection) { return connection.zscan(key, cursor); @@ -2473,7 +2512,7 @@ public ScanResult execute(Jedis connection) { @Override public ScanResult zscan(final byte[] key, final byte[] cursor, final ScanParams params) { - return new JedisClusterCommand>(connectionHandler, maxAttempts) { + return new JedisClusterCommand>(connectionHandler, maxAttempts, maxTotalRetriesDuration) { @Override public ScanResult execute(Jedis connection) { return connection.zscan(key, cursor, params); @@ -2483,7 +2522,7 @@ public ScanResult execute(Jedis connection) { @Override public List bitfield(final byte[] key, final byte[]... arguments) { - return new JedisClusterCommand>(connectionHandler, maxAttempts) { + return new JedisClusterCommand>(connectionHandler, maxAttempts, maxTotalRetriesDuration) { @Override public List execute(Jedis connection) { return connection.bitfield(key, arguments); @@ -2493,7 +2532,7 @@ public List execute(Jedis connection) { @Override public List bitfieldReadonly(final byte[] key, final byte[]... arguments) { - return new JedisClusterCommand>(connectionHandler, maxAttempts) { + return new JedisClusterCommand>(connectionHandler, maxAttempts, maxTotalRetriesDuration) { @Override public List execute(Jedis connection) { return connection.bitfieldReadonly(key, arguments); @@ -2503,7 +2542,7 @@ public List execute(Jedis connection) { @Override public Long hstrlen(final byte[] key, final byte[] field) { - return new JedisClusterCommand(connectionHandler, maxAttempts) { + return new JedisClusterCommand(connectionHandler, maxAttempts, maxTotalRetriesDuration) { @Override public Long execute(Jedis connection) { return connection.hstrlen(key, field); @@ -2513,7 +2552,7 @@ public Long execute(Jedis connection) { @Override public Long memoryUsage(final byte[] key) { - return new JedisClusterCommand(connectionHandler, maxAttempts) { + return new JedisClusterCommand(connectionHandler, maxAttempts, maxTotalRetriesDuration) { @Override public Long execute(Jedis connection) { return connection.memoryUsage(key); @@ -2523,7 +2562,7 @@ public Long execute(Jedis connection) { @Override public Long memoryUsage(final byte[] key, final int samples) { - return new JedisClusterCommand(connectionHandler, maxAttempts) { + return new JedisClusterCommand(connectionHandler, maxAttempts, maxTotalRetriesDuration) { @Override public Long execute(Jedis connection) { return connection.memoryUsage(key, samples); @@ -2534,7 +2573,7 @@ public Long execute(Jedis connection) { @Override public byte[] xadd(final byte[] key, final byte[] id, final Map hash, final long maxLen, final boolean approximateLength) { - return new JedisClusterCommand(connectionHandler, maxAttempts) { + return new JedisClusterCommand(connectionHandler, maxAttempts, maxTotalRetriesDuration) { @Override public byte[] execute(Jedis connection) { return connection.xadd(key, id, hash, maxLen, approximateLength); @@ -2544,7 +2583,7 @@ public byte[] execute(Jedis connection) { @Override public byte[] xadd(final byte[] key, final Map hash, final XAddParams params) { - return new JedisClusterCommand(connectionHandler, maxAttempts) { + return new JedisClusterCommand(connectionHandler, maxAttempts, maxTotalRetriesDuration) { @Override public byte[] execute(Jedis connection) { return connection.xadd(key, hash, params); @@ -2554,7 +2593,7 @@ public byte[] execute(Jedis connection) { @Override public Long xlen(final byte[] key) { - return new JedisClusterCommand(connectionHandler, maxAttempts) { + return new JedisClusterCommand(connectionHandler, maxAttempts, maxTotalRetriesDuration) { @Override public Long execute(Jedis connection) { return connection.xlen(key); @@ -2564,7 +2603,7 @@ public Long execute(Jedis connection) { @Override public List xrange(final byte[] key, final byte[] start, final byte[] end) { - return new JedisClusterCommand>(connectionHandler, maxAttempts) { + return new JedisClusterCommand>(connectionHandler, maxAttempts, maxTotalRetriesDuration) { @Override public List execute(Jedis connection) { return connection.xrange(key, start, end); @@ -2575,7 +2614,7 @@ public List execute(Jedis connection) { @Override public List xrange(final byte[] key, final byte[] start, final byte[] end, final long count) { - return new JedisClusterCommand>(connectionHandler, maxAttempts) { + return new JedisClusterCommand>(connectionHandler, maxAttempts, maxTotalRetriesDuration) { @Override public List execute(Jedis connection) { return connection.xrange(key, start, end, count); @@ -2585,7 +2624,7 @@ public List execute(Jedis connection) { @Override public List xrange(final byte[] key, final byte[] start, final byte[] end, final int count) { - return new JedisClusterCommand>(connectionHandler, maxAttempts) { + return new JedisClusterCommand>(connectionHandler, maxAttempts, maxTotalRetriesDuration) { @Override public List execute(Jedis connection) { return connection.xrange(key, start, end, count); @@ -2595,7 +2634,7 @@ public List execute(Jedis connection) { @Override public List xrevrange(final byte[] key, final byte[] end, final byte[] start) { - return new JedisClusterCommand>(connectionHandler, maxAttempts) { + return new JedisClusterCommand>(connectionHandler, maxAttempts, maxTotalRetriesDuration) { @Override public List execute(Jedis connection) { return connection.xrevrange(key, end, start); @@ -2606,7 +2645,7 @@ public List execute(Jedis connection) { @Override public List xrevrange(final byte[] key, final byte[] end, final byte[] start, final int count) { - return new JedisClusterCommand>(connectionHandler, maxAttempts) { + return new JedisClusterCommand>(connectionHandler, maxAttempts, maxTotalRetriesDuration) { @Override public List execute(Jedis connection) { return connection.xrevrange(key, end, start, count); @@ -2618,7 +2657,7 @@ public List execute(Jedis connection) { public List xread(final int count, final long block, final Map streams) { byte[][] keys = streams.keySet().toArray(new byte[streams.size()][]); - return new JedisClusterCommand>(connectionHandler, maxAttempts) { + return new JedisClusterCommand>(connectionHandler, maxAttempts, maxTotalRetriesDuration) { @Override public List execute(Jedis connection) { return connection.xread(count, block, streams); @@ -2628,7 +2667,7 @@ public List execute(Jedis connection) { @Override public List xread(final XReadParams xReadParams, final Entry... streams) { - return new JedisClusterCommand>(connectionHandler, maxAttempts) { + return new JedisClusterCommand>(connectionHandler, maxAttempts, maxTotalRetriesDuration) { @Override public List execute(Jedis connection) { return connection.xread(xReadParams, streams); @@ -2638,7 +2677,7 @@ public List execute(Jedis connection) { @Override public Long xack(final byte[] key, final byte[] group, final byte[]... ids) { - return new JedisClusterCommand(connectionHandler, maxAttempts) { + return new JedisClusterCommand(connectionHandler, maxAttempts, maxTotalRetriesDuration) { @Override public Long execute(Jedis connection) { return connection.xack(key, group, ids); @@ -2649,7 +2688,7 @@ public Long execute(Jedis connection) { @Override public String xgroupCreate(final byte[] key, final byte[] consumer, final byte[] id, final boolean makeStream) { - return new JedisClusterCommand(connectionHandler, maxAttempts) { + return new JedisClusterCommand(connectionHandler, maxAttempts, maxTotalRetriesDuration) { @Override public String execute(Jedis connection) { return connection.xgroupCreate(key, consumer, id, makeStream); @@ -2659,7 +2698,7 @@ public String execute(Jedis connection) { @Override public String xgroupSetID(final byte[] key, final byte[] consumer, final byte[] id) { - return new JedisClusterCommand(connectionHandler, maxAttempts) { + return new JedisClusterCommand(connectionHandler, maxAttempts, maxTotalRetriesDuration) { @Override public String execute(Jedis connection) { return connection.xgroupSetID(key, consumer, id); @@ -2669,7 +2708,7 @@ public String execute(Jedis connection) { @Override public Long xgroupDestroy(final byte[] key, final byte[] consumer) { - return new JedisClusterCommand(connectionHandler, maxAttempts) { + return new JedisClusterCommand(connectionHandler, maxAttempts, maxTotalRetriesDuration) { @Override public Long execute(Jedis connection) { return connection.xgroupDestroy(key, consumer); @@ -2679,7 +2718,7 @@ public Long execute(Jedis connection) { @Override public Long xgroupDelConsumer(final byte[] key, final byte[] consumer, final byte[] consumerName) { - return new JedisClusterCommand(connectionHandler, maxAttempts) { + return new JedisClusterCommand(connectionHandler, maxAttempts, maxTotalRetriesDuration) { @Override public Long execute(Jedis connection) { return connection.xgroupDelConsumer(key, consumer, consumerName); @@ -2693,7 +2732,7 @@ public List xreadGroup(final byte[] groupname, final byte[] consumer, fi byte[][] keys = streams.keySet().toArray(new byte[streams.size()][]); - return new JedisClusterCommand>(connectionHandler, maxAttempts) { + return new JedisClusterCommand>(connectionHandler, maxAttempts, maxTotalRetriesDuration) { @Override public List execute(Jedis connection) { return connection.xreadGroup(groupname, consumer, count, block, noAck, streams); @@ -2704,7 +2743,7 @@ public List execute(Jedis connection) { @Override public List xreadGroup(final byte[] groupname, final byte[] consumer, final XReadGroupParams xReadGroupParams, final Entry... streams) { - return new JedisClusterCommand>(connectionHandler, maxAttempts) { + return new JedisClusterCommand>(connectionHandler, maxAttempts, maxTotalRetriesDuration) { @Override public List execute(Jedis connection) { return connection.xreadGroup(groupname, consumer, xReadGroupParams, streams); @@ -2714,7 +2753,7 @@ public List execute(Jedis connection) { @Override public Long xdel(final byte[] key, final byte[]... ids) { - return new JedisClusterCommand(connectionHandler, maxAttempts) { + return new JedisClusterCommand(connectionHandler, maxAttempts, maxTotalRetriesDuration) { @Override public Long execute(Jedis connection) { return connection.xdel(key, ids); @@ -2724,7 +2763,7 @@ public Long execute(Jedis connection) { @Override public Long xtrim(final byte[] key, final long maxLen, final boolean approximateLength) { - return new JedisClusterCommand(connectionHandler, maxAttempts) { + return new JedisClusterCommand(connectionHandler, maxAttempts, maxTotalRetriesDuration) { @Override public Long execute(Jedis connection) { return connection.xtrim(key, maxLen, approximateLength); @@ -2734,7 +2773,7 @@ public Long execute(Jedis connection) { @Override public Long xtrim(final byte[] key, final XTrimParams params) { - return new JedisClusterCommand(connectionHandler, maxAttempts) { + return new JedisClusterCommand(connectionHandler, maxAttempts, maxTotalRetriesDuration) { @Override public Long execute(Jedis connection) { return connection.xtrim(key, params); @@ -2745,7 +2784,7 @@ public Long execute(Jedis connection) { @Override public List xpending(final byte[] key, final byte[] groupname, final byte[] start, final byte[] end, final int count, final byte[] consumername) { - return new JedisClusterCommand>(connectionHandler, maxAttempts) { + return new JedisClusterCommand>(connectionHandler, maxAttempts, maxTotalRetriesDuration) { @Override public List execute(Jedis connection) { return connection.xpending(key, groupname, start, end, count, consumername); @@ -2755,7 +2794,7 @@ public List execute(Jedis connection) { @Override public Object xpending(final byte[] key, final byte[] groupname) { - return new JedisClusterCommand(connectionHandler, maxAttempts) { + return new JedisClusterCommand(connectionHandler, maxAttempts, maxTotalRetriesDuration) { @Override public Object execute(Jedis connection) { return connection.xpending(key, groupname); @@ -2765,7 +2804,7 @@ public Object execute(Jedis connection) { @Override public List xpending(final byte[] key, final byte[] groupname, final XPendingParams params) { - return new JedisClusterCommand>(connectionHandler, maxAttempts) { + return new JedisClusterCommand>(connectionHandler, maxAttempts, maxTotalRetriesDuration) { @Override public List execute(Jedis connection) { return connection.xpending(key, groupname, params); @@ -2777,7 +2816,7 @@ public List execute(Jedis connection) { public List xclaim(final byte[] key, final byte[] groupname, final byte[] consumername, final long minIdleTime, final long newIdleTime, final int retries, final boolean force, final byte[][] ids) { - return new JedisClusterCommand>(connectionHandler, maxAttempts) { + return new JedisClusterCommand>(connectionHandler, maxAttempts, maxTotalRetriesDuration) { @Override public List execute(Jedis connection) { return connection.xclaim(key, groupname, consumername, minIdleTime, newIdleTime, retries, @@ -2789,7 +2828,7 @@ public List execute(Jedis connection) { @Override public List xclaim(byte[] key, byte[] group, byte[] consumername, long minIdleTime, XClaimParams params, byte[]... ids) { - return new JedisClusterCommand>(connectionHandler, maxAttempts) { + return new JedisClusterCommand>(connectionHandler, maxAttempts, maxTotalRetriesDuration) { @Override public List execute(Jedis connection) { return connection.xclaim(key, group, consumername, minIdleTime, params, ids); @@ -2800,7 +2839,7 @@ public List execute(Jedis connection) { @Override public List xclaimJustId(byte[] key, byte[] group, byte[] consumername, long minIdleTime, XClaimParams params, byte[]... ids) { - return new JedisClusterCommand>(connectionHandler, maxAttempts) { + return new JedisClusterCommand>(connectionHandler, maxAttempts, maxTotalRetriesDuration) { @Override public List execute(Jedis connection) { return connection.xclaimJustId(key, group, consumername, minIdleTime, params, ids); @@ -2810,7 +2849,7 @@ public List execute(Jedis connection) { @Override public Long waitReplicas(final byte[] key, final int replicas, final long timeout) { - return new JedisClusterCommand(connectionHandler, maxAttempts) { + return new JedisClusterCommand(connectionHandler, maxAttempts, maxTotalRetriesDuration) { @Override public Long execute(Jedis connection) { return connection.waitReplicas(replicas, timeout); @@ -2819,7 +2858,7 @@ public Long execute(Jedis connection) { } public Object sendCommand(final byte[] sampleKey, final ProtocolCommand cmd, final byte[]... args) { - return new JedisClusterCommand(connectionHandler, maxAttempts) { + return new JedisClusterCommand(connectionHandler, maxAttempts, maxTotalRetriesDuration) { @Override public Object execute(Jedis connection) { return connection.sendCommand(cmd, args); @@ -2829,7 +2868,7 @@ public Object execute(Jedis connection) { public Object sendBlockingCommand(final byte[] sampleKey, final ProtocolCommand cmd, final byte[]... args) { - return new JedisClusterCommand(connectionHandler, maxAttempts) { + return new JedisClusterCommand(connectionHandler, maxAttempts, maxTotalRetriesDuration) { @Override public Object execute(Jedis connection) { return connection.sendBlockingCommand(cmd, args); diff --git a/src/main/java/redis/clients/jedis/Connection.java b/src/main/java/redis/clients/jedis/Connection.java index eadb56b918..5bc7702b81 100644 --- a/src/main/java/redis/clients/jedis/Connection.java +++ b/src/main/java/redis/clients/jedis/Connection.java @@ -81,6 +81,11 @@ public Connection(final JedisSocketFactory jedisSocketFactory) { this.soTimeout = jedisSocketFactory.getSoTimeout(); } + @Override + public String toString() { + return "Connection{" + socketFactory + "}"; + } + public Socket getSocket() { return socket; } diff --git a/src/main/java/redis/clients/jedis/DefaultJedisSocketFactory.java b/src/main/java/redis/clients/jedis/DefaultJedisSocketFactory.java index e9bcc10c92..a6f8883085 100644 --- a/src/main/java/redis/clients/jedis/DefaultJedisSocketFactory.java +++ b/src/main/java/redis/clients/jedis/DefaultJedisSocketFactory.java @@ -220,4 +220,9 @@ public HostAndPortMapper getHostAndPortMapper() { public void setHostAndPortMapper(HostAndPortMapper hostAndPortMapper) { this.hostAndPortMapper = hostAndPortMapper; } + + @Override + public String toString() { + return "DefaultJedisSocketFactory{" + hostAndPort.toString() + "}"; + } } diff --git a/src/main/java/redis/clients/jedis/JedisCluster.java b/src/main/java/redis/clients/jedis/JedisCluster.java index 13571194ab..56eddd4880 100644 --- a/src/main/java/redis/clients/jedis/JedisCluster.java +++ b/src/main/java/redis/clients/jedis/JedisCluster.java @@ -10,6 +10,7 @@ import redis.clients.jedis.util.JedisClusterHashTagUtil; import redis.clients.jedis.util.KeyMergeUtil; +import java.time.Duration; import java.util.Collections; import java.util.List; import java.util.Map; @@ -244,14 +245,37 @@ public JedisCluster(Set jedisClusterNode, int connectionTimeout, in hostAndPortMap); } + /** + * @param maxTotalRetriesDuration After this amount of time we will do no more retries and report + * the operation as failed. + * @deprecated This constructor will be removed in future. + */ + @Deprecated + public JedisCluster(Set jedisClusterNode, int connectionTimeout, int soTimeout, + int infiniteSoTimeout, int maxAttempts, String user, String password, String clientName, + final GenericObjectPoolConfig poolConfig, boolean ssl, + SSLSocketFactory sslSocketFactory, SSLParameters sslParameters, + HostnameVerifier hostnameVerifier, JedisClusterHostAndPortMap hostAndPortMap, + Duration maxTotalRetriesDuration) { + super(jedisClusterNode, connectionTimeout, soTimeout, infiniteSoTimeout, maxAttempts, user, + password, clientName, poolConfig, ssl, sslSocketFactory, sslParameters, hostnameVerifier, + hostAndPortMap, maxTotalRetriesDuration); + } + public JedisCluster(Set nodes, final JedisClientConfig clientConfig, int maxAttempts, final GenericObjectPoolConfig poolConfig) { super(nodes, clientConfig, maxAttempts, poolConfig); } + public JedisCluster(Set nodes, final JedisClientConfig clientConfig, + int maxAttempts, Duration maxTotalRetriesDuration, + final GenericObjectPoolConfig poolConfig) { + super(nodes, clientConfig, maxAttempts, maxTotalRetriesDuration, poolConfig); + } + @Override public Boolean copy(String srcKey, String dstKey, boolean replace) { - return new JedisClusterCommand(connectionHandler, maxAttempts) { + return new JedisClusterCommand(connectionHandler, maxAttempts, maxTotalRetriesDuration) { @Override public Boolean execute(Jedis connection) { return connection.copy(srcKey, dstKey, replace); @@ -261,7 +285,7 @@ public Boolean execute(Jedis connection) { @Override public String set(final String key, final String value) { - return new JedisClusterCommand(connectionHandler, maxAttempts) { + return new JedisClusterCommand(connectionHandler, maxAttempts, maxTotalRetriesDuration) { @Override public String execute(Jedis connection) { return connection.set(key, value); @@ -271,7 +295,7 @@ public String execute(Jedis connection) { @Override public String set(final String key, final String value, final SetParams params) { - return new JedisClusterCommand(connectionHandler, maxAttempts) { + return new JedisClusterCommand(connectionHandler, maxAttempts, maxTotalRetriesDuration) { @Override public String execute(Jedis connection) { return connection.set(key, value, params); @@ -281,7 +305,7 @@ public String execute(Jedis connection) { @Override public String get(final String key) { - return new JedisClusterCommand(connectionHandler, maxAttempts) { + return new JedisClusterCommand(connectionHandler, maxAttempts, maxTotalRetriesDuration) { @Override public String execute(Jedis connection) { return connection.get(key); @@ -291,7 +315,7 @@ public String execute(Jedis connection) { @Override public String getDel(final String key) { - return new JedisClusterCommand(connectionHandler, maxAttempts) { + return new JedisClusterCommand(connectionHandler, maxAttempts, maxTotalRetriesDuration) { @Override public String execute(Jedis connection) { return connection.getDel(key); @@ -301,7 +325,7 @@ public String execute(Jedis connection) { @Override public String getEx(String key, GetExParams params) { - return new JedisClusterCommand(connectionHandler, maxAttempts) { + return new JedisClusterCommand(connectionHandler, maxAttempts, maxTotalRetriesDuration) { @Override public String execute(Jedis connection) { return connection.getEx(key, params); @@ -311,7 +335,7 @@ public String execute(Jedis connection) { @Override public Boolean exists(final String key) { - return new JedisClusterCommand(connectionHandler, maxAttempts) { + return new JedisClusterCommand(connectionHandler, maxAttempts, maxTotalRetriesDuration) { @Override public Boolean execute(Jedis connection) { return connection.exists(key); @@ -321,7 +345,7 @@ public Boolean execute(Jedis connection) { @Override public Long exists(final String... keys) { - return new JedisClusterCommand(connectionHandler, maxAttempts) { + return new JedisClusterCommand(connectionHandler, maxAttempts, maxTotalRetriesDuration) { @Override public Long execute(Jedis connection) { return connection.exists(keys); @@ -331,7 +355,7 @@ public Long execute(Jedis connection) { @Override public Long persist(final String key) { - return new JedisClusterCommand(connectionHandler, maxAttempts) { + return new JedisClusterCommand(connectionHandler, maxAttempts, maxTotalRetriesDuration) { @Override public Long execute(Jedis connection) { return connection.persist(key); @@ -341,7 +365,7 @@ public Long execute(Jedis connection) { @Override public String type(final String key) { - return new JedisClusterCommand(connectionHandler, maxAttempts) { + return new JedisClusterCommand(connectionHandler, maxAttempts, maxTotalRetriesDuration) { @Override public String execute(Jedis connection) { return connection.type(key); @@ -351,7 +375,7 @@ public String execute(Jedis connection) { @Override public byte[] dump(final String key) { - return new JedisClusterCommand(connectionHandler, maxAttempts) { + return new JedisClusterCommand(connectionHandler, maxAttempts, maxTotalRetriesDuration) { @Override public byte[] execute(Jedis connection) { return connection.dump(key); @@ -361,7 +385,7 @@ public byte[] execute(Jedis connection) { @Override public String restore(final String key, final long ttl, final byte[] serializedValue) { - return new JedisClusterCommand(connectionHandler, maxAttempts) { + return new JedisClusterCommand(connectionHandler, maxAttempts, maxTotalRetriesDuration) { @Override public String execute(Jedis connection) { return connection.restore(key, ttl, serializedValue); @@ -372,7 +396,7 @@ public String execute(Jedis connection) { @Override public String restore(final String key, final long ttl, final byte[] serializedValue, final RestoreParams params) { - return new JedisClusterCommand(connectionHandler, maxAttempts) { + return new JedisClusterCommand(connectionHandler, maxAttempts, maxTotalRetriesDuration) { @Override public String execute(Jedis connection) { return connection.restore(key, ttl, serializedValue, params); @@ -382,7 +406,7 @@ public String execute(Jedis connection) { @Override public Long expire(final String key, final long seconds) { - return new JedisClusterCommand(connectionHandler, maxAttempts) { + return new JedisClusterCommand(connectionHandler, maxAttempts, maxTotalRetriesDuration) { @Override public Long execute(Jedis connection) { return connection.expire(key, seconds); @@ -392,7 +416,7 @@ public Long execute(Jedis connection) { @Override public Long pexpire(final String key, final long milliseconds) { - return new JedisClusterCommand(connectionHandler, maxAttempts) { + return new JedisClusterCommand(connectionHandler, maxAttempts, maxTotalRetriesDuration) { @Override public Long execute(Jedis connection) { return connection.pexpire(key, milliseconds); @@ -402,7 +426,7 @@ public Long execute(Jedis connection) { @Override public Long expireAt(final String key, final long unixTime) { - return new JedisClusterCommand(connectionHandler, maxAttempts) { + return new JedisClusterCommand(connectionHandler, maxAttempts, maxTotalRetriesDuration) { @Override public Long execute(Jedis connection) { return connection.expireAt(key, unixTime); @@ -412,7 +436,7 @@ public Long execute(Jedis connection) { @Override public Long pexpireAt(final String key, final long millisecondsTimestamp) { - return new JedisClusterCommand(connectionHandler, maxAttempts) { + return new JedisClusterCommand(connectionHandler, maxAttempts, maxTotalRetriesDuration) { @Override public Long execute(Jedis connection) { return connection.pexpireAt(key, millisecondsTimestamp); @@ -422,7 +446,7 @@ public Long execute(Jedis connection) { @Override public Long ttl(final String key) { - return new JedisClusterCommand(connectionHandler, maxAttempts) { + return new JedisClusterCommand(connectionHandler, maxAttempts, maxTotalRetriesDuration) { @Override public Long execute(Jedis connection) { return connection.ttl(key); @@ -432,7 +456,7 @@ public Long execute(Jedis connection) { @Override public Long pttl(final String key) { - return new JedisClusterCommand(connectionHandler, maxAttempts) { + return new JedisClusterCommand(connectionHandler, maxAttempts, maxTotalRetriesDuration) { @Override public Long execute(Jedis connection) { return connection.pttl(key); @@ -442,7 +466,7 @@ public Long execute(Jedis connection) { @Override public Long touch(final String key) { - return new JedisClusterCommand(connectionHandler, maxAttempts) { + return new JedisClusterCommand(connectionHandler, maxAttempts, maxTotalRetriesDuration) { @Override public Long execute(Jedis connection) { return connection.touch(key); @@ -452,7 +476,7 @@ public Long execute(Jedis connection) { @Override public Long touch(final String... keys) { - return new JedisClusterCommand(connectionHandler, maxAttempts) { + return new JedisClusterCommand(connectionHandler, maxAttempts, maxTotalRetriesDuration) { @Override public Long execute(Jedis connection) { return connection.touch(keys); @@ -462,7 +486,7 @@ public Long execute(Jedis connection) { @Override public Boolean setbit(final String key, final long offset, final boolean value) { - return new JedisClusterCommand(connectionHandler, maxAttempts) { + return new JedisClusterCommand(connectionHandler, maxAttempts, maxTotalRetriesDuration) { @Override public Boolean execute(Jedis connection) { return connection.setbit(key, offset, value); @@ -472,7 +496,7 @@ public Boolean execute(Jedis connection) { @Override public Boolean setbit(final String key, final long offset, final String value) { - return new JedisClusterCommand(connectionHandler, maxAttempts) { + return new JedisClusterCommand(connectionHandler, maxAttempts, maxTotalRetriesDuration) { @Override public Boolean execute(Jedis connection) { return connection.setbit(key, offset, value); @@ -482,7 +506,7 @@ public Boolean execute(Jedis connection) { @Override public Boolean getbit(final String key, final long offset) { - return new JedisClusterCommand(connectionHandler, maxAttempts) { + return new JedisClusterCommand(connectionHandler, maxAttempts, maxTotalRetriesDuration) { @Override public Boolean execute(Jedis connection) { return connection.getbit(key, offset); @@ -492,7 +516,7 @@ public Boolean execute(Jedis connection) { @Override public Long setrange(final String key, final long offset, final String value) { - return new JedisClusterCommand(connectionHandler, maxAttempts) { + return new JedisClusterCommand(connectionHandler, maxAttempts, maxTotalRetriesDuration) { @Override public Long execute(Jedis connection) { return connection.setrange(key, offset, value); @@ -502,7 +526,7 @@ public Long execute(Jedis connection) { @Override public String getrange(final String key, final long startOffset, final long endOffset) { - return new JedisClusterCommand(connectionHandler, maxAttempts) { + return new JedisClusterCommand(connectionHandler, maxAttempts, maxTotalRetriesDuration) { @Override public String execute(Jedis connection) { return connection.getrange(key, startOffset, endOffset); @@ -512,7 +536,7 @@ public String execute(Jedis connection) { @Override public String getSet(final String key, final String value) { - return new JedisClusterCommand(connectionHandler, maxAttempts) { + return new JedisClusterCommand(connectionHandler, maxAttempts, maxTotalRetriesDuration) { @Override public String execute(Jedis connection) { return connection.getSet(key, value); @@ -522,7 +546,7 @@ public String execute(Jedis connection) { @Override public Long setnx(final String key, final String value) { - return new JedisClusterCommand(connectionHandler, maxAttempts) { + return new JedisClusterCommand(connectionHandler, maxAttempts, maxTotalRetriesDuration) { @Override public Long execute(Jedis connection) { return connection.setnx(key, value); @@ -532,7 +556,7 @@ public Long execute(Jedis connection) { @Override public String setex(final String key, final long seconds, final String value) { - return new JedisClusterCommand(connectionHandler, maxAttempts) { + return new JedisClusterCommand(connectionHandler, maxAttempts, maxTotalRetriesDuration) { @Override public String execute(Jedis connection) { return connection.setex(key, seconds, value); @@ -542,7 +566,7 @@ public String execute(Jedis connection) { @Override public String psetex(final String key, final long milliseconds, final String value) { - return new JedisClusterCommand(connectionHandler, maxAttempts) { + return new JedisClusterCommand(connectionHandler, maxAttempts, maxTotalRetriesDuration) { @Override public String execute(Jedis connection) { return connection.psetex(key, milliseconds, value); @@ -552,7 +576,7 @@ public String execute(Jedis connection) { @Override public Long decrBy(final String key, final long decrement) { - return new JedisClusterCommand(connectionHandler, maxAttempts) { + return new JedisClusterCommand(connectionHandler, maxAttempts, maxTotalRetriesDuration) { @Override public Long execute(Jedis connection) { return connection.decrBy(key, decrement); @@ -562,7 +586,7 @@ public Long execute(Jedis connection) { @Override public Long decr(final String key) { - return new JedisClusterCommand(connectionHandler, maxAttempts) { + return new JedisClusterCommand(connectionHandler, maxAttempts, maxTotalRetriesDuration) { @Override public Long execute(Jedis connection) { return connection.decr(key); @@ -572,7 +596,7 @@ public Long execute(Jedis connection) { @Override public Long incrBy(final String key, final long increment) { - return new JedisClusterCommand(connectionHandler, maxAttempts) { + return new JedisClusterCommand(connectionHandler, maxAttempts, maxTotalRetriesDuration) { @Override public Long execute(Jedis connection) { return connection.incrBy(key, increment); @@ -582,7 +606,7 @@ public Long execute(Jedis connection) { @Override public Double incrByFloat(final String key, final double increment) { - return new JedisClusterCommand(connectionHandler, maxAttempts) { + return new JedisClusterCommand(connectionHandler, maxAttempts, maxTotalRetriesDuration) { @Override public Double execute(Jedis connection) { return connection.incrByFloat(key, increment); @@ -592,7 +616,7 @@ public Double execute(Jedis connection) { @Override public Long incr(final String key) { - return new JedisClusterCommand(connectionHandler, maxAttempts) { + return new JedisClusterCommand(connectionHandler, maxAttempts, maxTotalRetriesDuration) { @Override public Long execute(Jedis connection) { return connection.incr(key); @@ -602,7 +626,7 @@ public Long execute(Jedis connection) { @Override public Long append(final String key, final String value) { - return new JedisClusterCommand(connectionHandler, maxAttempts) { + return new JedisClusterCommand(connectionHandler, maxAttempts, maxTotalRetriesDuration) { @Override public Long execute(Jedis connection) { return connection.append(key, value); @@ -612,7 +636,7 @@ public Long execute(Jedis connection) { @Override public String substr(final String key, final int start, final int end) { - return new JedisClusterCommand(connectionHandler, maxAttempts) { + return new JedisClusterCommand(connectionHandler, maxAttempts, maxTotalRetriesDuration) { @Override public String execute(Jedis connection) { return connection.substr(key, start, end); @@ -622,7 +646,7 @@ public String execute(Jedis connection) { @Override public Long hset(final String key, final String field, final String value) { - return new JedisClusterCommand(connectionHandler, maxAttempts) { + return new JedisClusterCommand(connectionHandler, maxAttempts, maxTotalRetriesDuration) { @Override public Long execute(Jedis connection) { return connection.hset(key, field, value); @@ -632,7 +656,7 @@ public Long execute(Jedis connection) { @Override public Long hset(final String key, final Map hash) { - return new JedisClusterCommand(connectionHandler, maxAttempts) { + return new JedisClusterCommand(connectionHandler, maxAttempts, maxTotalRetriesDuration) { @Override public Long execute(Jedis connection) { return connection.hset(key, hash); @@ -642,7 +666,7 @@ public Long execute(Jedis connection) { @Override public String hget(final String key, final String field) { - return new JedisClusterCommand(connectionHandler, maxAttempts) { + return new JedisClusterCommand(connectionHandler, maxAttempts, maxTotalRetriesDuration) { @Override public String execute(Jedis connection) { return connection.hget(key, field); @@ -652,7 +676,7 @@ public String execute(Jedis connection) { @Override public Long hsetnx(final String key, final String field, final String value) { - return new JedisClusterCommand(connectionHandler, maxAttempts) { + return new JedisClusterCommand(connectionHandler, maxAttempts, maxTotalRetriesDuration) { @Override public Long execute(Jedis connection) { return connection.hsetnx(key, field, value); @@ -662,7 +686,7 @@ public Long execute(Jedis connection) { @Override public String hmset(final String key, final Map hash) { - return new JedisClusterCommand(connectionHandler, maxAttempts) { + return new JedisClusterCommand(connectionHandler, maxAttempts, maxTotalRetriesDuration) { @Override public String execute(Jedis connection) { return connection.hmset(key, hash); @@ -672,7 +696,7 @@ public String execute(Jedis connection) { @Override public List hmget(final String key, final String... fields) { - return new JedisClusterCommand>(connectionHandler, maxAttempts) { + return new JedisClusterCommand>(connectionHandler, maxAttempts, maxTotalRetriesDuration) { @Override public List execute(Jedis connection) { return connection.hmget(key, fields); @@ -682,7 +706,7 @@ public List execute(Jedis connection) { @Override public Long hincrBy(final String key, final String field, final long value) { - return new JedisClusterCommand(connectionHandler, maxAttempts) { + return new JedisClusterCommand(connectionHandler, maxAttempts, maxTotalRetriesDuration) { @Override public Long execute(Jedis connection) { return connection.hincrBy(key, field, value); @@ -692,7 +716,7 @@ public Long execute(Jedis connection) { @Override public Double hincrByFloat(final String key, final String field, final double value) { - return new JedisClusterCommand(connectionHandler, maxAttempts) { + return new JedisClusterCommand(connectionHandler, maxAttempts, maxTotalRetriesDuration) { @Override public Double execute(Jedis connection) { return connection.hincrByFloat(key, field, value); @@ -702,7 +726,7 @@ public Double execute(Jedis connection) { @Override public Boolean hexists(final String key, final String field) { - return new JedisClusterCommand(connectionHandler, maxAttempts) { + return new JedisClusterCommand(connectionHandler, maxAttempts, maxTotalRetriesDuration) { @Override public Boolean execute(Jedis connection) { return connection.hexists(key, field); @@ -712,7 +736,7 @@ public Boolean execute(Jedis connection) { @Override public Long hdel(final String key, final String... field) { - return new JedisClusterCommand(connectionHandler, maxAttempts) { + return new JedisClusterCommand(connectionHandler, maxAttempts, maxTotalRetriesDuration) { @Override public Long execute(Jedis connection) { return connection.hdel(key, field); @@ -722,7 +746,7 @@ public Long execute(Jedis connection) { @Override public Long hlen(final String key) { - return new JedisClusterCommand(connectionHandler, maxAttempts) { + return new JedisClusterCommand(connectionHandler, maxAttempts, maxTotalRetriesDuration) { @Override public Long execute(Jedis connection) { return connection.hlen(key); @@ -732,7 +756,7 @@ public Long execute(Jedis connection) { @Override public Set hkeys(final String key) { - return new JedisClusterCommand>(connectionHandler, maxAttempts) { + return new JedisClusterCommand>(connectionHandler, maxAttempts, maxTotalRetriesDuration) { @Override public Set execute(Jedis connection) { return connection.hkeys(key); @@ -742,7 +766,7 @@ public Set execute(Jedis connection) { @Override public List hvals(final String key) { - return new JedisClusterCommand>(connectionHandler, maxAttempts) { + return new JedisClusterCommand>(connectionHandler, maxAttempts, maxTotalRetriesDuration) { @Override public List execute(Jedis connection) { return connection.hvals(key); @@ -752,7 +776,7 @@ public List execute(Jedis connection) { @Override public Map hgetAll(final String key) { - return new JedisClusterCommand>(connectionHandler, maxAttempts) { + return new JedisClusterCommand>(connectionHandler, maxAttempts, maxTotalRetriesDuration) { @Override public Map execute(Jedis connection) { return connection.hgetAll(key); @@ -762,7 +786,7 @@ public Map execute(Jedis connection) { @Override public String hrandfield(final String key) { - return new JedisClusterCommand(connectionHandler, maxAttempts) { + return new JedisClusterCommand(connectionHandler, maxAttempts, maxTotalRetriesDuration) { @Override public String execute(Jedis connection) { return connection.hrandfield(key); @@ -772,7 +796,7 @@ public String execute(Jedis connection) { @Override public List hrandfield(final String key, final long count) { - return new JedisClusterCommand>(connectionHandler, maxAttempts) { + return new JedisClusterCommand>(connectionHandler, maxAttempts, maxTotalRetriesDuration) { @Override public List execute(Jedis connection) { return connection.hrandfield(key, count); @@ -782,7 +806,7 @@ public List execute(Jedis connection) { @Override public Map hrandfieldWithValues(final String key, final long count) { - return new JedisClusterCommand>(connectionHandler, maxAttempts) { + return new JedisClusterCommand>(connectionHandler, maxAttempts, maxTotalRetriesDuration) { @Override public Map execute(Jedis connection) { return connection.hrandfieldWithValues(key, count); @@ -792,7 +816,7 @@ public Map execute(Jedis connection) { @Override public Long rpush(final String key, final String... string) { - return new JedisClusterCommand(connectionHandler, maxAttempts) { + return new JedisClusterCommand(connectionHandler, maxAttempts, maxTotalRetriesDuration) { @Override public Long execute(Jedis connection) { return connection.rpush(key, string); @@ -802,7 +826,7 @@ public Long execute(Jedis connection) { @Override public Long lpush(final String key, final String... string) { - return new JedisClusterCommand(connectionHandler, maxAttempts) { + return new JedisClusterCommand(connectionHandler, maxAttempts, maxTotalRetriesDuration) { @Override public Long execute(Jedis connection) { return connection.lpush(key, string); @@ -812,7 +836,7 @@ public Long execute(Jedis connection) { @Override public Long llen(final String key) { - return new JedisClusterCommand(connectionHandler, maxAttempts) { + return new JedisClusterCommand(connectionHandler, maxAttempts, maxTotalRetriesDuration) { @Override public Long execute(Jedis connection) { return connection.llen(key); @@ -822,7 +846,7 @@ public Long execute(Jedis connection) { @Override public List lrange(final String key, final long start, final long stop) { - return new JedisClusterCommand>(connectionHandler, maxAttempts) { + return new JedisClusterCommand>(connectionHandler, maxAttempts, maxTotalRetriesDuration) { @Override public List execute(Jedis connection) { return connection.lrange(key, start, stop); @@ -832,7 +856,7 @@ public List execute(Jedis connection) { @Override public String ltrim(final String key, final long start, final long stop) { - return new JedisClusterCommand(connectionHandler, maxAttempts) { + return new JedisClusterCommand(connectionHandler, maxAttempts, maxTotalRetriesDuration) { @Override public String execute(Jedis connection) { return connection.ltrim(key, start, stop); @@ -842,7 +866,7 @@ public String execute(Jedis connection) { @Override public String lindex(final String key, final long index) { - return new JedisClusterCommand(connectionHandler, maxAttempts) { + return new JedisClusterCommand(connectionHandler, maxAttempts, maxTotalRetriesDuration) { @Override public String execute(Jedis connection) { return connection.lindex(key, index); @@ -852,7 +876,7 @@ public String execute(Jedis connection) { @Override public String lset(final String key, final long index, final String value) { - return new JedisClusterCommand(connectionHandler, maxAttempts) { + return new JedisClusterCommand(connectionHandler, maxAttempts, maxTotalRetriesDuration) { @Override public String execute(Jedis connection) { return connection.lset(key, index, value); @@ -862,7 +886,7 @@ public String execute(Jedis connection) { @Override public Long lrem(final String key, final long count, final String value) { - return new JedisClusterCommand(connectionHandler, maxAttempts) { + return new JedisClusterCommand(connectionHandler, maxAttempts, maxTotalRetriesDuration) { @Override public Long execute(Jedis connection) { return connection.lrem(key, count, value); @@ -872,7 +896,7 @@ public Long execute(Jedis connection) { @Override public String lpop(final String key) { - return new JedisClusterCommand(connectionHandler, maxAttempts) { + return new JedisClusterCommand(connectionHandler, maxAttempts, maxTotalRetriesDuration) { @Override public String execute(Jedis connection) { return connection.lpop(key); @@ -882,7 +906,7 @@ public String execute(Jedis connection) { @Override public List lpop(final String key, final int count) { - return new JedisClusterCommand>(connectionHandler, maxAttempts) { + return new JedisClusterCommand>(connectionHandler, maxAttempts, maxTotalRetriesDuration) { @Override public List execute(Jedis connection) { return connection.lpop(key, count); @@ -892,7 +916,7 @@ public List execute(Jedis connection) { @Override public Long lpos(final String key, final String element) { - return new JedisClusterCommand(connectionHandler, maxAttempts) { + return new JedisClusterCommand(connectionHandler, maxAttempts, maxTotalRetriesDuration) { @Override public Long execute(Jedis connection) { return connection.lpos(key, element); @@ -902,7 +926,7 @@ public Long execute(Jedis connection) { @Override public Long lpos(final String key, final String element, final LPosParams params) { - return new JedisClusterCommand(connectionHandler, maxAttempts) { + return new JedisClusterCommand(connectionHandler, maxAttempts, maxTotalRetriesDuration) { @Override public Long execute(Jedis connection) { return connection.lpos(key, element, params); @@ -913,7 +937,7 @@ public Long execute(Jedis connection) { @Override public List lpos(final String key, final String element, final LPosParams params, final long count) { - return new JedisClusterCommand>(connectionHandler, maxAttempts) { + return new JedisClusterCommand>(connectionHandler, maxAttempts, maxTotalRetriesDuration) { @Override public List execute(Jedis connection) { return connection.lpos(key, element, params, count); @@ -923,7 +947,7 @@ public List execute(Jedis connection) { @Override public String rpop(final String key) { - return new JedisClusterCommand(connectionHandler, maxAttempts) { + return new JedisClusterCommand(connectionHandler, maxAttempts, maxTotalRetriesDuration) { @Override public String execute(Jedis connection) { return connection.rpop(key); @@ -933,7 +957,7 @@ public String execute(Jedis connection) { @Override public List rpop(final String key, final int count) { - return new JedisClusterCommand>(connectionHandler, maxAttempts) { + return new JedisClusterCommand>(connectionHandler, maxAttempts, maxTotalRetriesDuration) { @Override public List execute(Jedis connection) { return connection.rpop(key, count); @@ -943,7 +967,7 @@ public List execute(Jedis connection) { @Override public Long sadd(final String key, final String... member) { - return new JedisClusterCommand(connectionHandler, maxAttempts) { + return new JedisClusterCommand(connectionHandler, maxAttempts, maxTotalRetriesDuration) { @Override public Long execute(Jedis connection) { return connection.sadd(key, member); @@ -953,7 +977,7 @@ public Long execute(Jedis connection) { @Override public Set smembers(final String key) { - return new JedisClusterCommand>(connectionHandler, maxAttempts) { + return new JedisClusterCommand>(connectionHandler, maxAttempts, maxTotalRetriesDuration) { @Override public Set execute(Jedis connection) { return connection.smembers(key); @@ -963,7 +987,7 @@ public Set execute(Jedis connection) { @Override public Long srem(final String key, final String... member) { - return new JedisClusterCommand(connectionHandler, maxAttempts) { + return new JedisClusterCommand(connectionHandler, maxAttempts, maxTotalRetriesDuration) { @Override public Long execute(Jedis connection) { return connection.srem(key, member); @@ -973,7 +997,7 @@ public Long execute(Jedis connection) { @Override public String spop(final String key) { - return new JedisClusterCommand(connectionHandler, maxAttempts) { + return new JedisClusterCommand(connectionHandler, maxAttempts, maxTotalRetriesDuration) { @Override public String execute(Jedis connection) { return connection.spop(key); @@ -983,7 +1007,7 @@ public String execute(Jedis connection) { @Override public Set spop(final String key, final long count) { - return new JedisClusterCommand>(connectionHandler, maxAttempts) { + return new JedisClusterCommand>(connectionHandler, maxAttempts, maxTotalRetriesDuration) { @Override public Set execute(Jedis connection) { return connection.spop(key, count); @@ -993,7 +1017,7 @@ public Set execute(Jedis connection) { @Override public Long scard(final String key) { - return new JedisClusterCommand(connectionHandler, maxAttempts) { + return new JedisClusterCommand(connectionHandler, maxAttempts, maxTotalRetriesDuration) { @Override public Long execute(Jedis connection) { return connection.scard(key); @@ -1003,7 +1027,7 @@ public Long execute(Jedis connection) { @Override public Boolean sismember(final String key, final String member) { - return new JedisClusterCommand(connectionHandler, maxAttempts) { + return new JedisClusterCommand(connectionHandler, maxAttempts, maxTotalRetriesDuration) { @Override public Boolean execute(Jedis connection) { return connection.sismember(key, member); @@ -1013,7 +1037,7 @@ public Boolean execute(Jedis connection) { @Override public List smismember(final String key, final String... members) { - return new JedisClusterCommand>(connectionHandler, maxAttempts) { + return new JedisClusterCommand>(connectionHandler, maxAttempts, maxTotalRetriesDuration) { @Override public List execute(Jedis connection) { return connection.smismember(key, members); @@ -1023,7 +1047,7 @@ public List execute(Jedis connection) { @Override public String srandmember(final String key) { - return new JedisClusterCommand(connectionHandler, maxAttempts) { + return new JedisClusterCommand(connectionHandler, maxAttempts, maxTotalRetriesDuration) { @Override public String execute(Jedis connection) { return connection.srandmember(key); @@ -1033,7 +1057,7 @@ public String execute(Jedis connection) { @Override public List srandmember(final String key, final int count) { - return new JedisClusterCommand>(connectionHandler, maxAttempts) { + return new JedisClusterCommand>(connectionHandler, maxAttempts, maxTotalRetriesDuration) { @Override public List execute(Jedis connection) { return connection.srandmember(key, count); @@ -1043,7 +1067,7 @@ public List execute(Jedis connection) { @Override public Long strlen(final String key) { - return new JedisClusterCommand(connectionHandler, maxAttempts) { + return new JedisClusterCommand(connectionHandler, maxAttempts, maxTotalRetriesDuration) { @Override public Long execute(Jedis connection) { return connection.strlen(key); @@ -1053,7 +1077,7 @@ public Long execute(Jedis connection) { @Override public Long zadd(final String key, final double score, final String member) { - return new JedisClusterCommand(connectionHandler, maxAttempts) { + return new JedisClusterCommand(connectionHandler, maxAttempts, maxTotalRetriesDuration) { @Override public Long execute(Jedis connection) { return connection.zadd(key, score, member); @@ -1064,7 +1088,7 @@ public Long execute(Jedis connection) { @Override public Long zadd(final String key, final double score, final String member, final ZAddParams params) { - return new JedisClusterCommand(connectionHandler, maxAttempts) { + return new JedisClusterCommand(connectionHandler, maxAttempts, maxTotalRetriesDuration) { @Override public Long execute(Jedis connection) { return connection.zadd(key, score, member, params); @@ -1074,7 +1098,7 @@ public Long execute(Jedis connection) { @Override public Long zadd(final String key, final Map scoreMembers) { - return new JedisClusterCommand(connectionHandler, maxAttempts) { + return new JedisClusterCommand(connectionHandler, maxAttempts, maxTotalRetriesDuration) { @Override public Long execute(Jedis connection) { return connection.zadd(key, scoreMembers); @@ -1084,7 +1108,7 @@ public Long execute(Jedis connection) { @Override public Long zadd(final String key, final Map scoreMembers, final ZAddParams params) { - return new JedisClusterCommand(connectionHandler, maxAttempts) { + return new JedisClusterCommand(connectionHandler, maxAttempts, maxTotalRetriesDuration) { @Override public Long execute(Jedis connection) { return connection.zadd(key, scoreMembers, params); @@ -1094,7 +1118,7 @@ public Long execute(Jedis connection) { @Override public Double zaddIncr(String key, double score, String member, ZAddParams params) { - return new JedisClusterCommand(connectionHandler, maxAttempts) { + return new JedisClusterCommand(connectionHandler, maxAttempts, maxTotalRetriesDuration) { @Override public Double execute(Jedis connection) { return connection.zaddIncr(key, score, member, params); @@ -1104,7 +1128,7 @@ public Double execute(Jedis connection) { @Override public Set zdiff(String... keys) { - return new JedisClusterCommand>(connectionHandler, maxAttempts) { + return new JedisClusterCommand>(connectionHandler, maxAttempts, maxTotalRetriesDuration) { @Override public Set execute(Jedis connection) { return connection.zdiff(keys); @@ -1114,7 +1138,7 @@ public Set execute(Jedis connection) { @Override public Set zdiffWithScores(String... keys) { - return new JedisClusterCommand>(connectionHandler, maxAttempts) { + return new JedisClusterCommand>(connectionHandler, maxAttempts, maxTotalRetriesDuration) { @Override public Set execute(Jedis connection) { return connection.zdiffWithScores(keys); @@ -1125,7 +1149,7 @@ public Set execute(Jedis connection) { @Override public Long zdiffStore(final String dstkey, final String... keys) { String[] wholeKeys = KeyMergeUtil.merge(dstkey, keys); - return new JedisClusterCommand(connectionHandler, maxAttempts) { + return new JedisClusterCommand(connectionHandler, maxAttempts, maxTotalRetriesDuration) { @Override public Long execute(Jedis connection) { return connection.zdiffStore(dstkey, keys); @@ -1135,7 +1159,7 @@ public Long execute(Jedis connection) { @Override public Set zrange(final String key, final long start, final long stop) { - return new JedisClusterCommand>(connectionHandler, maxAttempts) { + return new JedisClusterCommand>(connectionHandler, maxAttempts, maxTotalRetriesDuration) { @Override public Set execute(Jedis connection) { return connection.zrange(key, start, stop); @@ -1145,7 +1169,7 @@ public Set execute(Jedis connection) { @Override public Long zrem(final String key, final String... members) { - return new JedisClusterCommand(connectionHandler, maxAttempts) { + return new JedisClusterCommand(connectionHandler, maxAttempts, maxTotalRetriesDuration) { @Override public Long execute(Jedis connection) { return connection.zrem(key, members); @@ -1155,7 +1179,7 @@ public Long execute(Jedis connection) { @Override public Double zincrby(final String key, final double increment, final String member) { - return new JedisClusterCommand(connectionHandler, maxAttempts) { + return new JedisClusterCommand(connectionHandler, maxAttempts, maxTotalRetriesDuration) { @Override public Double execute(Jedis connection) { return connection.zincrby(key, increment, member); @@ -1166,7 +1190,7 @@ public Double execute(Jedis connection) { @Override public Double zincrby(final String key, final double increment, final String member, final ZIncrByParams params) { - return new JedisClusterCommand(connectionHandler, maxAttempts) { + return new JedisClusterCommand(connectionHandler, maxAttempts, maxTotalRetriesDuration) { @Override public Double execute(Jedis connection) { return connection.zincrby(key, increment, member, params); @@ -1176,7 +1200,7 @@ public Double execute(Jedis connection) { @Override public Long zrank(final String key, final String member) { - return new JedisClusterCommand(connectionHandler, maxAttempts) { + return new JedisClusterCommand(connectionHandler, maxAttempts, maxTotalRetriesDuration) { @Override public Long execute(Jedis connection) { return connection.zrank(key, member); @@ -1186,7 +1210,7 @@ public Long execute(Jedis connection) { @Override public Long zrevrank(final String key, final String member) { - return new JedisClusterCommand(connectionHandler, maxAttempts) { + return new JedisClusterCommand(connectionHandler, maxAttempts, maxTotalRetriesDuration) { @Override public Long execute(Jedis connection) { return connection.zrevrank(key, member); @@ -1196,7 +1220,7 @@ public Long execute(Jedis connection) { @Override public Set zrevrange(final String key, final long start, final long stop) { - return new JedisClusterCommand>(connectionHandler, maxAttempts) { + return new JedisClusterCommand>(connectionHandler, maxAttempts, maxTotalRetriesDuration) { @Override public Set execute(Jedis connection) { return connection.zrevrange(key, start, stop); @@ -1206,7 +1230,7 @@ public Set execute(Jedis connection) { @Override public Set zrangeWithScores(final String key, final long start, final long stop) { - return new JedisClusterCommand>(connectionHandler, maxAttempts) { + return new JedisClusterCommand>(connectionHandler, maxAttempts, maxTotalRetriesDuration) { @Override public Set execute(Jedis connection) { return connection.zrangeWithScores(key, start, stop); @@ -1216,7 +1240,7 @@ public Set execute(Jedis connection) { @Override public Set zrevrangeWithScores(final String key, final long start, final long stop) { - return new JedisClusterCommand>(connectionHandler, maxAttempts) { + return new JedisClusterCommand>(connectionHandler, maxAttempts, maxTotalRetriesDuration) { @Override public Set execute(Jedis connection) { return connection.zrevrangeWithScores(key, start, stop); @@ -1226,7 +1250,7 @@ public Set execute(Jedis connection) { @Override public String zrandmember(final String key) { - return new JedisClusterCommand(connectionHandler, maxAttempts) { + return new JedisClusterCommand(connectionHandler, maxAttempts, maxTotalRetriesDuration) { @Override public String execute(Jedis connection) { return connection.zrandmember(key); @@ -1236,7 +1260,7 @@ public String execute(Jedis connection) { @Override public Set zrandmember(final String key, final long count) { - return new JedisClusterCommand>(connectionHandler, maxAttempts) { + return new JedisClusterCommand>(connectionHandler, maxAttempts, maxTotalRetriesDuration) { @Override public Set execute(Jedis connection) { return connection.zrandmember(key, count); @@ -1246,7 +1270,7 @@ public Set execute(Jedis connection) { @Override public Set zrandmemberWithScores(final String key, final long count) { - return new JedisClusterCommand>(connectionHandler, maxAttempts) { + return new JedisClusterCommand>(connectionHandler, maxAttempts, maxTotalRetriesDuration) { @Override public Set execute(Jedis connection) { return connection.zrandmemberWithScores(key, count); @@ -1256,7 +1280,7 @@ public Set execute(Jedis connection) { @Override public Long zcard(final String key) { - return new JedisClusterCommand(connectionHandler, maxAttempts) { + return new JedisClusterCommand(connectionHandler, maxAttempts, maxTotalRetriesDuration) { @Override public Long execute(Jedis connection) { return connection.zcard(key); @@ -1266,7 +1290,7 @@ public Long execute(Jedis connection) { @Override public Double zscore(final String key, final String member) { - return new JedisClusterCommand(connectionHandler, maxAttempts) { + return new JedisClusterCommand(connectionHandler, maxAttempts, maxTotalRetriesDuration) { @Override public Double execute(Jedis connection) { return connection.zscore(key, member); @@ -1276,7 +1300,7 @@ public Double execute(Jedis connection) { @Override public List zmscore(final String key, final String... members) { - return new JedisClusterCommand>(connectionHandler, maxAttempts) { + return new JedisClusterCommand>(connectionHandler, maxAttempts, maxTotalRetriesDuration) { @Override public List execute(Jedis connection) { return connection.zmscore(key, members); @@ -1286,7 +1310,7 @@ public List execute(Jedis connection) { @Override public Tuple zpopmax(final String key) { - return new JedisClusterCommand(connectionHandler, maxAttempts) { + return new JedisClusterCommand(connectionHandler, maxAttempts, maxTotalRetriesDuration) { @Override public Tuple execute(Jedis connection) { return connection.zpopmax(key); @@ -1296,7 +1320,7 @@ public Tuple execute(Jedis connection) { @Override public Set zpopmax(final String key, final int count) { - return new JedisClusterCommand>(connectionHandler, maxAttempts) { + return new JedisClusterCommand>(connectionHandler, maxAttempts, maxTotalRetriesDuration) { @Override public Set execute(Jedis connection) { return connection.zpopmax(key, count); @@ -1306,7 +1330,7 @@ public Set execute(Jedis connection) { @Override public Tuple zpopmin(final String key) { - return new JedisClusterCommand(connectionHandler, maxAttempts) { + return new JedisClusterCommand(connectionHandler, maxAttempts, maxTotalRetriesDuration) { @Override public Tuple execute(Jedis connection) { return connection.zpopmin(key); @@ -1316,7 +1340,7 @@ public Tuple execute(Jedis connection) { @Override public Set zpopmin(final String key, final int count) { - return new JedisClusterCommand>(connectionHandler, maxAttempts) { + return new JedisClusterCommand>(connectionHandler, maxAttempts, maxTotalRetriesDuration) { @Override public Set execute(Jedis connection) { return connection.zpopmin(key, count); @@ -1326,7 +1350,7 @@ public Set execute(Jedis connection) { @Override public List sort(final String key) { - return new JedisClusterCommand>(connectionHandler, maxAttempts) { + return new JedisClusterCommand>(connectionHandler, maxAttempts, maxTotalRetriesDuration) { @Override public List execute(Jedis connection) { return connection.sort(key); @@ -1336,7 +1360,7 @@ public List execute(Jedis connection) { @Override public List sort(final String key, final SortingParams sortingParameters) { - return new JedisClusterCommand>(connectionHandler, maxAttempts) { + return new JedisClusterCommand>(connectionHandler, maxAttempts, maxTotalRetriesDuration) { @Override public List execute(Jedis connection) { return connection.sort(key, sortingParameters); @@ -1346,7 +1370,7 @@ public List execute(Jedis connection) { @Override public Long zcount(final String key, final double min, final double max) { - return new JedisClusterCommand(connectionHandler, maxAttempts) { + return new JedisClusterCommand(connectionHandler, maxAttempts, maxTotalRetriesDuration) { @Override public Long execute(Jedis connection) { return connection.zcount(key, min, max); @@ -1356,7 +1380,7 @@ public Long execute(Jedis connection) { @Override public Long zcount(final String key, final String min, final String max) { - return new JedisClusterCommand(connectionHandler, maxAttempts) { + return new JedisClusterCommand(connectionHandler, maxAttempts, maxTotalRetriesDuration) { @Override public Long execute(Jedis connection) { return connection.zcount(key, min, max); @@ -1366,7 +1390,7 @@ public Long execute(Jedis connection) { @Override public Set zrangeByScore(final String key, final double min, final double max) { - return new JedisClusterCommand>(connectionHandler, maxAttempts) { + return new JedisClusterCommand>(connectionHandler, maxAttempts, maxTotalRetriesDuration) { @Override public Set execute(Jedis connection) { return connection.zrangeByScore(key, min, max); @@ -1376,7 +1400,7 @@ public Set execute(Jedis connection) { @Override public Set zrangeByScore(final String key, final String min, final String max) { - return new JedisClusterCommand>(connectionHandler, maxAttempts) { + return new JedisClusterCommand>(connectionHandler, maxAttempts, maxTotalRetriesDuration) { @Override public Set execute(Jedis connection) { return connection.zrangeByScore(key, min, max); @@ -1386,7 +1410,7 @@ public Set execute(Jedis connection) { @Override public Set zrevrangeByScore(final String key, final double max, final double min) { - return new JedisClusterCommand>(connectionHandler, maxAttempts) { + return new JedisClusterCommand>(connectionHandler, maxAttempts, maxTotalRetriesDuration) { @Override public Set execute(Jedis connection) { return connection.zrevrangeByScore(key, max, min); @@ -1397,7 +1421,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, maxAttempts) { + return new JedisClusterCommand>(connectionHandler, maxAttempts, maxTotalRetriesDuration) { @Override public Set execute(Jedis connection) { return connection.zrangeByScore(key, min, max, offset, count); @@ -1407,7 +1431,7 @@ public Set execute(Jedis connection) { @Override public Set zrevrangeByScore(final String key, final String max, final String min) { - return new JedisClusterCommand>(connectionHandler, maxAttempts) { + return new JedisClusterCommand>(connectionHandler, maxAttempts, maxTotalRetriesDuration) { @Override public Set execute(Jedis connection) { return connection.zrevrangeByScore(key, max, min); @@ -1418,7 +1442,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, maxAttempts) { + return new JedisClusterCommand>(connectionHandler, maxAttempts, maxTotalRetriesDuration) { @Override public Set execute(Jedis connection) { return connection.zrangeByScore(key, min, max, offset, count); @@ -1429,7 +1453,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, maxAttempts) { + return new JedisClusterCommand>(connectionHandler, maxAttempts, maxTotalRetriesDuration) { @Override public Set execute(Jedis connection) { return connection.zrevrangeByScore(key, max, min, offset, count); @@ -1439,7 +1463,7 @@ public Set execute(Jedis connection) { @Override public Set zrangeByScoreWithScores(final String key, final double min, final double max) { - return new JedisClusterCommand>(connectionHandler, maxAttempts) { + return new JedisClusterCommand>(connectionHandler, maxAttempts, maxTotalRetriesDuration) { @Override public Set execute(Jedis connection) { return connection.zrangeByScoreWithScores(key, min, max); @@ -1449,7 +1473,7 @@ public Set execute(Jedis connection) { @Override public Set zrevrangeByScoreWithScores(final String key, final double max, final double min) { - return new JedisClusterCommand>(connectionHandler, maxAttempts) { + return new JedisClusterCommand>(connectionHandler, maxAttempts, maxTotalRetriesDuration) { @Override public Set execute(Jedis connection) { return connection.zrevrangeByScoreWithScores(key, max, min); @@ -1460,7 +1484,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, maxAttempts) { + return new JedisClusterCommand>(connectionHandler, maxAttempts, maxTotalRetriesDuration) { @Override public Set execute(Jedis connection) { return connection.zrangeByScoreWithScores(key, min, max, offset, count); @@ -1471,7 +1495,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, maxAttempts) { + return new JedisClusterCommand>(connectionHandler, maxAttempts, maxTotalRetriesDuration) { @Override public Set execute(Jedis connection) { return connection.zrevrangeByScore(key, max, min, offset, count); @@ -1481,7 +1505,7 @@ public Set execute(Jedis connection) { @Override public Set zrangeByScoreWithScores(final String key, final String min, final String max) { - return new JedisClusterCommand>(connectionHandler, maxAttempts) { + return new JedisClusterCommand>(connectionHandler, maxAttempts, maxTotalRetriesDuration) { @Override public Set execute(Jedis connection) { return connection.zrangeByScoreWithScores(key, min, max); @@ -1491,7 +1515,7 @@ public Set execute(Jedis connection) { @Override public Set zrevrangeByScoreWithScores(final String key, final String max, final String min) { - return new JedisClusterCommand>(connectionHandler, maxAttempts) { + return new JedisClusterCommand>(connectionHandler, maxAttempts, maxTotalRetriesDuration) { @Override public Set execute(Jedis connection) { return connection.zrevrangeByScoreWithScores(key, max, min); @@ -1502,7 +1526,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, maxAttempts) { + return new JedisClusterCommand>(connectionHandler, maxAttempts, maxTotalRetriesDuration) { @Override public Set execute(Jedis connection) { return connection.zrangeByScoreWithScores(key, min, max, offset, count); @@ -1513,7 +1537,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, maxAttempts) { + return new JedisClusterCommand>(connectionHandler, maxAttempts, maxTotalRetriesDuration) { @Override public Set execute(Jedis connection) { return connection.zrevrangeByScoreWithScores(key, max, min, offset, count); @@ -1524,7 +1548,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, maxAttempts) { + return new JedisClusterCommand>(connectionHandler, maxAttempts, maxTotalRetriesDuration) { @Override public Set execute(Jedis connection) { return connection.zrevrangeByScoreWithScores(key, max, min, offset, count); @@ -1534,7 +1558,7 @@ public Set execute(Jedis connection) { @Override public Long zremrangeByRank(final String key, final long start, final long stop) { - return new JedisClusterCommand(connectionHandler, maxAttempts) { + return new JedisClusterCommand(connectionHandler, maxAttempts, maxTotalRetriesDuration) { @Override public Long execute(Jedis connection) { return connection.zremrangeByRank(key, start, stop); @@ -1544,7 +1568,7 @@ public Long execute(Jedis connection) { @Override public Long zremrangeByScore(final String key, final double min, final double max) { - return new JedisClusterCommand(connectionHandler, maxAttempts) { + return new JedisClusterCommand(connectionHandler, maxAttempts, maxTotalRetriesDuration) { @Override public Long execute(Jedis connection) { return connection.zremrangeByScore(key, min, max); @@ -1554,7 +1578,7 @@ public Long execute(Jedis connection) { @Override public Long zremrangeByScore(final String key, final String min, final String max) { - return new JedisClusterCommand(connectionHandler, maxAttempts) { + return new JedisClusterCommand(connectionHandler, maxAttempts, maxTotalRetriesDuration) { @Override public Long execute(Jedis connection) { return connection.zremrangeByScore(key, min, max); @@ -1564,7 +1588,7 @@ public Long execute(Jedis connection) { @Override public Long zlexcount(final String key, final String min, final String max) { - return new JedisClusterCommand(connectionHandler, maxAttempts) { + return new JedisClusterCommand(connectionHandler, maxAttempts, maxTotalRetriesDuration) { @Override public Long execute(Jedis connection) { return connection.zlexcount(key, min, max); @@ -1574,7 +1598,7 @@ public Long execute(Jedis connection) { @Override public Set zrangeByLex(final String key, final String min, final String max) { - return new JedisClusterCommand>(connectionHandler, maxAttempts) { + return new JedisClusterCommand>(connectionHandler, maxAttempts, maxTotalRetriesDuration) { @Override public Set execute(Jedis connection) { return connection.zrangeByLex(key, min, max); @@ -1585,7 +1609,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, maxAttempts) { + return new JedisClusterCommand>(connectionHandler, maxAttempts, maxTotalRetriesDuration) { @Override public Set execute(Jedis connection) { return connection.zrangeByLex(key, min, max, offset, count); @@ -1595,7 +1619,7 @@ public Set execute(Jedis connection) { @Override public Set zrevrangeByLex(final String key, final String max, final String min) { - return new JedisClusterCommand>(connectionHandler, maxAttempts) { + return new JedisClusterCommand>(connectionHandler, maxAttempts, maxTotalRetriesDuration) { @Override public Set execute(Jedis connection) { return connection.zrevrangeByLex(key, max, min); @@ -1606,7 +1630,7 @@ public Set execute(Jedis connection) { @Override public Set zrevrangeByLex(final String key, final String max, final String min, final int offset, final int count) { - return new JedisClusterCommand>(connectionHandler, maxAttempts) { + return new JedisClusterCommand>(connectionHandler, maxAttempts, maxTotalRetriesDuration) { @Override public Set execute(Jedis connection) { return connection.zrevrangeByLex(key, max, min, offset, count); @@ -1616,7 +1640,7 @@ public Set execute(Jedis connection) { @Override public Long zremrangeByLex(final String key, final String min, final String max) { - return new JedisClusterCommand(connectionHandler, maxAttempts) { + return new JedisClusterCommand(connectionHandler, maxAttempts, maxTotalRetriesDuration) { @Override public Long execute(Jedis connection) { return connection.zremrangeByLex(key, min, max); @@ -1627,7 +1651,7 @@ public Long execute(Jedis connection) { @Override public Long linsert(final String key, final ListPosition where, final String pivot, final String value) { - return new JedisClusterCommand(connectionHandler, maxAttempts) { + return new JedisClusterCommand(connectionHandler, maxAttempts, maxTotalRetriesDuration) { @Override public Long execute(Jedis connection) { return connection.linsert(key, where, pivot, value); @@ -1637,7 +1661,7 @@ public Long execute(Jedis connection) { @Override public Long lpushx(final String key, final String... string) { - return new JedisClusterCommand(connectionHandler, maxAttempts) { + return new JedisClusterCommand(connectionHandler, maxAttempts, maxTotalRetriesDuration) { @Override public Long execute(Jedis connection) { return connection.lpushx(key, string); @@ -1647,7 +1671,7 @@ public Long execute(Jedis connection) { @Override public Long rpushx(final String key, final String... string) { - return new JedisClusterCommand(connectionHandler, maxAttempts) { + return new JedisClusterCommand(connectionHandler, maxAttempts, maxTotalRetriesDuration) { @Override public Long execute(Jedis connection) { return connection.rpushx(key, string); @@ -1657,7 +1681,7 @@ public Long execute(Jedis connection) { @Override public Long del(final String key) { - return new JedisClusterCommand(connectionHandler, maxAttempts) { + return new JedisClusterCommand(connectionHandler, maxAttempts, maxTotalRetriesDuration) { @Override public Long execute(Jedis connection) { return connection.del(key); @@ -1667,7 +1691,7 @@ public Long execute(Jedis connection) { @Override public Long unlink(final String key) { - return new JedisClusterCommand(connectionHandler, maxAttempts) { + return new JedisClusterCommand(connectionHandler, maxAttempts, maxTotalRetriesDuration) { @Override public Long execute(Jedis connection) { return connection.unlink(key); @@ -1677,7 +1701,7 @@ public Long execute(Jedis connection) { @Override public Long unlink(final String... keys) { - return new JedisClusterCommand(connectionHandler, maxAttempts) { + return new JedisClusterCommand(connectionHandler, maxAttempts, maxTotalRetriesDuration) { @Override public Long execute(Jedis connection) { return connection.unlink(keys); @@ -1688,7 +1712,7 @@ public Long execute(Jedis connection) { @Override public String echo(final String string) { // note that it'll be run from arbitrary node - return new JedisClusterCommand(connectionHandler, maxAttempts) { + return new JedisClusterCommand(connectionHandler, maxAttempts, maxTotalRetriesDuration) { @Override public String execute(Jedis connection) { return connection.echo(string); @@ -1698,7 +1722,7 @@ public String execute(Jedis connection) { @Override public Long bitcount(final String key) { - return new JedisClusterCommand(connectionHandler, maxAttempts) { + return new JedisClusterCommand(connectionHandler, maxAttempts, maxTotalRetriesDuration) { @Override public Long execute(Jedis connection) { return connection.bitcount(key); @@ -1708,7 +1732,7 @@ public Long execute(Jedis connection) { @Override public Long bitcount(final String key, final long start, final long end) { - return new JedisClusterCommand(connectionHandler, maxAttempts) { + return new JedisClusterCommand(connectionHandler, maxAttempts, maxTotalRetriesDuration) { @Override public Long execute(Jedis connection) { return connection.bitcount(key, start, end); @@ -1728,7 +1752,7 @@ public Set keys(final String pattern) { + " only supports KEYS commands with patterns containing hash-tags" + " ( curly-brackets enclosed strings )"); } - return new JedisClusterCommand>(connectionHandler, maxAttempts) { + return new JedisClusterCommand>(connectionHandler, maxAttempts, maxTotalRetriesDuration) { @Override public Set execute(Jedis connection) { return connection.keys(pattern); @@ -1753,7 +1777,8 @@ public ScanResult scan(final String cursor, final ScanParams params) { + " ( curly-brackets enclosed strings )"); } - return new JedisClusterCommand>(connectionHandler, maxAttempts) { + return new JedisClusterCommand< ScanResult>(connectionHandler, maxAttempts, + maxTotalRetriesDuration) { @Override public ScanResult execute(Jedis connection) { return connection.scan(cursor, params); @@ -1764,7 +1789,7 @@ public ScanResult execute(Jedis connection) { @Override public ScanResult> hscan(final String key, final String cursor) { return new JedisClusterCommand>>(connectionHandler, - maxAttempts) { + maxAttempts, maxTotalRetriesDuration) { @Override public ScanResult> execute(Jedis connection) { return connection.hscan(key, cursor); @@ -1774,7 +1799,7 @@ public ScanResult> execute(Jedis connection) { @Override public ScanResult sscan(final String key, final String cursor) { - return new JedisClusterCommand>(connectionHandler, maxAttempts) { + return new JedisClusterCommand>(connectionHandler, maxAttempts, maxTotalRetriesDuration) { @Override public ScanResult execute(Jedis connection) { return connection.sscan(key, cursor); @@ -1784,7 +1809,7 @@ public ScanResult execute(Jedis connection) { @Override public ScanResult zscan(final String key, final String cursor) { - return new JedisClusterCommand>(connectionHandler, maxAttempts) { + return new JedisClusterCommand>(connectionHandler, maxAttempts, maxTotalRetriesDuration) { @Override public ScanResult execute(Jedis connection) { return connection.zscan(key, cursor); @@ -1794,7 +1819,7 @@ public ScanResult execute(Jedis connection) { @Override public Long pfadd(final String key, final String... elements) { - return new JedisClusterCommand(connectionHandler, maxAttempts) { + return new JedisClusterCommand(connectionHandler, maxAttempts, maxTotalRetriesDuration) { @Override public Long execute(Jedis connection) { return connection.pfadd(key, elements); @@ -1804,7 +1829,7 @@ public Long execute(Jedis connection) { @Override public long pfcount(final String key) { - return new JedisClusterCommand(connectionHandler, maxAttempts) { + return new JedisClusterCommand(connectionHandler, maxAttempts, maxTotalRetriesDuration) { @Override public Long execute(Jedis connection) { return connection.pfcount(key); @@ -1814,7 +1839,7 @@ public Long execute(Jedis connection) { @Override public Long del(final String... keys) { - return new JedisClusterCommand(connectionHandler, maxAttempts) { + return new JedisClusterCommand(connectionHandler, maxAttempts, maxTotalRetriesDuration) { @Override public Long execute(Jedis connection) { return connection.del(keys); @@ -1824,7 +1849,7 @@ public Long execute(Jedis connection) { @Override public String lmove(String srcKey, String dstKey, ListDirection from, ListDirection to) { - return new JedisClusterCommand(connectionHandler, maxAttempts) { + return new JedisClusterCommand(connectionHandler, maxAttempts, maxTotalRetriesDuration) { @Override public String execute(Jedis connection) { return connection.lmove(srcKey, dstKey, from, to); @@ -1835,7 +1860,7 @@ public String execute(Jedis connection) { @Override public String blmove(String srcKey, String dstKey, ListDirection from, ListDirection to, double timeout) { - return new JedisClusterCommand(connectionHandler, maxAttempts) { + return new JedisClusterCommand(connectionHandler, maxAttempts, maxTotalRetriesDuration) { @Override public String execute(Jedis connection) { return connection.blmove(srcKey, dstKey, from, to, timeout); @@ -1845,7 +1870,7 @@ public String execute(Jedis connection) { @Override public List blpop(final int timeout, final String... keys) { - return new JedisClusterCommand>(connectionHandler, maxAttempts) { + return new JedisClusterCommand>(connectionHandler, maxAttempts, maxTotalRetriesDuration) { @Override public List execute(Jedis connection) { return connection.blpop(timeout, keys); @@ -1856,7 +1881,7 @@ public List execute(Jedis connection) { @Override public KeyedListElement blpop(final double timeout, final String... keys) { - return new JedisClusterCommand(connectionHandler, maxAttempts) { + return new JedisClusterCommand(connectionHandler, maxAttempts, maxTotalRetriesDuration) { @Override public KeyedListElement execute(Jedis connection) { return connection.blpop(timeout, keys); @@ -1867,7 +1892,7 @@ public KeyedListElement execute(Jedis connection) { @Override public List brpop(final int timeout, final String... keys) { - return new JedisClusterCommand>(connectionHandler, maxAttempts) { + return new JedisClusterCommand>(connectionHandler, maxAttempts, maxTotalRetriesDuration) { @Override public List execute(Jedis connection) { return connection.brpop(timeout, keys); @@ -1877,7 +1902,7 @@ public List execute(Jedis connection) { @Override public KeyedListElement brpop(final double timeout, final String... keys) { - return new JedisClusterCommand(connectionHandler, maxAttempts) { + return new JedisClusterCommand(connectionHandler, maxAttempts, maxTotalRetriesDuration) { @Override public KeyedListElement execute(Jedis connection) { return connection.brpop(timeout, keys); @@ -1887,7 +1912,7 @@ public KeyedListElement execute(Jedis connection) { @Override public KeyedZSetElement bzpopmax(double timeout, String... keys) { - return new JedisClusterCommand(connectionHandler, maxAttempts) { + return new JedisClusterCommand(connectionHandler, maxAttempts, maxTotalRetriesDuration) { @Override public KeyedZSetElement execute(Jedis connection) { return connection.bzpopmax(timeout, keys); @@ -1897,7 +1922,7 @@ public KeyedZSetElement execute(Jedis connection) { @Override public KeyedZSetElement bzpopmin(double timeout, String... keys) { - return new JedisClusterCommand(connectionHandler, maxAttempts) { + return new JedisClusterCommand(connectionHandler, maxAttempts, maxTotalRetriesDuration) { @Override public KeyedZSetElement execute(Jedis connection) { return connection.bzpopmin(timeout, keys); @@ -1907,7 +1932,7 @@ public KeyedZSetElement execute(Jedis connection) { @Override public List blpop(final int timeout, final String key) { - return new JedisClusterCommand>(connectionHandler, maxAttempts) { + return new JedisClusterCommand>(connectionHandler, maxAttempts, maxTotalRetriesDuration) { @Override public List execute(Jedis connection) { return connection.blpop(timeout, key); @@ -1917,7 +1942,7 @@ public List execute(Jedis connection) { @Override public KeyedListElement blpop(double timeout, String key) { - return new JedisClusterCommand(connectionHandler, maxAttempts) { + return new JedisClusterCommand(connectionHandler, maxAttempts, maxTotalRetriesDuration) { @Override public KeyedListElement execute(Jedis connection) { return connection.blpop(timeout, key); @@ -1927,7 +1952,7 @@ public KeyedListElement execute(Jedis connection) { @Override public List brpop(final int timeout, final String key) { - return new JedisClusterCommand>(connectionHandler, maxAttempts) { + return new JedisClusterCommand>(connectionHandler, maxAttempts, maxTotalRetriesDuration) { @Override public List execute(Jedis connection) { return connection.brpop(timeout, key); @@ -1937,7 +1962,7 @@ public List execute(Jedis connection) { @Override public KeyedListElement brpop(double timeout, String key) { - return new JedisClusterCommand(connectionHandler, maxAttempts) { + return new JedisClusterCommand(connectionHandler, maxAttempts, maxTotalRetriesDuration) { @Override public KeyedListElement execute(Jedis connection) { return connection.brpop(timeout, key); @@ -1947,7 +1972,7 @@ public KeyedListElement execute(Jedis connection) { @Override public List mget(final String... keys) { - return new JedisClusterCommand>(connectionHandler, maxAttempts) { + return new JedisClusterCommand>(connectionHandler, maxAttempts, maxTotalRetriesDuration) { @Override public List execute(Jedis connection) { return connection.mget(keys); @@ -1963,7 +1988,7 @@ public String mset(final String... keysvalues) { keys[keyIdx] = keysvalues[keyIdx * 2]; } - return new JedisClusterCommand(connectionHandler, maxAttempts) { + return new JedisClusterCommand(connectionHandler, maxAttempts, maxTotalRetriesDuration) { @Override public String execute(Jedis connection) { return connection.mset(keysvalues); @@ -1979,7 +2004,7 @@ public Long msetnx(final String... keysvalues) { keys[keyIdx] = keysvalues[keyIdx * 2]; } - return new JedisClusterCommand(connectionHandler, maxAttempts) { + return new JedisClusterCommand(connectionHandler, maxAttempts, maxTotalRetriesDuration) { @Override public Long execute(Jedis connection) { return connection.msetnx(keysvalues); @@ -1989,7 +2014,7 @@ public Long execute(Jedis connection) { @Override public String rename(final String oldkey, final String newkey) { - return new JedisClusterCommand(connectionHandler, maxAttempts) { + return new JedisClusterCommand(connectionHandler, maxAttempts, maxTotalRetriesDuration) { @Override public String execute(Jedis connection) { return connection.rename(oldkey, newkey); @@ -1999,7 +2024,7 @@ public String execute(Jedis connection) { @Override public Long renamenx(final String oldkey, final String newkey) { - return new JedisClusterCommand(connectionHandler, maxAttempts) { + return new JedisClusterCommand(connectionHandler, maxAttempts, maxTotalRetriesDuration) { @Override public Long execute(Jedis connection) { return connection.renamenx(oldkey, newkey); @@ -2009,7 +2034,7 @@ public Long execute(Jedis connection) { @Override public String rpoplpush(final String srckey, final String dstkey) { - return new JedisClusterCommand(connectionHandler, maxAttempts) { + return new JedisClusterCommand(connectionHandler, maxAttempts, maxTotalRetriesDuration) { @Override public String execute(Jedis connection) { return connection.rpoplpush(srckey, dstkey); @@ -2019,7 +2044,7 @@ public String execute(Jedis connection) { @Override public Set sdiff(final String... keys) { - return new JedisClusterCommand>(connectionHandler, maxAttempts) { + return new JedisClusterCommand>(connectionHandler, maxAttempts, maxTotalRetriesDuration) { @Override public Set execute(Jedis connection) { return connection.sdiff(keys); @@ -2031,7 +2056,7 @@ public Set execute(Jedis connection) { public Long sdiffstore(final String dstkey, final String... keys) { String[] mergedKeys = KeyMergeUtil.merge(dstkey, keys); - return new JedisClusterCommand(connectionHandler, maxAttempts) { + return new JedisClusterCommand(connectionHandler, maxAttempts, maxTotalRetriesDuration) { @Override public Long execute(Jedis connection) { return connection.sdiffstore(dstkey, keys); @@ -2041,7 +2066,7 @@ public Long execute(Jedis connection) { @Override public Set sinter(final String... keys) { - return new JedisClusterCommand>(connectionHandler, maxAttempts) { + return new JedisClusterCommand>(connectionHandler, maxAttempts, maxTotalRetriesDuration) { @Override public Set execute(Jedis connection) { return connection.sinter(keys); @@ -2053,7 +2078,7 @@ public Set execute(Jedis connection) { public Long sinterstore(final String dstkey, final String... keys) { String[] mergedKeys = KeyMergeUtil.merge(dstkey, keys); - return new JedisClusterCommand(connectionHandler, maxAttempts) { + return new JedisClusterCommand(connectionHandler, maxAttempts, maxTotalRetriesDuration) { @Override public Long execute(Jedis connection) { return connection.sinterstore(dstkey, keys); @@ -2063,7 +2088,7 @@ public Long execute(Jedis connection) { @Override public Long smove(final String srckey, final String dstkey, final String member) { - return new JedisClusterCommand(connectionHandler, maxAttempts) { + return new JedisClusterCommand(connectionHandler, maxAttempts, maxTotalRetriesDuration) { @Override public Long execute(Jedis connection) { return connection.smove(srckey, dstkey, member); @@ -2073,7 +2098,7 @@ public Long execute(Jedis connection) { @Override public Long sort(final String key, final SortingParams sortingParameters, final String dstkey) { - return new JedisClusterCommand(connectionHandler, maxAttempts) { + return new JedisClusterCommand(connectionHandler, maxAttempts, maxTotalRetriesDuration) { @Override public Long execute(Jedis connection) { return connection.sort(key, sortingParameters, dstkey); @@ -2083,7 +2108,7 @@ public Long execute(Jedis connection) { @Override public Long sort(final String key, final String dstkey) { - return new JedisClusterCommand(connectionHandler, maxAttempts) { + return new JedisClusterCommand(connectionHandler, maxAttempts, maxTotalRetriesDuration) { @Override public Long execute(Jedis connection) { return connection.sort(key, dstkey); @@ -2093,7 +2118,7 @@ public Long execute(Jedis connection) { @Override public Set sunion(final String... keys) { - return new JedisClusterCommand>(connectionHandler, maxAttempts) { + return new JedisClusterCommand>(connectionHandler, maxAttempts, maxTotalRetriesDuration) { @Override public Set execute(Jedis connection) { return connection.sunion(keys); @@ -2105,7 +2130,7 @@ public Set execute(Jedis connection) { public Long sunionstore(final String dstkey, final String... keys) { String[] wholeKeys = KeyMergeUtil.merge(dstkey, keys); - return new JedisClusterCommand(connectionHandler, maxAttempts) { + return new JedisClusterCommand(connectionHandler, maxAttempts, maxTotalRetriesDuration) { @Override public Long execute(Jedis connection) { return connection.sunionstore(dstkey, keys); @@ -2115,7 +2140,7 @@ public Long execute(Jedis connection) { @Override public Set zinter(final ZParams params, final String... keys) { - return new JedisClusterCommand>(connectionHandler, maxAttempts) { + return new JedisClusterCommand>(connectionHandler, maxAttempts, maxTotalRetriesDuration) { @Override public Set execute(Jedis connection) { return connection.zinter(params, keys); @@ -2125,7 +2150,7 @@ public Set execute(Jedis connection) { @Override public Set zinterWithScores(final ZParams params, final String... keys) { - return new JedisClusterCommand>(connectionHandler, maxAttempts) { + return new JedisClusterCommand>(connectionHandler, maxAttempts, maxTotalRetriesDuration) { @Override public Set execute(Jedis connection) { return connection.zinterWithScores(params, keys); @@ -2137,7 +2162,7 @@ public Set execute(Jedis connection) { public Long zinterstore(final String dstkey, final String... sets) { String[] wholeKeys = KeyMergeUtil.merge(dstkey, sets); - return new JedisClusterCommand(connectionHandler, maxAttempts) { + return new JedisClusterCommand(connectionHandler, maxAttempts, maxTotalRetriesDuration) { @Override public Long execute(Jedis connection) { return connection.zinterstore(dstkey, sets); @@ -2149,7 +2174,7 @@ public Long execute(Jedis connection) { public Long zinterstore(final String dstkey, final ZParams params, final String... sets) { String[] mergedKeys = KeyMergeUtil.merge(dstkey, sets); - return new JedisClusterCommand(connectionHandler, maxAttempts) { + return new JedisClusterCommand(connectionHandler, maxAttempts, maxTotalRetriesDuration) { @Override public Long execute(Jedis connection) { return connection.zinterstore(dstkey, params, sets); @@ -2159,7 +2184,7 @@ public Long execute(Jedis connection) { @Override public Set zunion(final ZParams params, final String... keys) { - return new JedisClusterCommand>(connectionHandler, maxAttempts) { + return new JedisClusterCommand>(connectionHandler, maxAttempts, maxTotalRetriesDuration) { @Override public Set execute(Jedis connection) { return connection.zunion(params, keys); @@ -2169,7 +2194,7 @@ public Set execute(Jedis connection) { @Override public Set zunionWithScores(final ZParams params, final String... keys) { - return new JedisClusterCommand>(connectionHandler, maxAttempts) { + return new JedisClusterCommand>(connectionHandler, maxAttempts, maxTotalRetriesDuration) { @Override public Set execute(Jedis connection) { return connection.zunionWithScores(params, keys); @@ -2181,7 +2206,7 @@ public Set execute(Jedis connection) { public Long zunionstore(final String dstkey, final String... sets) { String[] mergedKeys = KeyMergeUtil.merge(dstkey, sets); - return new JedisClusterCommand(connectionHandler, maxAttempts) { + return new JedisClusterCommand(connectionHandler, maxAttempts, maxTotalRetriesDuration) { @Override public Long execute(Jedis connection) { return connection.zunionstore(dstkey, sets); @@ -2193,7 +2218,7 @@ public Long execute(Jedis connection) { public Long zunionstore(final String dstkey, final ZParams params, final String... sets) { String[] mergedKeys = KeyMergeUtil.merge(dstkey, sets); - return new JedisClusterCommand(connectionHandler, maxAttempts) { + return new JedisClusterCommand(connectionHandler, maxAttempts, maxTotalRetriesDuration) { @Override public Long execute(Jedis connection) { return connection.zunionstore(dstkey, params, sets); @@ -2203,7 +2228,7 @@ public Long execute(Jedis connection) { @Override public String brpoplpush(final String source, final String destination, final int timeout) { - return new JedisClusterCommand(connectionHandler, maxAttempts) { + return new JedisClusterCommand(connectionHandler, maxAttempts, maxTotalRetriesDuration) { @Override public String execute(Jedis connection) { return connection.brpoplpush(source, destination, timeout); @@ -2213,7 +2238,7 @@ public String execute(Jedis connection) { @Override public Long publish(final String channel, final String message) { - return new JedisClusterCommand(connectionHandler, maxAttempts) { + return new JedisClusterCommand(connectionHandler, maxAttempts, maxTotalRetriesDuration) { @Override public Long execute(Jedis connection) { return connection.publish(channel, message); @@ -2223,7 +2248,7 @@ public Long execute(Jedis connection) { @Override public void subscribe(final JedisPubSub jedisPubSub, final String... channels) { - new JedisClusterCommand(connectionHandler, maxAttempts) { + new JedisClusterCommand(connectionHandler, maxAttempts, maxTotalRetriesDuration) { @Override public Integer execute(Jedis connection) { connection.subscribe(jedisPubSub, channels); @@ -2234,7 +2259,7 @@ public Integer execute(Jedis connection) { @Override public void psubscribe(final JedisPubSub jedisPubSub, final String... patterns) { - new JedisClusterCommand(connectionHandler, maxAttempts) { + new JedisClusterCommand(connectionHandler, maxAttempts, maxTotalRetriesDuration) { @Override public Integer execute(Jedis connection) { connection.psubscribe(jedisPubSub, patterns); @@ -2247,7 +2272,7 @@ public Integer execute(Jedis connection) { public Long bitop(final BitOP op, final String destKey, final String... srcKeys) { String[] mergedKeys = KeyMergeUtil.merge(destKey, srcKeys); - return new JedisClusterCommand(connectionHandler, maxAttempts) { + return new JedisClusterCommand(connectionHandler, maxAttempts, maxTotalRetriesDuration) { @Override public Long execute(Jedis connection) { return connection.bitop(op, destKey, srcKeys); @@ -2259,7 +2284,7 @@ public Long execute(Jedis connection) { public String pfmerge(final String destkey, final String... sourcekeys) { String[] mergedKeys = KeyMergeUtil.merge(destkey, sourcekeys); - return new JedisClusterCommand(connectionHandler, maxAttempts) { + return new JedisClusterCommand(connectionHandler, maxAttempts, maxTotalRetriesDuration) { @Override public String execute(Jedis connection) { return connection.pfmerge(destkey, sourcekeys); @@ -2269,7 +2294,7 @@ public String execute(Jedis connection) { @Override public long pfcount(final String... keys) { - return new JedisClusterCommand(connectionHandler, maxAttempts) { + return new JedisClusterCommand(connectionHandler, maxAttempts, maxTotalRetriesDuration) { @Override public Long execute(Jedis connection) { return connection.pfcount(keys); @@ -2279,7 +2304,7 @@ public Long execute(Jedis connection) { @Override public Object eval(final String script, final int keyCount, final String... params) { - return new JedisClusterCommand(connectionHandler, maxAttempts) { + return new JedisClusterCommand(connectionHandler, maxAttempts, maxTotalRetriesDuration) { @Override public Object execute(Jedis connection) { return connection.eval(script, keyCount, params); @@ -2289,7 +2314,7 @@ public Object execute(Jedis connection) { @Override public Object eval(final String script, final String sampleKey) { - return new JedisClusterCommand(connectionHandler, maxAttempts) { + return new JedisClusterCommand(connectionHandler, maxAttempts, maxTotalRetriesDuration) { @Override public Object execute(Jedis connection) { return connection.eval(script); @@ -2299,7 +2324,7 @@ public Object execute(Jedis connection) { @Override public Object eval(final String script, final List keys, final List args) { - return new JedisClusterCommand(connectionHandler, maxAttempts) { + return new JedisClusterCommand(connectionHandler, maxAttempts, maxTotalRetriesDuration) { @Override public Object execute(Jedis connection) { return connection.eval(script, keys, args); @@ -2309,7 +2334,7 @@ public Object execute(Jedis connection) { @Override public Object evalsha(final String sha1, final int keyCount, final String... params) { - return new JedisClusterCommand(connectionHandler, maxAttempts) { + return new JedisClusterCommand(connectionHandler, maxAttempts, maxTotalRetriesDuration) { @Override public Object execute(Jedis connection) { return connection.evalsha(sha1, keyCount, params); @@ -2319,7 +2344,7 @@ public Object execute(Jedis connection) { @Override public Object evalsha(final String sha1, final List keys, final List args) { - return new JedisClusterCommand(connectionHandler, maxAttempts) { + return new JedisClusterCommand(connectionHandler, maxAttempts, maxTotalRetriesDuration) { @Override public Object execute(Jedis connection) { return connection.evalsha(sha1, keys, args); @@ -2329,7 +2354,7 @@ public Object execute(Jedis connection) { @Override public Object evalsha(final String sha1, final String sampleKey) { - return new JedisClusterCommand(connectionHandler, maxAttempts) { + return new JedisClusterCommand(connectionHandler, maxAttempts, maxTotalRetriesDuration) { @Override public Object execute(Jedis connection) { return connection.evalsha(sha1); @@ -2339,7 +2364,7 @@ public Object execute(Jedis connection) { @Override public Boolean scriptExists(final String sha1, final String sampleKey) { - return new JedisClusterCommand(connectionHandler, maxAttempts) { + return new JedisClusterCommand(connectionHandler, maxAttempts, maxTotalRetriesDuration) { @Override public Boolean execute(Jedis connection) { return connection.scriptExists(sha1); @@ -2349,7 +2374,7 @@ public Boolean execute(Jedis connection) { @Override public List scriptExists(final String sampleKey, final String... sha1) { - return new JedisClusterCommand>(connectionHandler, maxAttempts) { + return new JedisClusterCommand>(connectionHandler, maxAttempts, maxTotalRetriesDuration) { @Override public List execute(Jedis connection) { return connection.scriptExists(sha1); @@ -2359,7 +2384,7 @@ public List execute(Jedis connection) { @Override public String scriptLoad(final String script, final String sampleKey) { - return new JedisClusterCommand(connectionHandler, maxAttempts) { + return new JedisClusterCommand(connectionHandler, maxAttempts, maxTotalRetriesDuration) { @Override public String execute(Jedis connection) { return connection.scriptLoad(script); @@ -2369,7 +2394,7 @@ public String execute(Jedis connection) { @Override public String scriptFlush(final String sampleKey) { - return new JedisClusterCommand(connectionHandler, maxAttempts) { + return new JedisClusterCommand(connectionHandler, maxAttempts, maxTotalRetriesDuration) { @Override public String execute(Jedis connection) { return connection.scriptFlush(); @@ -2379,7 +2404,7 @@ public String execute(Jedis connection) { @Override public String scriptKill(final String sampleKey) { - return new JedisClusterCommand(connectionHandler, maxAttempts) { + return new JedisClusterCommand(connectionHandler, maxAttempts, maxTotalRetriesDuration) { @Override public String execute(Jedis connection) { return connection.scriptKill(); @@ -2390,7 +2415,7 @@ public String execute(Jedis connection) { @Override public Long geoadd(final String key, final double longitude, final double latitude, final String member) { - return new JedisClusterCommand(connectionHandler, maxAttempts) { + return new JedisClusterCommand(connectionHandler, maxAttempts, maxTotalRetriesDuration) { @Override public Long execute(Jedis connection) { return connection.geoadd(key, longitude, latitude, member); @@ -2400,7 +2425,7 @@ public Long execute(Jedis connection) { @Override public Long geoadd(final String key, final Map memberCoordinateMap) { - return new JedisClusterCommand(connectionHandler, maxAttempts) { + return new JedisClusterCommand(connectionHandler, maxAttempts, maxTotalRetriesDuration) { @Override public Long execute(Jedis connection) { return connection.geoadd(key, memberCoordinateMap); @@ -2410,7 +2435,7 @@ public Long execute(Jedis connection) { @Override public Long geoadd(String key, GeoAddParams params, Map memberCoordinateMap) { - return new JedisClusterCommand(connectionHandler, maxAttempts) { + return new JedisClusterCommand(connectionHandler, maxAttempts, maxTotalRetriesDuration) { @Override public Long execute(Jedis connection) { return connection.geoadd(key, params, memberCoordinateMap); @@ -2420,7 +2445,7 @@ public Long execute(Jedis connection) { @Override public Double geodist(final String key, final String member1, final String member2) { - return new JedisClusterCommand(connectionHandler, maxAttempts) { + return new JedisClusterCommand(connectionHandler, maxAttempts, maxTotalRetriesDuration) { @Override public Double execute(Jedis connection) { return connection.geodist(key, member1, member2); @@ -2431,7 +2456,7 @@ public Double execute(Jedis connection) { @Override public Double geodist(final String key, final String member1, final String member2, final GeoUnit unit) { - return new JedisClusterCommand(connectionHandler, maxAttempts) { + return new JedisClusterCommand(connectionHandler, maxAttempts, maxTotalRetriesDuration) { @Override public Double execute(Jedis connection) { return connection.geodist(key, member1, member2, unit); @@ -2441,7 +2466,7 @@ public Double execute(Jedis connection) { @Override public List geohash(final String key, final String... members) { - return new JedisClusterCommand>(connectionHandler, maxAttempts) { + return new JedisClusterCommand>(connectionHandler, maxAttempts, maxTotalRetriesDuration) { @Override public List execute(Jedis connection) { return connection.geohash(key, members); @@ -2451,7 +2476,7 @@ public List execute(Jedis connection) { @Override public List geopos(final String key, final String... members) { - return new JedisClusterCommand>(connectionHandler, maxAttempts) { + return new JedisClusterCommand>(connectionHandler, maxAttempts, maxTotalRetriesDuration) { @Override public List execute(Jedis connection) { return connection.geopos(key, members); @@ -2462,7 +2487,7 @@ public List execute(Jedis connection) { @Override public List georadius(final String key, final double longitude, final double latitude, final double radius, final GeoUnit unit) { - return new JedisClusterCommand>(connectionHandler, maxAttempts) { + return new JedisClusterCommand>(connectionHandler, maxAttempts, maxTotalRetriesDuration) { @Override public List execute(Jedis connection) { return connection.georadius(key, longitude, latitude, radius, unit); @@ -2473,7 +2498,7 @@ public List execute(Jedis connection) { @Override public List georadiusReadonly(final String key, final double longitude, final double latitude, final double radius, final GeoUnit unit) { - return new JedisClusterCommand>(connectionHandler, maxAttempts) { + return new JedisClusterCommand>(connectionHandler, maxAttempts, maxTotalRetriesDuration) { @Override public List execute(Jedis connection) { return connection.georadiusReadonly(key, longitude, latitude, radius, unit); @@ -2484,7 +2509,7 @@ public List execute(Jedis connection) { @Override public List georadius(final String key, final double longitude, final double latitude, final double radius, final GeoUnit unit, final GeoRadiusParam param) { - return new JedisClusterCommand>(connectionHandler, maxAttempts) { + return new JedisClusterCommand>(connectionHandler, maxAttempts, maxTotalRetriesDuration) { @Override public List execute(Jedis connection) { return connection.georadius(key, longitude, latitude, radius, unit, param); @@ -2497,7 +2522,7 @@ public Long georadiusStore(final String key, final double longitude, final doubl final double radius, final GeoUnit unit, final GeoRadiusParam param, final GeoRadiusStoreParam storeParam) { String[] keys = storeParam.getStringKeys(key); - return new JedisClusterCommand(connectionHandler, maxAttempts) { + return new JedisClusterCommand(connectionHandler, maxAttempts, maxTotalRetriesDuration) { @Override public Long execute(Jedis connection) { return connection.georadiusStore(key, longitude, latitude, radius, unit, param, storeParam); @@ -2508,7 +2533,7 @@ public Long execute(Jedis connection) { @Override public List georadiusReadonly(final String key, final double longitude, final double latitude, final double radius, final GeoUnit unit, final GeoRadiusParam param) { - return new JedisClusterCommand>(connectionHandler, maxAttempts) { + return new JedisClusterCommand>(connectionHandler, maxAttempts, maxTotalRetriesDuration) { @Override public List execute(Jedis connection) { return connection.georadiusReadonly(key, longitude, latitude, radius, unit, param); @@ -2519,7 +2544,7 @@ public List execute(Jedis connection) { @Override public List georadiusByMember(final String key, final String member, final double radius, final GeoUnit unit) { - return new JedisClusterCommand>(connectionHandler, maxAttempts) { + return new JedisClusterCommand>(connectionHandler, maxAttempts, maxTotalRetriesDuration) { @Override public List execute(Jedis connection) { return connection.georadiusByMember(key, member, radius, unit); @@ -2530,7 +2555,7 @@ public List execute(Jedis connection) { @Override public List georadiusByMemberReadonly(final String key, final String member, final double radius, final GeoUnit unit) { - return new JedisClusterCommand>(connectionHandler, maxAttempts) { + return new JedisClusterCommand>(connectionHandler, maxAttempts, maxTotalRetriesDuration) { @Override public List execute(Jedis connection) { return connection.georadiusByMemberReadonly(key, member, radius, unit); @@ -2541,7 +2566,7 @@ public List execute(Jedis connection) { @Override public List georadiusByMember(final String key, final String member, final double radius, final GeoUnit unit, final GeoRadiusParam param) { - return new JedisClusterCommand>(connectionHandler, maxAttempts) { + return new JedisClusterCommand>(connectionHandler, maxAttempts, maxTotalRetriesDuration) { @Override public List execute(Jedis connection) { return connection.georadiusByMember(key, member, radius, unit, param); @@ -2553,7 +2578,7 @@ public List execute(Jedis connection) { public Long georadiusByMemberStore(final String key, final String member, final double radius, final GeoUnit unit, final GeoRadiusParam param, final GeoRadiusStoreParam storeParam) { String[] keys = storeParam.getStringKeys(key); - return new JedisClusterCommand(connectionHandler, maxAttempts) { + return new JedisClusterCommand(connectionHandler, maxAttempts, maxTotalRetriesDuration) { @Override public Long execute(Jedis connection) { return connection.georadiusByMemberStore(key, member, radius, unit, param, storeParam); @@ -2564,7 +2589,7 @@ public Long execute(Jedis connection) { @Override public List georadiusByMemberReadonly(final String key, final String member, final double radius, final GeoUnit unit, final GeoRadiusParam param) { - return new JedisClusterCommand>(connectionHandler, maxAttempts) { + return new JedisClusterCommand>(connectionHandler, maxAttempts, maxTotalRetriesDuration) { @Override public List execute(Jedis connection) { return connection.georadiusByMemberReadonly(key, member, radius, unit, param); @@ -2574,7 +2599,7 @@ public List execute(Jedis connection) { @Override public List bitfield(final String key, final String... arguments) { - return new JedisClusterCommand>(connectionHandler, maxAttempts) { + return new JedisClusterCommand>(connectionHandler, maxAttempts, maxTotalRetriesDuration) { @Override public List execute(Jedis connection) { return connection.bitfield(key, arguments); @@ -2584,7 +2609,7 @@ public List execute(Jedis connection) { @Override public List bitfieldReadonly(final String key, final String... arguments) { - return new JedisClusterCommand>(connectionHandler, maxAttempts) { + return new JedisClusterCommand>(connectionHandler, maxAttempts, maxTotalRetriesDuration) { @Override public List execute(Jedis connection) { return connection.bitfieldReadonly(key, arguments); @@ -2594,7 +2619,7 @@ public List execute(Jedis connection) { @Override public Long hstrlen(final String key, final String field) { - return new JedisClusterCommand(connectionHandler, maxAttempts) { + return new JedisClusterCommand(connectionHandler, maxAttempts, maxTotalRetriesDuration) { @Override public Long execute(Jedis connection) { return connection.hstrlen(key, field); @@ -2604,7 +2629,7 @@ public Long execute(Jedis connection) { @Override public Long memoryUsage(final String key) { - return new JedisClusterCommand(connectionHandler, maxAttempts) { + return new JedisClusterCommand(connectionHandler, maxAttempts, maxTotalRetriesDuration) { @Override public Long execute(Jedis connection) { return connection.memoryUsage(key); @@ -2614,7 +2639,7 @@ public Long execute(Jedis connection) { @Override public Long memoryUsage(final String key, final int samples) { - return new JedisClusterCommand(connectionHandler, maxAttempts) { + return new JedisClusterCommand(connectionHandler, maxAttempts, maxTotalRetriesDuration) { @Override public Long execute(Jedis connection) { return connection.memoryUsage(key, samples); @@ -2624,7 +2649,7 @@ public Long execute(Jedis connection) { @Override public StreamEntryID xadd(final String key, final StreamEntryID id, final Map hash) { - return new JedisClusterCommand(connectionHandler, maxAttempts) { + return new JedisClusterCommand(connectionHandler, maxAttempts, maxTotalRetriesDuration) { @Override public StreamEntryID execute(Jedis connection) { return connection.xadd(key, id, hash); @@ -2635,7 +2660,7 @@ public StreamEntryID execute(Jedis connection) { @Override public StreamEntryID xadd(final String key, final StreamEntryID id, final Map hash, final long maxLen, final boolean approximateLength) { - return new JedisClusterCommand(connectionHandler, maxAttempts) { + return new JedisClusterCommand(connectionHandler, maxAttempts, maxTotalRetriesDuration) { @Override public StreamEntryID execute(Jedis connection) { return connection.xadd(key, id, hash, maxLen, approximateLength); @@ -2645,7 +2670,7 @@ public StreamEntryID execute(Jedis connection) { @Override public StreamEntryID xadd(final String key, final Map hash, final XAddParams params) { - return new JedisClusterCommand(connectionHandler, maxAttempts) { + return new JedisClusterCommand(connectionHandler, maxAttempts, maxTotalRetriesDuration) { @Override public StreamEntryID execute(Jedis connection) { return connection.xadd(key, hash, params); @@ -2655,7 +2680,7 @@ public StreamEntryID execute(Jedis connection) { @Override public Long xlen(final String key) { - return new JedisClusterCommand(connectionHandler, maxAttempts) { + return new JedisClusterCommand(connectionHandler, maxAttempts, maxTotalRetriesDuration) { @Override public Long execute(Jedis connection) { return connection.xlen(key); @@ -2666,7 +2691,7 @@ public Long execute(Jedis connection) { @Override public List xrange(final String key, final StreamEntryID start, final StreamEntryID end) { - return new JedisClusterCommand>(connectionHandler, maxAttempts) { + return new JedisClusterCommand>(connectionHandler, maxAttempts, maxTotalRetriesDuration) { @Override public List execute(Jedis connection) { return connection.xrange(key, start, end); @@ -2677,7 +2702,7 @@ public List execute(Jedis connection) { @Override public List xrange(final String key, final StreamEntryID start, final StreamEntryID end, final int count) { - return new JedisClusterCommand>(connectionHandler, maxAttempts) { + return new JedisClusterCommand>(connectionHandler, maxAttempts, maxTotalRetriesDuration) { @Override public List execute(Jedis connection) { return connection.xrange(key, start, end, count); @@ -2688,7 +2713,7 @@ public List execute(Jedis connection) { @Override public List xrevrange(final String key, final StreamEntryID end, final StreamEntryID start) { - return new JedisClusterCommand>(connectionHandler, maxAttempts) { + return new JedisClusterCommand>(connectionHandler, maxAttempts, maxTotalRetriesDuration) { @Override public List execute(Jedis connection) { return connection.xrevrange(key, end, start); @@ -2699,7 +2724,7 @@ public List execute(Jedis connection) { @Override public List xrevrange(final String key, final StreamEntryID end, final StreamEntryID start, final int count) { - return new JedisClusterCommand>(connectionHandler, maxAttempts) { + return new JedisClusterCommand>(connectionHandler, maxAttempts, maxTotalRetriesDuration) { @Override public List execute(Jedis connection) { return connection.xrevrange(key, end, start, count); @@ -2716,7 +2741,7 @@ public List>> xread(final int count, final long } return new JedisClusterCommand>>>(connectionHandler, - maxAttempts) { + maxAttempts, this.maxTotalRetriesDuration) { @Override public List>> execute(Jedis connection) { return connection.xread(count, block, streams); @@ -2726,7 +2751,7 @@ public List>> execute(Jedis connection) { @Override public List>> xread(final XReadParams xReadParams, final Map streams) { - return new JedisClusterCommand>>>(connectionHandler, maxAttempts) { + return new JedisClusterCommand>>>(connectionHandler, maxAttempts, maxTotalRetriesDuration) { @Override public List>> execute(Jedis connection) { return connection.xread(xReadParams, streams); @@ -2736,7 +2761,7 @@ public List>> execute(Jedis connection) { @Override public Long xack(final String key, final String group, final StreamEntryID... ids) { - return new JedisClusterCommand(connectionHandler, maxAttempts) { + return new JedisClusterCommand(connectionHandler, maxAttempts, maxTotalRetriesDuration) { @Override public Long execute(Jedis connection) { return connection.xack(key, group, ids); @@ -2747,7 +2772,7 @@ public Long execute(Jedis connection) { @Override public String xgroupCreate(final String key, final String groupname, final StreamEntryID id, final boolean makeStream) { - return new JedisClusterCommand(connectionHandler, maxAttempts) { + return new JedisClusterCommand(connectionHandler, maxAttempts, maxTotalRetriesDuration) { @Override public String execute(Jedis connection) { return connection.xgroupCreate(key, groupname, id, makeStream); @@ -2757,7 +2782,7 @@ public String execute(Jedis connection) { @Override public String xgroupSetID(final String key, final String groupname, final StreamEntryID id) { - return new JedisClusterCommand(connectionHandler, maxAttempts) { + return new JedisClusterCommand(connectionHandler, maxAttempts, maxTotalRetriesDuration) { @Override public String execute(Jedis connection) { return connection.xgroupSetID(key, groupname, id); @@ -2767,7 +2792,7 @@ public String execute(Jedis connection) { @Override public Long xgroupDestroy(final String key, final String groupname) { - return new JedisClusterCommand(connectionHandler, maxAttempts) { + return new JedisClusterCommand(connectionHandler, maxAttempts, maxTotalRetriesDuration) { @Override public Long execute(Jedis connection) { return connection.xgroupDestroy(key, groupname); @@ -2777,7 +2802,7 @@ public Long execute(Jedis connection) { @Override public Long xgroupDelConsumer(final String key, final String groupname, final String consumername) { - return new JedisClusterCommand(connectionHandler, maxAttempts) { + return new JedisClusterCommand(connectionHandler, maxAttempts, maxTotalRetriesDuration) { @Override public Long execute(Jedis connection) { return connection.xgroupDelConsumer(key, groupname, consumername); @@ -2796,7 +2821,7 @@ public List>> xreadGroup(final String groupname, } return new JedisClusterCommand>>>(connectionHandler, - maxAttempts) { + maxAttempts, this.maxTotalRetriesDuration) { @Override public List>> execute(Jedis connection) { return connection.xreadGroup(groupname, consumer, count, block, noAck, streams); @@ -2808,7 +2833,7 @@ public List>> execute(Jedis connection) { public List>> xreadGroup(final String groupname, final String consumer, final XReadGroupParams xReadGroupParams, final Map streams) { - return new JedisClusterCommand>>>(connectionHandler, maxAttempts) { + return new JedisClusterCommand>>>(connectionHandler, maxAttempts, maxTotalRetriesDuration) { @Override public List>> execute(Jedis connection) { return connection.xreadGroup(groupname, consumer, xReadGroupParams, streams); @@ -2818,7 +2843,7 @@ public List>> execute(Jedis connection) { @Override public StreamPendingSummary xpending(final String key, final String groupname) { - return new JedisClusterCommand(connectionHandler, maxAttempts) { + return new JedisClusterCommand(connectionHandler, maxAttempts, maxTotalRetriesDuration) { @Override public StreamPendingSummary execute(Jedis connection) { return connection.xpending(key, groupname); @@ -2829,7 +2854,7 @@ public StreamPendingSummary execute(Jedis connection) { @Override public List xpending(final String key, final String groupname, final StreamEntryID start, final StreamEntryID end, final int count, final String consumername) { - return new JedisClusterCommand>(connectionHandler, maxAttempts) { + return new JedisClusterCommand>(connectionHandler, maxAttempts, maxTotalRetriesDuration) { @Override public List execute(Jedis connection) { return connection.xpending(key, groupname, start, end, count, consumername); @@ -2839,7 +2864,7 @@ public List execute(Jedis connection) { @Override public List xpending(final String key, final String groupname, final XPendingParams params) { - return new JedisClusterCommand>(connectionHandler, maxAttempts) { + return new JedisClusterCommand>(connectionHandler, maxAttempts, maxTotalRetriesDuration) { @Override public List execute(Jedis connection) { return connection.xpending(key, groupname, params); @@ -2849,7 +2874,7 @@ public List execute(Jedis connection) { @Override public Long xdel(final String key, final StreamEntryID... ids) { - return new JedisClusterCommand(connectionHandler, maxAttempts) { + return new JedisClusterCommand(connectionHandler, maxAttempts, maxTotalRetriesDuration) { @Override public Long execute(Jedis connection) { return connection.xdel(key, ids); @@ -2859,7 +2884,7 @@ public Long execute(Jedis connection) { @Override public Long xtrim(final String key, final long maxLen, final boolean approximateLength) { - return new JedisClusterCommand(connectionHandler, maxAttempts) { + return new JedisClusterCommand(connectionHandler, maxAttempts, maxTotalRetriesDuration) { @Override public Long execute(Jedis connection) { return connection.xtrim(key, maxLen, approximateLength); @@ -2869,7 +2894,7 @@ public Long execute(Jedis connection) { @Override public Long xtrim(final String key, final XTrimParams params) { - return new JedisClusterCommand(connectionHandler, maxAttempts) { + return new JedisClusterCommand(connectionHandler, maxAttempts, maxTotalRetriesDuration) { @Override public Long execute(Jedis connection) { return connection.xtrim(key, params); @@ -2881,7 +2906,7 @@ public Long execute(Jedis connection) { public List xclaim(final String key, final String group, final String consumername, final long minIdleTime, final long newIdleTime, final int retries, final boolean force, final StreamEntryID... ids) { - return new JedisClusterCommand>(connectionHandler, maxAttempts) { + return new JedisClusterCommand>(connectionHandler, maxAttempts, maxTotalRetriesDuration) { @Override public List execute(Jedis connection) { return connection.xclaim(key, group, consumername, minIdleTime, newIdleTime, retries, @@ -2893,7 +2918,7 @@ public List execute(Jedis connection) { @Override public List xclaim(String key, String group, String consumername, long minIdleTime, XClaimParams params, StreamEntryID... ids) { - return new JedisClusterCommand>(connectionHandler, maxAttempts) { + return new JedisClusterCommand>(connectionHandler, maxAttempts, maxTotalRetriesDuration) { @Override public List execute(Jedis connection) { return connection.xclaim(key, group, consumername, minIdleTime, params, ids); @@ -2904,7 +2929,7 @@ public List execute(Jedis connection) { @Override public List xclaimJustId(String key, String group, String consumername, long minIdleTime, XClaimParams params, StreamEntryID... ids) { - return new JedisClusterCommand>(connectionHandler, maxAttempts) { + return new JedisClusterCommand>(connectionHandler, maxAttempts, maxTotalRetriesDuration) { @Override public List execute(Jedis connection) { return connection.xclaimJustId(key, group, consumername, minIdleTime, params, ids); @@ -2913,7 +2938,7 @@ public List execute(Jedis connection) { } public Long waitReplicas(final String key, final int replicas, final long timeout) { - return new JedisClusterCommand(connectionHandler, maxAttempts) { + return new JedisClusterCommand(connectionHandler, maxAttempts, maxTotalRetriesDuration) { @Override public Long execute(Jedis connection) { return connection.waitReplicas(replicas, timeout); @@ -2922,7 +2947,7 @@ public Long execute(Jedis connection) { } public Object sendCommand(final String sampleKey, final ProtocolCommand cmd, final String... args) { - return new JedisClusterCommand(connectionHandler, maxAttempts) { + return new JedisClusterCommand(connectionHandler, maxAttempts, maxTotalRetriesDuration) { @Override public Object execute(Jedis connection) { return connection.sendCommand(cmd, args); @@ -2932,7 +2957,7 @@ public Object execute(Jedis connection) { public Object sendBlockingCommand(final String sampleKey, final ProtocolCommand cmd, final String... args) { - return new JedisClusterCommand(connectionHandler, maxAttempts) { + return new JedisClusterCommand(connectionHandler, maxAttempts, maxTotalRetriesDuration) { @Override public Object execute(Jedis connection) { return connection.sendBlockingCommand(cmd, args); diff --git a/src/main/java/redis/clients/jedis/JedisClusterCommand.java b/src/main/java/redis/clients/jedis/JedisClusterCommand.java index ca007f9afd..6744000c34 100644 --- a/src/main/java/redis/clients/jedis/JedisClusterCommand.java +++ b/src/main/java/redis/clients/jedis/JedisClusterCommand.java @@ -1,5 +1,8 @@ package redis.clients.jedis; +import java.time.Duration; +import java.time.Instant; +import java.util.concurrent.TimeUnit; import org.slf4j.Logger; import org.slf4j.LoggerFactory; @@ -18,10 +21,22 @@ public abstract class JedisClusterCommand { private final JedisClusterConnectionHandler connectionHandler; private final int maxAttempts; + private final Duration maxTotalRetriesDuration; public JedisClusterCommand(JedisClusterConnectionHandler connectionHandler, int maxAttempts) { + this(connectionHandler, maxAttempts, Duration.ofMillis((long) BinaryJedisCluster.DEFAULT_TIMEOUT * maxAttempts)); + } + + /** + * @param connectionHandler + * @param maxAttempts + * @param maxTotalRetriesDuration No more attempts after we have been trying for this long. + */ + public JedisClusterCommand(JedisClusterConnectionHandler connectionHandler, int maxAttempts, + Duration maxTotalRetriesDuration) { this.connectionHandler = connectionHandler; this.maxAttempts = maxAttempts; + this.maxTotalRetriesDuration = maxTotalRetriesDuration; } public abstract T execute(Jedis connection); @@ -85,7 +100,10 @@ public T runWithAnyNode() { } private T runWithRetries(final int slot) { + Instant deadline = Instant.now().plus(maxTotalRetriesDuration); + JedisRedirectionException redirect = null; + int consecutiveConnectionFailures = 0; Exception lastException = null; for (int attemptsLeft = this.maxAttempts; attemptsLeft > 0; attemptsLeft--) { Jedis connection = null; @@ -106,15 +124,21 @@ private T runWithRetries(final int slot) { throw jnrcne; } catch (JedisConnectionException jce) { lastException = jce; + ++consecutiveConnectionFailures; LOG.debug("Failed connecting to Redis: {}", connection, jce); // "- 1" because we just did one, but the attemptsLeft counter hasn't been decremented yet - handleConnectionProblem(attemptsLeft - 1); + boolean reset = handleConnectionProblem(attemptsLeft - 1, consecutiveConnectionFailures, deadline); + if (reset) { + consecutiveConnectionFailures = 0; + redirect = null; + } } catch (JedisRedirectionException jre) { // avoid updating lastException if it is a connection exception if (lastException == null || lastException instanceof JedisRedirectionException) { lastException = jre; } LOG.debug("Redirected by server to {}", jre.getTargetNode()); + consecutiveConnectionFailures = 0; redirect = jre; // if MOVED redirection occurred, if (jre instanceof JedisMovedDataException) { @@ -124,6 +148,9 @@ private T runWithRetries(final int slot) { } finally { releaseConnection(connection); } + if (Instant.now().isAfter(deadline)) { + throw new JedisClusterOperationException("Cluster retry deadline exceeded."); + } } JedisClusterMaxAttemptsException maxAttemptsException @@ -132,14 +159,60 @@ private T runWithRetries(final int slot) { throw maxAttemptsException; } - private void handleConnectionProblem(int attemptsLeft) { - if (attemptsLeft <= 1) { - // We need this because if node is not reachable anymore - we need to finally initiate slots - // renewing, or we can stuck with cluster state without one node in opposite case. - // But now if maxAttempts = [1 or 2] we will do it too often. - // TODO make tracking of successful/unsuccessful operations for node - do renewing only - // if there were no successful responses from this node last few seconds - this.connectionHandler.renewSlotCache(); + /** + * Related values should be reset if TRUE is returned. + * + * @param attemptsLeft + * @param consecutiveConnectionFailures + * @param doneDeadline + * @return true - if some actions are taken + *
false - if no actions are taken + */ + private boolean handleConnectionProblem(int attemptsLeft, int consecutiveConnectionFailures, Instant doneDeadline) { + if (this.maxAttempts < 3) { + // Since we only renew the slots cache after two consecutive connection + // failures (see consecutiveConnectionFailures above), we need to special + // case the situation where we max out after two or fewer attempts. + // Otherwise, on two or fewer max attempts, the slots cache would never be + // renewed. + if (attemptsLeft == 0) { + this.connectionHandler.renewSlotCache(); + return true; + } + return false; + } + + if (consecutiveConnectionFailures < 2) { + return false; + } + + sleep(getBackoffSleepMillis(attemptsLeft, doneDeadline)); + //We need this because if node is not reachable anymore - we need to finally initiate slots + //renewing, or we can stuck with cluster state without one node in opposite case. + //TODO make tracking of successful/unsuccessful operations for node - do renewing only + //if there were no successful responses from this node last few seconds + this.connectionHandler.renewSlotCache(); + return true; + } + + private static long getBackoffSleepMillis(int attemptsLeft, Instant deadline) { + if (attemptsLeft <= 0) { + return 0; + } + + long millisLeft = Duration.between(Instant.now(), deadline).toMillis(); + if (millisLeft < 0) { + throw new JedisClusterOperationException("Cluster retry deadline exceeded."); + } + + return millisLeft / (attemptsLeft * (attemptsLeft + 1)); + } + + protected void sleep(long sleepMillis) { + try { + TimeUnit.MILLISECONDS.sleep(sleepMillis); + } catch (InterruptedException e) { + throw new JedisClusterOperationException(e); } } diff --git a/src/test/java/redis/clients/jedis/tests/JedisClusterCommandTest.java b/src/test/java/redis/clients/jedis/tests/JedisClusterCommandTest.java new file mode 100644 index 0000000000..1541ca9f86 --- /dev/null +++ b/src/test/java/redis/clients/jedis/tests/JedisClusterCommandTest.java @@ -0,0 +1,371 @@ +package redis.clients.jedis.tests; + +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertNotNull; +import static org.junit.Assert.assertTrue; +import static org.junit.Assert.fail; +import static org.mockito.ArgumentMatchers.any; +import static org.mockito.ArgumentMatchers.anyInt; +import static org.mockito.ArgumentMatchers.anyLong; +import static org.mockito.Mockito.doAnswer; +import static org.mockito.Mockito.inOrder; +import static org.mockito.Mockito.mock; +import static org.mockito.Mockito.times; +import static org.mockito.Mockito.when; + +import java.time.Duration; +import java.util.concurrent.atomic.AtomicLong; +import java.util.function.LongConsumer; +import org.junit.Test; +import org.mockito.InOrder; +import org.mockito.invocation.InvocationOnMock; +import org.mockito.stubbing.Answer; +import redis.clients.jedis.HostAndPort; +import redis.clients.jedis.Jedis; +import redis.clients.jedis.JedisClusterCommand; +import redis.clients.jedis.JedisClusterConnectionHandler; +import redis.clients.jedis.JedisSlotBasedConnectionHandler; +import redis.clients.jedis.exceptions.JedisAskDataException; +import redis.clients.jedis.exceptions.JedisClusterMaxAttemptsException; +import redis.clients.jedis.exceptions.JedisClusterOperationException; +import redis.clients.jedis.exceptions.JedisConnectionException; +import redis.clients.jedis.exceptions.JedisMovedDataException; +import redis.clients.jedis.exceptions.JedisNoReachableClusterNodeException; + +public class JedisClusterCommandTest { + + private static final Duration ONE_SECOND = Duration.ofSeconds(1); + + @Test + public void runSuccessfulExecute() { + JedisClusterConnectionHandler connectionHandler = mock(JedisClusterConnectionHandler.class); + JedisClusterCommand testMe = new JedisClusterCommand(connectionHandler, 10, + Duration.ZERO) { + @Override + public String execute(Jedis connection) { + return "foo"; + } + + @Override + protected void sleep(long ignored) { + throw new RuntimeException("This test should never sleep"); + } + }; + String actual = testMe.run(""); + assertEquals("foo", actual); + } + + @Test + public void runFailOnFirstExecSuccessOnSecondExec() { + JedisClusterConnectionHandler connectionHandler = mock(JedisClusterConnectionHandler.class); + + JedisClusterCommand testMe = new JedisClusterCommand(connectionHandler, 10, + ONE_SECOND) { + boolean isFirstCall = true; + + @Override + public String execute(Jedis connection) { + if (isFirstCall) { + isFirstCall = false; + throw new JedisConnectionException("Borkenz"); + } + + return "foo"; + } + + @Override + protected void sleep(long ignored) { + throw new RuntimeException("This test should never sleep"); + } + }; + + String actual = testMe.run(""); + assertEquals("foo", actual); + } + + @Test + public void runAlwaysFailing() { + JedisSlotBasedConnectionHandler connectionHandler = mock(JedisSlotBasedConnectionHandler.class); + + final LongConsumer sleep = mock(LongConsumer.class); + JedisClusterCommand testMe = new JedisClusterCommand(connectionHandler, 3, + ONE_SECOND) { + @Override + public String execute(Jedis connection) { + throw new JedisConnectionException("Connection failed"); + } + + @Override + protected void sleep(long sleepMillis) { + sleep.accept(sleepMillis); + } + }; + + try { + testMe.run(""); + fail("cluster command did not fail"); + } catch (JedisClusterMaxAttemptsException e) { + // expected + } + InOrder inOrder = inOrder(connectionHandler, sleep); + inOrder.verify(connectionHandler, times(2)).getConnectionFromSlot(anyInt()); + inOrder.verify(sleep).accept(anyLong()); + inOrder.verify(connectionHandler).renewSlotCache(); + inOrder.verify(connectionHandler).getConnectionFromSlot(anyInt()); + inOrder.verifyNoMoreInteractions(); + } + + @Test + public void runMovedSuccess() { + JedisSlotBasedConnectionHandler connectionHandler = mock(JedisSlotBasedConnectionHandler.class); + + final HostAndPort movedTarget = new HostAndPort(null, 0); + JedisClusterCommand testMe = new JedisClusterCommand(connectionHandler, 10, + ONE_SECOND) { + boolean isFirstCall = true; + + @Override + public String execute(Jedis connection) { + if (isFirstCall) { + isFirstCall = false; + + // Slot 0 moved + throw new JedisMovedDataException("", movedTarget, 0); + } + + return "foo"; + } + + @Override + protected void sleep(long ignored) { + throw new RuntimeException("This test should never sleep"); + } + }; + + String actual = testMe.run(""); + assertEquals("foo", actual); + + InOrder inOrder = inOrder(connectionHandler); + inOrder.verify(connectionHandler).getConnectionFromSlot(anyInt()); + inOrder.verify(connectionHandler).renewSlotCache(any()); + inOrder.verify(connectionHandler).getConnectionFromNode(movedTarget); + inOrder.verifyNoMoreInteractions(); + } + + @Test + public void runAskSuccess() { + JedisSlotBasedConnectionHandler connectionHandler = mock(JedisSlotBasedConnectionHandler.class); + Jedis connection = mock(Jedis.class); + final HostAndPort askTarget = new HostAndPort(null, 0); + when(connectionHandler.getConnectionFromNode(askTarget)).thenReturn(connection); + + JedisClusterCommand testMe = new JedisClusterCommand(connectionHandler, 10, + ONE_SECOND) { + boolean isFirstCall = true; + + @Override + public String execute(Jedis connection) { + if (isFirstCall) { + isFirstCall = false; + + // Slot 0 moved + throw new JedisAskDataException("", askTarget, 0); + } + + return "foo"; + } + + @Override + protected void sleep(long ignored) { + throw new RuntimeException("This test should never sleep"); + } + }; + + String actual = testMe.run(""); + assertEquals("foo", actual); + + InOrder inOrder = inOrder(connectionHandler, connection); + inOrder.verify(connectionHandler).getConnectionFromSlot(anyInt()); + inOrder.verify(connectionHandler).getConnectionFromNode(askTarget); + inOrder.verify(connection).asking(); + inOrder.verify(connection).close(); // From the finally clause in runWithRetries() + inOrder.verifyNoMoreInteractions(); + } + + @Test + public void runMovedThenAllNodesFailing() { + // Test: + // First attempt is a JedisMovedDataException() move, because we asked the wrong node. + // All subsequent attempts are JedisConnectionExceptions, because all nodes are now down. + // In response to the JedisConnectionExceptions, run() retries random nodes until maxAttempts is + // reached. + JedisSlotBasedConnectionHandler connectionHandler = mock(JedisSlotBasedConnectionHandler.class); + + final Jedis redirecter = mock(Jedis.class); + when(connectionHandler.getConnectionFromSlot(anyInt())).thenReturn(redirecter); + + final Jedis failer = mock(Jedis.class); + when(connectionHandler.getConnectionFromNode(any(HostAndPort.class))).thenReturn(failer); + doAnswer((Answer) (InvocationOnMock invocation) -> { + when(connectionHandler.getConnectionFromSlot(anyInt())).thenReturn(failer); + return null; + }).when(connectionHandler).renewSlotCache(); + + final LongConsumer sleep = mock(LongConsumer.class); + final HostAndPort movedTarget = new HostAndPort(null, 0); + JedisClusterCommand testMe = new JedisClusterCommand(connectionHandler, 5, + ONE_SECOND) { + @Override + public String execute(Jedis connection) { + if (redirecter == connection) { + // First attempt, report moved + throw new JedisMovedDataException("Moved", movedTarget, 0); + } + + if (failer == connection) { + // Second attempt in response to the move, report failure + throw new JedisConnectionException("Connection failed"); + } + + throw new IllegalStateException("Should have thrown jedis exception"); + } + + @Override + protected void sleep(long sleepMillis) { + sleep.accept(sleepMillis); + } + }; + + try { + testMe.run(""); + fail("cluster command did not fail"); + } catch (JedisClusterMaxAttemptsException e) { + // expected + } + InOrder inOrder = inOrder(connectionHandler, sleep); + inOrder.verify(connectionHandler).getConnectionFromSlot(anyInt()); + inOrder.verify(connectionHandler).renewSlotCache(redirecter); + inOrder.verify(connectionHandler, times(2)).getConnectionFromNode(movedTarget); + inOrder.verify(sleep).accept(anyLong()); + inOrder.verify(connectionHandler).renewSlotCache(); + inOrder.verify(connectionHandler, times(2)).getConnectionFromSlot(anyInt()); + inOrder.verify(sleep).accept(anyLong()); + inOrder.verify(connectionHandler).renewSlotCache(); + inOrder.verifyNoMoreInteractions(); + } + + @Test + public void runMasterFailingReplicaRecovering() { + // We have two nodes, master and replica, and master has just gone down permanently. + // + // Test: + // 1. We try to contact master => JedisConnectionException + // 2. We try to contact master => JedisConnectionException + // 3. sleep and renew + // 4. We try to contact replica => Success, because it has now failed over + + final Jedis master = mock(Jedis.class); + when(master.toString()).thenReturn("master"); + + final Jedis replica = mock(Jedis.class); + when(replica.toString()).thenReturn("replica"); + + JedisSlotBasedConnectionHandler connectionHandler = mock(JedisSlotBasedConnectionHandler.class); + + when(connectionHandler.getConnectionFromSlot(anyInt())).thenReturn(master); + + doAnswer((Answer) (InvocationOnMock invocation) -> { + when(connectionHandler.getConnectionFromSlot(anyInt())).thenReturn(replica); + return null; + }).when(connectionHandler).renewSlotCache(); + + final AtomicLong totalSleepMs = new AtomicLong(); + JedisClusterCommand testMe = new JedisClusterCommand(connectionHandler, 10, + ONE_SECOND) { + + @Override + public String execute(Jedis connection) { + assertNotNull(connection); + + if (connection == master) { + throw new JedisConnectionException("Master is down"); + } + + assert connection == replica; + + return "Success!"; + } + + @Override + protected void sleep(long sleepMillis) { + assert sleepMillis > 0; + totalSleepMs.addAndGet(sleepMillis); + } + }; + + assertEquals("Success!", testMe.run("")); + InOrder inOrder = inOrder(connectionHandler); + inOrder.verify(connectionHandler, times(2)).getConnectionFromSlot(anyInt()); + inOrder.verify(connectionHandler).renewSlotCache(); + inOrder.verify(connectionHandler).getConnectionFromSlot(anyInt()); + inOrder.verifyNoMoreInteractions(); + assertTrue(totalSleepMs.get() > 0); + } + + @Test(expected = JedisNoReachableClusterNodeException.class) + public void runRethrowsJedisNoReachableClusterNodeException() { + JedisSlotBasedConnectionHandler connectionHandler = mock(JedisSlotBasedConnectionHandler.class); + when(connectionHandler.getConnectionFromSlot(anyInt())).thenThrow( + JedisNoReachableClusterNodeException.class); + + JedisClusterCommand testMe = new JedisClusterCommand(connectionHandler, 10, + Duration.ZERO) { + @Override + public String execute(Jedis connection) { + return null; + } + + @Override + protected void sleep(long ignored) { + throw new RuntimeException("This test should never sleep"); + } + }; + + testMe.run(""); + } + + @Test + public void runStopsRetryingAfterTimeout() { + JedisSlotBasedConnectionHandler connectionHandler = mock(JedisSlotBasedConnectionHandler.class); + + final LongConsumer sleep = mock(LongConsumer.class); + JedisClusterCommand testMe = new JedisClusterCommand(connectionHandler, 3, + Duration.ZERO) { + @Override + public String execute(Jedis connection) { + try { + // exceed deadline + Thread.sleep(2L); + } catch (InterruptedException e) { + throw new RuntimeException(e); + } + throw new JedisConnectionException("Connection failed"); + } + + @Override + protected void sleep(long sleepMillis) { + sleep.accept(sleepMillis); + } + }; + + try { + testMe.run(""); + fail("cluster command did not fail"); + } catch (JedisClusterOperationException e) { + // expected + } + InOrder inOrder = inOrder(connectionHandler, sleep); + inOrder.verify(connectionHandler).getConnectionFromSlot(anyInt()); + inOrder.verifyNoMoreInteractions(); + } +} diff --git a/src/test/resources/log4j2.xml b/src/test/resources/log4j2.xml index 99bb2f0109..a3131034ce 100644 --- a/src/test/resources/log4j2.xml +++ b/src/test/resources/log4j2.xml @@ -3,7 +3,7 @@ - +