Refactor redis cluster connection handler and add JedisAskDataException handling

This commit is contained in:
Marcos Nils
2013-12-20 15:28:32 -03:00
parent c008070045
commit 0bc27ac3a2
6 changed files with 66 additions and 50 deletions

View File

@@ -77,14 +77,13 @@ public class JedisClusterTest extends Assert {
node2.get("foo");
}
// @Test(expected=JedisAskDataException.class)
// public void ask() {
// node1.set("foo", "bar");
// int keySlot = RedisSlot.getSlot("foo");
// String node2Id = getNodeId(node2.clusterNodes());
// node1.clusterSetSlotMigrating(keySlot, node2Id);
// node1.get("foo");
// }
@Test(expected=JedisAskDataException.class)
public void ask() {
int keySlot = RedisSlot.getSlot("test");
String node2Id = getNodeId(node2.clusterNodes());
node1.clusterSetSlotMigrating(keySlot, node2Id);
node1.get("test");
}
private String getNodeId(String infoOutput) {
for (String infoLine : infoOutput.split("\n")) {

View File

@@ -22,4 +22,8 @@ public class RedisSlot {
return crc &= 0xffff % 16384;
}
public static void main(String[] args) {
System.out.println(getSlot("test"));
}
}