Refactor redis cluster connection handler and add JedisAskDataException handling
This commit is contained in:
@@ -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")) {
|
||||
|
||||
@@ -22,4 +22,8 @@ public class RedisSlot {
|
||||
return crc &= 0xffff % 16384;
|
||||
}
|
||||
|
||||
public static void main(String[] args) {
|
||||
System.out.println(getSlot("test"));
|
||||
}
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user