use of redis.clients.jedis.HostAndPort in project jedis by xetorthio.
the class JedisClusterTest method testRedisClusterMaxRedirections.
@Test(expected = JedisClusterMaxRedirectionsException.class)
public void testRedisClusterMaxRedirections() {
Set<HostAndPort> jedisClusterNode = new HashSet<HostAndPort>();
jedisClusterNode.add(new HostAndPort("127.0.0.1", 7379));
JedisCluster jc = new JedisCluster(jedisClusterNode, DEFAULT_TIMEOUT, DEFAULT_TIMEOUT, DEFAULT_REDIRECTIONS, "cluster", DEFAULT_CONFIG);
int slot51 = JedisClusterCRC16.getSlot("51");
// This will cause an infinite redirection loop
node2.clusterSetSlotMigrating(slot51, JedisClusterTestUtil.getNodeId(node3.clusterNodes()));
jc.set("51", "foo");
}
use of redis.clients.jedis.HostAndPort in project jedis by xetorthio.
the class JedisClusterTest method testCalculateConnectionPerSlot.
@Test
public void testCalculateConnectionPerSlot() {
Set<HostAndPort> jedisClusterNode = new HashSet<HostAndPort>();
jedisClusterNode.add(new HostAndPort("127.0.0.1", 7379));
JedisCluster jc = new JedisCluster(jedisClusterNode, DEFAULT_TIMEOUT, DEFAULT_TIMEOUT, DEFAULT_REDIRECTIONS, "cluster", DEFAULT_CONFIG);
jc.set("foo", "bar");
jc.set("test", "test");
assertEquals("bar", node3.get("foo"));
assertEquals("test", node2.get("test"));
JedisCluster jc2 = new JedisCluster(new HostAndPort("127.0.0.1", 7379), DEFAULT_TIMEOUT, DEFAULT_TIMEOUT, DEFAULT_REDIRECTIONS, "cluster", DEFAULT_CONFIG);
jc2.set("foo", "bar");
jc2.set("test", "test");
assertEquals("bar", node3.get("foo"));
assertEquals("test", node2.get("test"));
}
use of redis.clients.jedis.HostAndPort in project jedis by xetorthio.
the class JedisClusterTest method testLocalhostNodeNotAddedWhen127Present.
@Test
public void testLocalhostNodeNotAddedWhen127Present() {
HostAndPort localhost = new HostAndPort("localhost", 7379);
Set<HostAndPort> jedisClusterNode = new HashSet<HostAndPort>();
// cluster node is defined as 127.0.0.1; adding localhost should work,
// but shouldn't show up.
jedisClusterNode.add(localhost);
JedisPoolConfig config = DEFAULT_CONFIG;
config.setMaxTotal(1);
JedisCluster jc = new JedisCluster(jedisClusterNode, 0, 2, DEFAULT_REDIRECTIONS, "cluster", DEFAULT_CONFIG);
Map<String, JedisPool> clusterNodes = jc.getClusterNodes();
assertEquals(3, clusterNodes.size());
assertFalse(clusterNodes.containsKey(JedisClusterInfoCache.getNodeKey(localhost)));
}
Aggregations