Skip to content

Commit

Permalink
NXP-18884: Add retry logic to default Redis pool
Browse files Browse the repository at this point in the history
  • Loading branch information
bdelbosc committed Feb 2, 2016
1 parent e02d24d commit 335210c
Showing 1 changed file with 5 additions and 2 deletions.
Expand Up @@ -22,7 +22,6 @@
import org.nuxeo.common.xmap.annotation.XNode;
import org.nuxeo.common.xmap.annotation.XObject;
import org.nuxeo.ecm.core.api.NuxeoException;

import redis.clients.jedis.Jedis;
import redis.clients.jedis.JedisPool;
import redis.clients.jedis.JedisPoolConfig;
Expand All @@ -45,6 +44,9 @@ public class RedisServerDescriptor extends RedisPoolDescriptor {
@XNode("port")
public int port = Protocol.DEFAULT_PORT;

@XNode("failoverTimeout")
public int failoverTimeout = 300;

protected boolean canConnect(String name, int port) {
try (Jedis jedis = new Jedis(name, port)) {
if (StringUtils.isNotBlank(password)) {
Expand Down Expand Up @@ -72,8 +74,9 @@ public RedisExecutor newExecutor() {
JedisPoolConfig conf = new JedisPoolConfig();
conf.setMaxTotal(maxTotal);
conf.setMaxIdle(maxIdle);
return new RedisPoolExecutor(new JedisPool(conf, host, port, timeout,
RedisExecutor base = new RedisPoolExecutor(new JedisPool(conf, host, port, timeout,
StringUtils.defaultIfBlank(password, null), database));
return new RedisFailoverExecutor(failoverTimeout, base);
}

}

0 comments on commit 335210c

Please sign in to comment.