Add slot based connection which routes requests according to key slot

This commit is contained in:
Marcos Nils
2013-12-28 00:59:35 -03:00
parent 9f767a0848
commit b2d22e2060
6 changed files with 186 additions and 136 deletions

View File

@@ -4,11 +4,8 @@ public class JedisClusterCRC16 {
public final static int polynomial = 0x1021; // Represents x^16+x^12+x^5+1
static int crc;
public JedisClusterCRC16(){
crc = 0x0000;
}
public static int getSlot(String key) {
crc = 0x0000;
for (byte b : key.getBytes()) {
for (int i = 0; i < 8; i++) {
boolean bit = ((b >> (7-i) & 1) == 1);
@@ -21,9 +18,4 @@ public class JedisClusterCRC16 {
return crc &= 0xffff % 16384;
}
public static void main(String[] args) {
System.out.println(getSlot("test"));
}
}