Search in sources :

Example 16 with HostAndPort

use of redis.clients.jedis.HostAndPort in project incubator-skywalking by apache.

the class JedisClusterConstructorWithHostAndPortArgInterceptor method onConstruct.

@Override
public void onConstruct(EnhancedInstance objInst, Object[] allArguments) {
    HostAndPort hostAndPort = (HostAndPort) allArguments[0];
    objInst.setSkyWalkingDynamicField(hostAndPort.getHost() + ":" + hostAndPort.getPort());
}
Also used : HostAndPort(redis.clients.jedis.HostAndPort)

Example 17 with HostAndPort

use of redis.clients.jedis.HostAndPort in project incubator-skywalking by apache.

the class JedisClusterConstructorWithListHostAndPortArgInterceptor method onConstruct.

@Override
public void onConstruct(EnhancedInstance objInst, Object[] allArguments) {
    StringBuilder redisConnInfo = new StringBuilder();
    Set<HostAndPort> hostAndPorts = (Set<HostAndPort>) allArguments[0];
    for (HostAndPort hostAndPort : hostAndPorts) {
        redisConnInfo.append(hostAndPort.toString()).append(";");
    }
    objInst.setSkyWalkingDynamicField(redisConnInfo.toString());
}
Also used : HostAndPort(redis.clients.jedis.HostAndPort) Set(java.util.Set)

Example 18 with HostAndPort

use of redis.clients.jedis.HostAndPort in project new-cloud by xie-summer.

the class JedisClusterNodeInformationParserTest method testParseNormalState.

@Test
public void testParseNormalState() {
    String nodeInfo = "5f4a2236d00008fba7ac0dd24b95762b446767bd 192.168.0.3:7380 master - 0 1400598804016 2 connected 5461-10922";
    HostAndPort current = new HostAndPort("localhost", 7379);
    ClusterNodeInformation clusterNodeInfo = parser.parse(nodeInfo, current);
    assertNotEquals(clusterNodeInfo.getNode(), current);
    assertEquals(clusterNodeInfo.getNode(), new HostAndPort("192.168.0.3", 7380));
    for (int slot = 5461; slot <= 10922; slot++) {
        assertTrue(clusterNodeInfo.getAvailableSlots().contains(slot));
    }
    assertTrue(clusterNodeInfo.getSlotsBeingImported().isEmpty());
    assertTrue(clusterNodeInfo.getSlotsBeingMigrated().isEmpty());
}
Also used : HostAndPort(redis.clients.jedis.HostAndPort) ClusterNodeInformation(redis.clients.util.ClusterNodeInformation) Test(org.junit.Test)

Example 19 with HostAndPort

use of redis.clients.jedis.HostAndPort in project new-cloud by xie-summer.

the class JedisClusterNodeInformationParserTest method testParseSlotBeingMigrated.

@Test
public void testParseSlotBeingMigrated() {
    String nodeInfo = "5f4a2236d00008fba7ac0dd24b95762b446767bd :7379 myself,master - 0 0 1 connected 0-5459 [5460->-5f4a2236d00008fba7ac0dd24b95762b446767bd] [5461-<-5f4a2236d00008fba7ac0dd24b95762b446767bd]";
    HostAndPort current = new HostAndPort("localhost", 7379);
    ClusterNodeInformation clusterNodeInfo = parser.parse(nodeInfo, current);
    assertEquals(clusterNodeInfo.getNode(), current);
    for (int slot = 0; slot <= 5459; slot++) {
        assertTrue(clusterNodeInfo.getAvailableSlots().contains(slot));
    }
    assertEquals(1, clusterNodeInfo.getSlotsBeingMigrated().size());
    assertTrue(clusterNodeInfo.getSlotsBeingMigrated().contains(5460));
    assertEquals(1, clusterNodeInfo.getSlotsBeingImported().size());
    assertTrue(clusterNodeInfo.getSlotsBeingImported().contains(5461));
}
Also used : HostAndPort(redis.clients.jedis.HostAndPort) ClusterNodeInformation(redis.clients.util.ClusterNodeInformation) Test(org.junit.Test)

Example 20 with HostAndPort

use of redis.clients.jedis.HostAndPort in project new-cloud by xie-summer.

the class JedisSentinelPoolTest method initializeWithNotAvailableSentinelsShouldThrowException.

@Test(expected = JedisConnectionException.class)
public void initializeWithNotAvailableSentinelsShouldThrowException() {
    Set<String> wrongSentinels = new HashSet<String>();
    wrongSentinels.add(new HostAndPort("localhost", 65432).toString());
    wrongSentinels.add(new HostAndPort("localhost", 65431).toString());
    JedisSentinelPool pool = new JedisSentinelPool(MASTER_NAME, wrongSentinels);
    pool.destroy();
}
Also used : HostAndPort(redis.clients.jedis.HostAndPort) JedisSentinelPool(redis.clients.jedis.JedisSentinelPool) HashSet(java.util.HashSet) Test(org.junit.Test)

Aggregations

HostAndPort (redis.clients.jedis.HostAndPort)95 Test (org.junit.Test)42 JedisCluster (redis.clients.jedis.JedisCluster)33 HashSet (java.util.HashSet)31 Jedis (redis.clients.jedis.Jedis)24 LinkedHashSet (java.util.LinkedHashSet)18 JedisPoolConfig (redis.clients.jedis.JedisPoolConfig)10 Before (org.junit.Before)9 ArrayList (java.util.ArrayList)7 JedisPool (redis.clients.jedis.JedisPool)7 ClusterNodeInformation (redis.clients.util.ClusterNodeInformation)6 AppDesc (com.sohu.cache.entity.AppDesc)5 InstanceInfo (com.sohu.cache.entity.InstanceInfo)5 JedisSentinelPool (redis.clients.jedis.JedisSentinelPool)5 IOException (java.io.IOException)4 AtomicReference (java.util.concurrent.atomic.AtomicReference)4 JedisPubSub (redis.clients.jedis.JedisPubSub)4 HashMap (java.util.HashMap)3 Map (java.util.Map)3 JSONObject (com.alibaba.fastjson.JSONObject)2