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:
@@ -1,10 +1,7 @@
|
||||
package redis.clients.jedis;
|
||||
|
||||
import java.util.Random;
|
||||
import java.util.Set;
|
||||
|
||||
import redis.clients.util.Pool;
|
||||
|
||||
public class JedisRandomConnectionHandler extends JedisClusterConnectionHandler {
|
||||
|
||||
|
||||
@@ -12,11 +9,12 @@ public class JedisRandomConnectionHandler extends JedisClusterConnectionHandler
|
||||
super(nodes);
|
||||
}
|
||||
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
public Jedis getConnection(String key) {
|
||||
Object[] nodeArray = nodes.values().toArray();
|
||||
return ((Pool<Jedis>) nodeArray[new Random().nextInt(nodeArray.length)]).getResource();
|
||||
public Jedis getConnection() {
|
||||
return getRandomConnection().getResource();
|
||||
}
|
||||
|
||||
@Override
|
||||
Jedis getConnectionFromSlot(int slot) {
|
||||
return getRandomConnection().getResource();
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user