Renew slots when MOVED occured during request to Cluster

* It's suggested by http://redis.io/topics/cluster-spec
** antirez/redis-rb-cluster implementation does it, too
* Since Redis 3.0-beta 7 introduces CLUSTER SLOTS, it becomes easier
* FIXME: It's fully synchronized, so it hurts performance (somewhat poor implementation)
** We can try Reader / Writer strategy to make lock waiting make shorter
This commit is contained in:
Jungtaek Lim
2014-07-02 23:29:30 +09:00
parent b7b10df0a1
commit 94966e6163
4 changed files with 174 additions and 93 deletions

View File

@@ -72,13 +72,15 @@ public abstract class JedisClusterCommand<T> {
} catch (JedisRedirectionException jre) {
if (jre instanceof JedisAskDataException) {
asking = true;
} else if (jre instanceof JedisMovedDataException) {
// TODO : In antirez's redis-rb-cluster implementation,
// it rebuilds cluster's slot and node cache
}
this.connectionHandler.assignSlotToNode(jre.getSlot(),
jre.getTargetNode());
this.connectionHandler.assignSlotToNode(jre.getSlot(),
jre.getTargetNode());
} else if (jre instanceof JedisMovedDataException) {
// it rebuilds cluster's slot cache
// recommended by Redis cluster specification
this.connectionHandler.renewSlotCache();
} else {
throw new JedisClusterException(jre);
}
releaseConnection(connection, false);
connection = null;