Launch 3 nodes on ports 7379 to 7381 with cluster enabled.
Add command CLUSTER NODES
This commit is contained in:
47
Makefile
47
Makefile
@@ -61,6 +61,7 @@ save ""
|
|||||||
appendonly no
|
appendonly no
|
||||||
endef
|
endef
|
||||||
|
|
||||||
|
# SENTINELS
|
||||||
define REDIS_SENTINEL1
|
define REDIS_SENTINEL1
|
||||||
port 26379
|
port 26379
|
||||||
daemonize yes
|
daemonize yes
|
||||||
@@ -97,6 +98,40 @@ pidfile /tmp/sentinel3.pid
|
|||||||
logfile /tmp/sentinel3.log
|
logfile /tmp/sentinel3.log
|
||||||
endef
|
endef
|
||||||
|
|
||||||
|
# CLUSTER REDIS NODES
|
||||||
|
define REDIS_CLUSTER_NODE1_CONF
|
||||||
|
daemonize yes
|
||||||
|
port 7379
|
||||||
|
pidfile /tmp/redis_cluster_node1.pid
|
||||||
|
logfile /tmp/redis_cluster_node1.log
|
||||||
|
save ""
|
||||||
|
appendonly no
|
||||||
|
cluster-enabled yes
|
||||||
|
cluster-config-file /tmp/redis_cluster_node1.conf
|
||||||
|
endef
|
||||||
|
|
||||||
|
define REDIS_CLUSTER_NODE2_CONF
|
||||||
|
daemonize yes
|
||||||
|
port 7380
|
||||||
|
pidfile /tmp/redis_cluster_node2.pid
|
||||||
|
logfile /tmp/redis_cluster_node2.log
|
||||||
|
save ""
|
||||||
|
appendonly no
|
||||||
|
cluster-enabled yes
|
||||||
|
cluster-config-file /tmp/redis_cluster_node2.conf
|
||||||
|
endef
|
||||||
|
|
||||||
|
define REDIS_CLUSTER_NODE3_CONF
|
||||||
|
daemonize yes
|
||||||
|
port 7381
|
||||||
|
pidfile /tmp/redis_cluster_node3.pid
|
||||||
|
logfile /tmp/redis_cluster_node3.log
|
||||||
|
save ""
|
||||||
|
appendonly no
|
||||||
|
cluster-enabled yes
|
||||||
|
cluster-config-file /tmp/redis_cluster_node3.conf
|
||||||
|
endef
|
||||||
|
|
||||||
export REDIS1_CONF
|
export REDIS1_CONF
|
||||||
export REDIS2_CONF
|
export REDIS2_CONF
|
||||||
export REDIS3_CONF
|
export REDIS3_CONF
|
||||||
@@ -106,6 +141,9 @@ export REDIS6_CONF
|
|||||||
export REDIS_SENTINEL1
|
export REDIS_SENTINEL1
|
||||||
export REDIS_SENTINEL2
|
export REDIS_SENTINEL2
|
||||||
export REDIS_SENTINEL3
|
export REDIS_SENTINEL3
|
||||||
|
export REDIS_CLUSTER_NODE1_CONF
|
||||||
|
export REDIS_CLUSTER_NODE2_CONF
|
||||||
|
export REDIS_CLUSTER_NODE3_CONF
|
||||||
|
|
||||||
start:
|
start:
|
||||||
echo "$$REDIS1_CONF" | redis-server -
|
echo "$$REDIS1_CONF" | redis-server -
|
||||||
@@ -119,6 +157,9 @@ start:
|
|||||||
echo "$$REDIS_SENTINEL2" > /tmp/sentinel2.conf && redis-server /tmp/sentinel2.conf --sentinel
|
echo "$$REDIS_SENTINEL2" > /tmp/sentinel2.conf && redis-server /tmp/sentinel2.conf --sentinel
|
||||||
@sleep 0.5
|
@sleep 0.5
|
||||||
echo "$$REDIS_SENTINEL3" > /tmp/sentinel3.conf && redis-server /tmp/sentinel3.conf --sentinel
|
echo "$$REDIS_SENTINEL3" > /tmp/sentinel3.conf && redis-server /tmp/sentinel3.conf --sentinel
|
||||||
|
echo "$$REDIS_CLUSTER_NODE1_CONF" | redis-server -
|
||||||
|
echo "$$REDIS_CLUSTER_NODE2_CONF" | redis-server -
|
||||||
|
echo "$$REDIS_CLUSTER_NODE3_CONF" | redis-server -
|
||||||
|
|
||||||
stop:
|
stop:
|
||||||
kill `cat /tmp/redis1.pid`
|
kill `cat /tmp/redis1.pid`
|
||||||
@@ -131,6 +172,12 @@ stop:
|
|||||||
kill `cat /tmp/sentinel1.pid`
|
kill `cat /tmp/sentinel1.pid`
|
||||||
kill `cat /tmp/sentinel2.pid`
|
kill `cat /tmp/sentinel2.pid`
|
||||||
kill `cat /tmp/sentinel3.pid`
|
kill `cat /tmp/sentinel3.pid`
|
||||||
|
kill `cat /tmp/redis_cluster_node1.pid` || true
|
||||||
|
kill `cat /tmp/redis_cluster_node2.pid` || true
|
||||||
|
kill `cat /tmp/redis_cluster_node3.pid` || true
|
||||||
|
rm -f /tmp/redis_cluster_node1.conf
|
||||||
|
rm -f /tmp/redis_cluster_node2.conf
|
||||||
|
rm -f /tmp/redis_cluster_node3.conf
|
||||||
|
|
||||||
test:
|
test:
|
||||||
make start
|
make start
|
||||||
|
|||||||
1
pom.xml
1
pom.xml
@@ -47,6 +47,7 @@
|
|||||||
<properties>
|
<properties>
|
||||||
<redis-hosts>localhost:6379,localhost:6380,localhost:6381,localhost:6382,localhost:6383,localhost:6384</redis-hosts>
|
<redis-hosts>localhost:6379,localhost:6380,localhost:6381,localhost:6382,localhost:6383,localhost:6384</redis-hosts>
|
||||||
<sentinel-hosts>localhost:26379,localhost:26380,localhost:26381</sentinel-hosts>
|
<sentinel-hosts>localhost:26379,localhost:26380,localhost:26381</sentinel-hosts>
|
||||||
|
<cluster-hosts>localhost:7379,localhost:7380,localhost:7381</cluster-hosts>
|
||||||
<github.global.server>github</github.global.server>
|
<github.global.server>github</github.global.server>
|
||||||
</properties>
|
</properties>
|
||||||
|
|
||||||
|
|||||||
@@ -1100,4 +1100,9 @@ public class BinaryClient extends Connection {
|
|||||||
public void hincrByFloat(final byte[] key, final byte[] field, double increment) {
|
public void hincrByFloat(final byte[] key, final byte[] field, double increment) {
|
||||||
sendCommand(HINCRBYFLOAT, key, field, toByteArray(increment));
|
sendCommand(HINCRBYFLOAT, key, field, toByteArray(increment));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void cluster(final byte[]... args) {
|
||||||
|
sendCommand(CLUSTER, args);
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -807,4 +807,12 @@ public class Client extends BinaryClient implements Commands {
|
|||||||
public void hincrByFloat(final String key, final String field, double increment) {
|
public void hincrByFloat(final String key, final String field, double increment) {
|
||||||
hincrByFloat(SafeEncoder.encode(key), SafeEncoder.encode(field), increment);
|
hincrByFloat(SafeEncoder.encode(key), SafeEncoder.encode(field), increment);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void cluster(final String... args) {
|
||||||
|
final byte[][] arg = new byte[args.length][];
|
||||||
|
for (int i = 0; i < arg.length; i++) {
|
||||||
|
arg[i] = SafeEncoder.encode(args[i]);
|
||||||
|
}
|
||||||
|
cluster(arg);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -3076,4 +3076,10 @@ public class Jedis extends BinaryJedis implements JedisCommands, MultiKeyCommand
|
|||||||
String relpy = client.getBulkReply();
|
String relpy = client.getBulkReply();
|
||||||
return (relpy != null ? new Double(relpy) : null);
|
return (relpy != null ? new Double(relpy) : null);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public String clusterNodes() {
|
||||||
|
checkIsInMulti();
|
||||||
|
client.cluster(Protocol.CLUSTER_NODES);
|
||||||
|
return client.getBulkReply();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -30,6 +30,8 @@ public final class Protocol {
|
|||||||
public static final String SENTINEL_RESET = "reset";
|
public static final String SENTINEL_RESET = "reset";
|
||||||
public static final String SENTINEL_SLAVES = "slaves";
|
public static final String SENTINEL_SLAVES = "slaves";
|
||||||
|
|
||||||
|
public static final String CLUSTER_NODES = "nodes";
|
||||||
|
|
||||||
private Protocol() {
|
private Protocol() {
|
||||||
// this prevent the class from instantiation
|
// this prevent the class from instantiation
|
||||||
}
|
}
|
||||||
@@ -155,7 +157,7 @@ public final class Protocol {
|
|||||||
|
|
||||||
public static enum Command {
|
public static enum Command {
|
||||||
PING, SET, GET, QUIT, EXISTS, DEL, TYPE, FLUSHDB, KEYS, RANDOMKEY, RENAME, RENAMENX, RENAMEX, DBSIZE, EXPIRE, EXPIREAT, TTL, SELECT, MOVE, FLUSHALL, GETSET, MGET, SETNX, SETEX, MSET, MSETNX, DECRBY, DECR, INCRBY, INCR, APPEND, SUBSTR, HSET, HGET, HSETNX, HMSET, HMGET, HINCRBY, HEXISTS, HDEL, HLEN, HKEYS, HVALS, HGETALL, RPUSH, LPUSH, LLEN, LRANGE, LTRIM, LINDEX, LSET, LREM, LPOP, RPOP, RPOPLPUSH, SADD, SMEMBERS, SREM, SPOP, SMOVE, SCARD, SISMEMBER, SINTER, SINTERSTORE, SUNION, SUNIONSTORE, SDIFF, SDIFFSTORE, SRANDMEMBER, ZADD, ZRANGE, ZREM, ZINCRBY, ZRANK, ZREVRANK, ZREVRANGE, ZCARD, ZSCORE, MULTI, DISCARD, EXEC, WATCH, UNWATCH, SORT, BLPOP, BRPOP, AUTH, SUBSCRIBE, PUBLISH, UNSUBSCRIBE, PSUBSCRIBE, PUNSUBSCRIBE, ZCOUNT, ZRANGEBYSCORE, ZREVRANGEBYSCORE, ZREMRANGEBYRANK, ZREMRANGEBYSCORE, ZUNIONSTORE, ZINTERSTORE, SAVE, BGSAVE, BGREWRITEAOF, LASTSAVE, SHUTDOWN, INFO, MONITOR, SLAVEOF, CONFIG, STRLEN, SYNC, LPUSHX, PERSIST, RPUSHX, ECHO, LINSERT, DEBUG, BRPOPLPUSH, SETBIT, GETBIT, SETRANGE, GETRANGE, EVAL, EVALSHA, SCRIPT, SLOWLOG, OBJECT, BITCOUNT, BITOP, SENTINEL,
|
PING, SET, GET, QUIT, EXISTS, DEL, TYPE, FLUSHDB, KEYS, RANDOMKEY, RENAME, RENAMENX, RENAMEX, DBSIZE, EXPIRE, EXPIREAT, TTL, SELECT, MOVE, FLUSHALL, GETSET, MGET, SETNX, SETEX, MSET, MSETNX, DECRBY, DECR, INCRBY, INCR, APPEND, SUBSTR, HSET, HGET, HSETNX, HMSET, HMGET, HINCRBY, HEXISTS, HDEL, HLEN, HKEYS, HVALS, HGETALL, RPUSH, LPUSH, LLEN, LRANGE, LTRIM, LINDEX, LSET, LREM, LPOP, RPOP, RPOPLPUSH, SADD, SMEMBERS, SREM, SPOP, SMOVE, SCARD, SISMEMBER, SINTER, SINTERSTORE, SUNION, SUNIONSTORE, SDIFF, SDIFFSTORE, SRANDMEMBER, ZADD, ZRANGE, ZREM, ZINCRBY, ZRANK, ZREVRANK, ZREVRANGE, ZCARD, ZSCORE, MULTI, DISCARD, EXEC, WATCH, UNWATCH, SORT, BLPOP, BRPOP, AUTH, SUBSCRIBE, PUBLISH, UNSUBSCRIBE, PSUBSCRIBE, PUNSUBSCRIBE, ZCOUNT, ZRANGEBYSCORE, ZREVRANGEBYSCORE, ZREMRANGEBYRANK, ZREMRANGEBYSCORE, ZUNIONSTORE, ZINTERSTORE, SAVE, BGSAVE, BGREWRITEAOF, LASTSAVE, SHUTDOWN, INFO, MONITOR, SLAVEOF, CONFIG, STRLEN, SYNC, LPUSHX, PERSIST, RPUSHX, ECHO, LINSERT, DEBUG, BRPOPLPUSH, SETBIT, GETBIT, SETRANGE, GETRANGE, EVAL, EVALSHA, SCRIPT, SLOWLOG, OBJECT, BITCOUNT, BITOP, SENTINEL,
|
||||||
DUMP, RESTORE, PEXPIRE, PEXPIREAT, PTTL, INCRBYFLOAT, PSETEX, CLIENT, TIME, MIGRATE, HINCRBYFLOAT;
|
DUMP, RESTORE, PEXPIRE, PEXPIREAT, PTTL, INCRBYFLOAT, PSETEX, CLIENT, TIME, MIGRATE, HINCRBYFLOAT, CLUSTER;
|
||||||
|
|
||||||
public final byte[] raw;
|
public final byte[] raw;
|
||||||
|
|
||||||
|
|||||||
@@ -9,83 +9,106 @@ import redis.clients.jedis.Protocol;
|
|||||||
public class HostAndPortUtil {
|
public class HostAndPortUtil {
|
||||||
private static List<HostAndPort> redisHostAndPortList = new ArrayList<HostAndPort>();
|
private static List<HostAndPort> redisHostAndPortList = new ArrayList<HostAndPort>();
|
||||||
private static List<HostAndPort> sentinelHostAndPortList = new ArrayList<HostAndPort>();
|
private static List<HostAndPort> sentinelHostAndPortList = new ArrayList<HostAndPort>();
|
||||||
|
private static List<HostAndPort> clusterHostAndPortList = new ArrayList<HostAndPort>();
|
||||||
|
|
||||||
static {
|
static {
|
||||||
|
|
||||||
HostAndPort defaulthnp1 = new HostAndPort("localhost", Protocol.DEFAULT_PORT);
|
|
||||||
redisHostAndPortList.add(defaulthnp1);
|
|
||||||
|
|
||||||
HostAndPort defaulthnp2 = new HostAndPort("localhost", Protocol.DEFAULT_PORT + 1);
|
HostAndPort defaulthnp1 = new HostAndPort("localhost",
|
||||||
redisHostAndPortList.add(defaulthnp2);
|
Protocol.DEFAULT_PORT);
|
||||||
|
redisHostAndPortList.add(defaulthnp1);
|
||||||
HostAndPort defaulthnp3 = new HostAndPort("localhost", Protocol.DEFAULT_PORT + 2);
|
|
||||||
redisHostAndPortList.add(defaulthnp3);
|
|
||||||
|
|
||||||
HostAndPort defaulthnp4 = new HostAndPort("localhost", Protocol.DEFAULT_PORT + 3);
|
|
||||||
redisHostAndPortList.add(defaulthnp4);
|
|
||||||
|
|
||||||
HostAndPort defaulthnp5 = new HostAndPort("localhost", Protocol.DEFAULT_PORT + 4);
|
|
||||||
redisHostAndPortList.add(defaulthnp5);
|
|
||||||
|
|
||||||
HostAndPort defaulthnp6 = new HostAndPort("localhost", Protocol.DEFAULT_PORT + 5);
|
|
||||||
redisHostAndPortList.add(defaulthnp6);
|
|
||||||
|
|
||||||
HostAndPort defaulthnp7 = new HostAndPort("localhost", Protocol.DEFAULT_SENTINEL_PORT);
|
|
||||||
sentinelHostAndPortList.add(defaulthnp7);
|
|
||||||
|
|
||||||
HostAndPort defaulthnp8 = new HostAndPort("localhost", Protocol.DEFAULT_SENTINEL_PORT + 1);
|
|
||||||
sentinelHostAndPortList.add(defaulthnp8);
|
|
||||||
|
|
||||||
HostAndPort defaulthnp9 = new HostAndPort("localhost", Protocol.DEFAULT_SENTINEL_PORT + 2);
|
|
||||||
sentinelHostAndPortList.add(defaulthnp9);
|
|
||||||
|
|
||||||
String envRedisHosts = System.getProperty("redis-hosts");
|
HostAndPort defaulthnp2 = new HostAndPort("localhost",
|
||||||
String envSentinelHosts = System.getProperty("sentinel-hosts");
|
Protocol.DEFAULT_PORT + 1);
|
||||||
|
redisHostAndPortList.add(defaulthnp2);
|
||||||
redisHostAndPortList = parseHosts(envRedisHosts, redisHostAndPortList);
|
|
||||||
sentinelHostAndPortList = parseHosts(envSentinelHosts, sentinelHostAndPortList);
|
HostAndPort defaulthnp3 = new HostAndPort("localhost",
|
||||||
|
Protocol.DEFAULT_PORT + 2);
|
||||||
|
redisHostAndPortList.add(defaulthnp3);
|
||||||
|
|
||||||
|
HostAndPort defaulthnp4 = new HostAndPort("localhost",
|
||||||
|
Protocol.DEFAULT_PORT + 3);
|
||||||
|
redisHostAndPortList.add(defaulthnp4);
|
||||||
|
|
||||||
|
HostAndPort defaulthnp5 = new HostAndPort("localhost",
|
||||||
|
Protocol.DEFAULT_PORT + 4);
|
||||||
|
redisHostAndPortList.add(defaulthnp5);
|
||||||
|
|
||||||
|
HostAndPort defaulthnp6 = new HostAndPort("localhost",
|
||||||
|
Protocol.DEFAULT_PORT + 5);
|
||||||
|
redisHostAndPortList.add(defaulthnp6);
|
||||||
|
|
||||||
|
HostAndPort defaulthnp7 = new HostAndPort("localhost",
|
||||||
|
Protocol.DEFAULT_SENTINEL_PORT);
|
||||||
|
sentinelHostAndPortList.add(defaulthnp7);
|
||||||
|
|
||||||
|
HostAndPort defaulthnp8 = new HostAndPort("localhost",
|
||||||
|
Protocol.DEFAULT_SENTINEL_PORT + 1);
|
||||||
|
sentinelHostAndPortList.add(defaulthnp8);
|
||||||
|
|
||||||
|
HostAndPort defaulthnp9 = new HostAndPort("localhost",
|
||||||
|
Protocol.DEFAULT_SENTINEL_PORT + 2);
|
||||||
|
sentinelHostAndPortList.add(defaulthnp9);
|
||||||
|
|
||||||
|
clusterHostAndPortList.add(new HostAndPort("localhost", 7379));
|
||||||
|
clusterHostAndPortList.add(new HostAndPort("localhost", 7380));
|
||||||
|
clusterHostAndPortList.add(new HostAndPort("localhost", 7381));
|
||||||
|
|
||||||
|
String envRedisHosts = System.getProperty("redis-hosts");
|
||||||
|
String envSentinelHosts = System.getProperty("sentinel-hosts");
|
||||||
|
String envClusterHosts = System.getProperty("cluster-hosts");
|
||||||
|
|
||||||
|
redisHostAndPortList = parseHosts(envRedisHosts, redisHostAndPortList);
|
||||||
|
sentinelHostAndPortList = parseHosts(envSentinelHosts,
|
||||||
|
sentinelHostAndPortList);
|
||||||
|
clusterHostAndPortList = parseHosts(envClusterHosts,
|
||||||
|
clusterHostAndPortList);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static List<HostAndPort> parseHosts(String envHosts, List<HostAndPort> existingHostsAndPorts) {
|
public static List<HostAndPort> parseHosts(String envHosts,
|
||||||
|
List<HostAndPort> existingHostsAndPorts) {
|
||||||
if (null != envHosts && 0 < envHosts.length()) {
|
|
||||||
|
if (null != envHosts && 0 < envHosts.length()) {
|
||||||
String[] hostDefs = envHosts.split(",");
|
|
||||||
|
String[] hostDefs = envHosts.split(",");
|
||||||
if (null != hostDefs && 2 <= hostDefs.length) {
|
|
||||||
|
if (null != hostDefs && 2 <= hostDefs.length) {
|
||||||
List<HostAndPort> envHostsAndPorts = new ArrayList<HostAndPort>(hostDefs.length);
|
|
||||||
|
List<HostAndPort> envHostsAndPorts = new ArrayList<HostAndPort>(
|
||||||
for (String hostDef : hostDefs) {
|
hostDefs.length);
|
||||||
|
|
||||||
String[] hostAndPort = hostDef.split(":");
|
for (String hostDef : hostDefs) {
|
||||||
|
|
||||||
if (null != hostAndPort && 2 == hostAndPort.length) {
|
String[] hostAndPort = hostDef.split(":");
|
||||||
String host = hostAndPort[0];
|
|
||||||
int port = Protocol.DEFAULT_PORT;
|
if (null != hostAndPort && 2 == hostAndPort.length) {
|
||||||
|
String host = hostAndPort[0];
|
||||||
try {
|
int port = Protocol.DEFAULT_PORT;
|
||||||
port = Integer.parseInt(hostAndPort[1]);
|
|
||||||
} catch (final NumberFormatException nfe) {
|
try {
|
||||||
}
|
port = Integer.parseInt(hostAndPort[1]);
|
||||||
|
} catch (final NumberFormatException nfe) {
|
||||||
envHostsAndPorts.add(new HostAndPort(host, port));
|
}
|
||||||
}
|
|
||||||
}
|
envHostsAndPorts.add(new HostAndPort(host, port));
|
||||||
|
}
|
||||||
return envHostsAndPorts;
|
}
|
||||||
}
|
|
||||||
}
|
return envHostsAndPorts;
|
||||||
|
}
|
||||||
return existingHostsAndPorts;
|
}
|
||||||
|
|
||||||
|
return existingHostsAndPorts;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static List<HostAndPort> getRedisServers() {
|
public static List<HostAndPort> getRedisServers() {
|
||||||
return redisHostAndPortList;
|
return redisHostAndPortList;
|
||||||
}
|
|
||||||
|
|
||||||
public static List<HostAndPort> getSentinelServers() {
|
|
||||||
return sentinelHostAndPortList;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static List<HostAndPort> getSentinelServers() {
|
||||||
|
return sentinelHostAndPortList;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static List<HostAndPort> getClusterServers() {
|
||||||
|
return clusterHostAndPortList;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -0,0 +1,41 @@
|
|||||||
|
package redis.clients.jedis.tests.commands;
|
||||||
|
|
||||||
|
import org.junit.After;
|
||||||
|
import org.junit.Before;
|
||||||
|
import org.junit.Test;
|
||||||
|
|
||||||
|
import redis.clients.jedis.HostAndPort;
|
||||||
|
import redis.clients.jedis.Jedis;
|
||||||
|
import redis.clients.jedis.tests.HostAndPortUtil;
|
||||||
|
import redis.clients.jedis.tests.JedisTestBase;
|
||||||
|
|
||||||
|
public class ClusterCommandsTest extends JedisTestBase {
|
||||||
|
private Jedis node1;
|
||||||
|
private Jedis node2;
|
||||||
|
|
||||||
|
@Before
|
||||||
|
public void setUp() throws Exception {
|
||||||
|
HostAndPort nodeInfo1 = HostAndPortUtil.getClusterServers().get(0);
|
||||||
|
HostAndPort nodeInfo2 = HostAndPortUtil.getClusterServers().get(1);
|
||||||
|
|
||||||
|
node1 = new Jedis(nodeInfo1.getHost(), nodeInfo1.getPort());
|
||||||
|
node1.connect();
|
||||||
|
node1.flushAll();
|
||||||
|
|
||||||
|
node2 = new Jedis(nodeInfo2.getHost(), nodeInfo2.getPort());
|
||||||
|
node2.connect();
|
||||||
|
node2.flushAll();
|
||||||
|
}
|
||||||
|
|
||||||
|
@After
|
||||||
|
public void tearDown() {
|
||||||
|
node1.disconnect();
|
||||||
|
node2.disconnect();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void clusterNodes() {
|
||||||
|
String nodes = node1.clusterNodes();
|
||||||
|
assertEquals(1, nodes.split("\n").length);
|
||||||
|
}
|
||||||
|
}
|
||||||
Reference in New Issue
Block a user