Implement all Jedis cluster commands and rename RedisSlot class
This commit is contained in:
File diff suppressed because it is too large
Load Diff
@@ -1,5 +1,6 @@
|
|||||||
package redis.clients.jedis;
|
package redis.clients.jedis;
|
||||||
|
|
||||||
|
import redis.clients.jedis.exceptions.JedisAskDataException;
|
||||||
import redis.clients.jedis.exceptions.JedisMovedDataException;
|
import redis.clients.jedis.exceptions.JedisMovedDataException;
|
||||||
|
|
||||||
public abstract class JedisClusterCommand<T> {
|
public abstract class JedisClusterCommand<T> {
|
||||||
@@ -15,8 +16,10 @@ public abstract class JedisClusterCommand<T> {
|
|||||||
public T run() {
|
public T run() {
|
||||||
try {
|
try {
|
||||||
return execute();
|
return execute();
|
||||||
} catch (JedisMovedDataException e) {
|
} catch (JedisMovedDataException jme) {
|
||||||
//TODO: Retry here
|
//TODO: Do Retry here
|
||||||
|
} catch (JedisAskDataException jae) {
|
||||||
|
//TODO: Do ASK here
|
||||||
}
|
}
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -11,7 +11,7 @@ import redis.clients.jedis.JedisCluster;
|
|||||||
import redis.clients.jedis.Pipeline;
|
import redis.clients.jedis.Pipeline;
|
||||||
import redis.clients.jedis.exceptions.JedisAskDataException;
|
import redis.clients.jedis.exceptions.JedisAskDataException;
|
||||||
import redis.clients.jedis.exceptions.JedisMovedDataException;
|
import redis.clients.jedis.exceptions.JedisMovedDataException;
|
||||||
import redis.clients.jedis.tests.utils.RedisSlot;
|
import redis.clients.jedis.tests.utils.JedisClusterCRC16;
|
||||||
|
|
||||||
public class JedisClusterTest extends Assert {
|
public class JedisClusterTest extends Assert {
|
||||||
private Jedis node1;
|
private Jedis node1;
|
||||||
@@ -78,8 +78,8 @@ public class JedisClusterTest extends Assert {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Test(expected=JedisAskDataException.class)
|
@Test(expected=JedisAskDataException.class)
|
||||||
public void ask() {
|
public void throwAskExceptionTest() {
|
||||||
int keySlot = RedisSlot.getSlot("test");
|
int keySlot = JedisClusterCRC16.getSlot("test");
|
||||||
String node2Id = getNodeId(node2.clusterNodes());
|
String node2Id = getNodeId(node2.clusterNodes());
|
||||||
node1.clusterSetSlotMigrating(keySlot, node2Id);
|
node1.clusterSetSlotMigrating(keySlot, node2Id);
|
||||||
node1.get("test");
|
node1.get("test");
|
||||||
|
|||||||
@@ -1,10 +1,10 @@
|
|||||||
package redis.clients.jedis.tests.utils;
|
package redis.clients.jedis.tests.utils;
|
||||||
|
|
||||||
public class RedisSlot {
|
public class JedisClusterCRC16 {
|
||||||
public final static int polynomial = 0x1021; // Represents x^16+x^12+x^5+1
|
public final static int polynomial = 0x1021; // Represents x^16+x^12+x^5+1
|
||||||
static int crc;
|
static int crc;
|
||||||
|
|
||||||
public RedisSlot(){
|
public JedisClusterCRC16(){
|
||||||
crc = 0x0000;
|
crc = 0x0000;
|
||||||
}
|
}
|
||||||
|
|
||||||
Reference in New Issue
Block a user