Make Jedis Cluster more likely to antirez's redis-rb-cluster

JedisClusterCommand

* improvements on connection error handling
** if based on slot connection throws connection related exception, retry to random node
** if we retry with random node, but all nodes are unreachable, throw JedisConnectionException without retry
** try to release connection whether connection is broken or not

* bug fix : if asking flag is on, and success this time, set asking flag to off

JedisClusterConnectionHandler

* have flexibility on initializing slots cache
** allow some nodes connection failure - skip
** if current node is success initializing slots cache, skip other nodes
** if current node failed to initialize slots cache, discard all discovered nodes and slots

* set nodes if node does not exist in nodes
** it restricts JedisPool to replace - prevent IllegalStateException : Returned object not currently part of this pool

JedisSlotBasedConnectionGuaranteedConnectionHandler

* getConnection (random connection)
** check all connections by random sequence
** always return valid connection (able to ping-pong)
** throw exception if all connections are invalid

* some refactoring
This commit is contained in:
Jungtaek Lim
2014-02-25 18:29:09 +09:00
parent e9cf469200
commit 882d662470
4 changed files with 196 additions and 41 deletions

View File

@@ -27,7 +27,7 @@ public class JedisCluster implements JedisCommands, BasicCommands {
public JedisCluster(Set<HostAndPort> jedisClusterNode, int timeout,
int maxRedirections) {
this.connectionHandler = new JedisSlotBasedConnectionHandler(
this.connectionHandler = new JedisSlotBasedConnectionGuaranteedConnectionHandler(
jedisClusterNode);
this.timeout = timeout;
this.maxRedirections = maxRedirections;