Add support for cluster reset command. Some tests were refactored per the inclusion of the new command
This commit is contained in:
@@ -8,6 +8,7 @@ import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Map.Entry;
|
||||
|
||||
import redis.clients.jedis.JedisCluster.Reset;
|
||||
import redis.clients.util.SafeEncoder;
|
||||
|
||||
public class Client extends BinaryClient implements Commands {
|
||||
@@ -911,6 +912,10 @@ public class Client extends BinaryClient implements Commands {
|
||||
cluster(Protocol.CLUSTER_MEET, ip, String.valueOf(port));
|
||||
}
|
||||
|
||||
public void clusterReset(Reset resetType) {
|
||||
cluster(Protocol.CLUSTER_RESET, resetType.toString());
|
||||
}
|
||||
|
||||
public void clusterAddSlots(final int... slots) {
|
||||
cluster(Protocol.CLUSTER_ADDSLOTS, slots);
|
||||
}
|
||||
|
||||
@@ -2,6 +2,8 @@ package redis.clients.jedis;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import redis.clients.jedis.JedisCluster.Reset;
|
||||
|
||||
public interface ClusterCommands {
|
||||
String clusterNodes();
|
||||
|
||||
@@ -40,4 +42,6 @@ public interface ClusterCommands {
|
||||
String clusterFailover();
|
||||
|
||||
List<Object> clusterSlots();
|
||||
|
||||
String clusterReset(Reset resetType);
|
||||
}
|
||||
|
||||
@@ -1,14 +1,22 @@
|
||||
package redis.clients.jedis;
|
||||
|
||||
import java.net.URI;
|
||||
import java.util.AbstractMap;
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashSet;
|
||||
import java.util.Iterator;
|
||||
import java.util.LinkedHashSet;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Map.Entry;
|
||||
import java.util.Set;
|
||||
|
||||
import redis.clients.jedis.BinaryClient.LIST_POSITION;
|
||||
import redis.clients.jedis.JedisCluster.Reset;
|
||||
import redis.clients.util.Pool;
|
||||
import redis.clients.util.SafeEncoder;
|
||||
import redis.clients.util.Slowlog;
|
||||
|
||||
import java.net.URI;
|
||||
import java.util.*;
|
||||
import java.util.Map.Entry;
|
||||
|
||||
public class Jedis extends BinaryJedis implements JedisCommands,
|
||||
MultiKeyCommands, AdvancedJedisCommands, ScriptingCommands,
|
||||
BasicCommands, ClusterCommands {
|
||||
@@ -3298,6 +3306,12 @@ public class Jedis extends BinaryJedis implements JedisCommands,
|
||||
client.clusterMeet(ip, port);
|
||||
return client.getStatusCodeReply();
|
||||
}
|
||||
|
||||
public String clusterReset(final Reset resetType) {
|
||||
checkIsInMulti();
|
||||
client.clusterReset(resetType);
|
||||
return client.getStatusCodeReply();
|
||||
}
|
||||
|
||||
public String clusterAddSlots(final int... slots) {
|
||||
checkIsInMulti();
|
||||
|
||||
@@ -14,6 +14,8 @@ public class JedisCluster implements JedisCommands, BasicCommands, Closeable {
|
||||
public static final short HASHSLOTS = 16384;
|
||||
private static final int DEFAULT_TIMEOUT = 1;
|
||||
private static final int DEFAULT_MAX_REDIRECTIONS = 5;
|
||||
|
||||
public static enum Reset {SOFT, HARD}
|
||||
|
||||
private int timeout;
|
||||
private int maxRedirections;
|
||||
|
||||
@@ -42,6 +42,7 @@ public final class Protocol {
|
||||
|
||||
public static final String CLUSTER_NODES = "nodes";
|
||||
public static final String CLUSTER_MEET = "meet";
|
||||
public static final String CLUSTER_RESET = "reset";
|
||||
public static final String CLUSTER_ADDSLOTS = "addslots";
|
||||
public static final String CLUSTER_DELSLOTS = "delslots";
|
||||
public static final String CLUSTER_INFO = "info";
|
||||
|
||||
Reference in New Issue
Block a user