Search in sources :

Example 26 with JedisCluster

use of redis.clients.jedis.JedisCluster 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)));
}
Also used : HostAndPort(redis.clients.jedis.HostAndPort) JedisCluster(redis.clients.jedis.JedisCluster) JedisPool(redis.clients.jedis.JedisPool) JedisPoolConfig(redis.clients.jedis.JedisPoolConfig) HashSet(java.util.HashSet) LinkedHashSet(java.util.LinkedHashSet) Test(org.junit.Test)

Aggregations

JedisCluster (redis.clients.jedis.JedisCluster)26 HostAndPort (redis.clients.jedis.HostAndPort)23 Test (org.junit.Test)19 HashSet (java.util.HashSet)18 LinkedHashSet (java.util.LinkedHashSet)18 Jedis (redis.clients.jedis.Jedis)7 JedisPoolConfig (redis.clients.jedis.JedisPoolConfig)6 JedisPool (redis.clients.jedis.JedisPool)5 Before (org.junit.Before)4 IOException (java.io.IOException)2 ArrayList (java.util.ArrayList)2 ObjectMapper (com.fasterxml.jackson.databind.ObjectMapper)1 HeartbeatInfo (com.sohu.tv.cachecloud.client.basic.heartbeat.HeartbeatInfo)1 Map (java.util.Map)1 Random (java.util.Random)1 ExecutionException (java.util.concurrent.ExecutionException)1 Future (java.util.concurrent.Future)1 ThreadPoolExecutor (java.util.concurrent.ThreadPoolExecutor)1 GenericObjectPoolConfig (org.apache.commons.pool2.impl.GenericObjectPoolConfig)1 RedisClusterState (org.apache.storm.redis.trident.state.RedisClusterState)1