Several changes have been added to this commit:

- Add asking to cluster commands
- Make jedis cluster return connection to original pool
- Add tests for MOVED and ASK cluster responses
- Refactor connection handler to recalculate connections based on slots

This commit makes the first usable version of Jedis along with Redis Cluster
This commit is contained in:
Marcos Nils
2014-01-03 16:42:21 -03:00
parent 1b26815799
commit dd0bbdaf91
10 changed files with 349 additions and 265 deletions

View File

@@ -13,6 +13,7 @@ import redis.clients.jedis.Jedis;
import redis.clients.jedis.JedisCluster;
import redis.clients.jedis.Pipeline;
import redis.clients.jedis.exceptions.JedisAskDataException;
import redis.clients.jedis.exceptions.JedisClusterException;
import redis.clients.jedis.exceptions.JedisMovedDataException;
import redis.clients.jedis.tests.utils.JedisClusterCRC16;
@@ -39,7 +40,7 @@ public class JedisClusterTest extends Assert {
node3.connect();
node3.flushAll();
// ---- configure cluster
// ---- configure cluster
// add nodes to cluster
node1.clusterMeet("127.0.0.1", nodeInfo1.getPort());
@@ -148,6 +149,14 @@ public class JedisClusterTest extends Assert {
assertEquals("foo", jc.get("51"));
}
@Test(expected=JedisClusterException.class)
public void testThrowExceptionWithoutKey() {
Set<HostAndPort> jedisClusterNode = new HashSet<HostAndPort>();
jedisClusterNode.add(new HostAndPort("127.0.0.1", 7379));
JedisCluster jc = new JedisCluster(jedisClusterNode);
jc.ping();
}
private String getNodeId(String infoOutput) {
for (String infoLine : infoOutput.split("\n")) {
if (infoLine.contains("myself")) {