Search in sources :

Example 6 with ClusterNodeInformation

use of redis.clients.util.ClusterNodeInformation in project new-cloud by xie-summer.

the class JedisClusterNodeInformationParserTest method testParseNodeMyself.

@Test
public void testParseNodeMyself() {
    String nodeInfo = "9b0d2ab38ee31482c95fdb2c7847a0d40e88d518 :7379 myself,master - 0 0 1 connected 0-5460";
    HostAndPort current = new HostAndPort("localhost", 7379);
    ClusterNodeInformation clusterNodeInfo = parser.parse(nodeInfo, current);
    assertEquals(clusterNodeInfo.getNode(), current);
}
Also used : HostAndPort(redis.clients.jedis.HostAndPort) ClusterNodeInformation(redis.clients.util.ClusterNodeInformation) Test(org.junit.Test)

Example 7 with ClusterNodeInformation

use of redis.clients.util.ClusterNodeInformation in project cachecloud by sohutv.

the class JedisClusterNodeInformationParserTest method testParseNodeMyself.

@Test
public void testParseNodeMyself() {
    String nodeInfo = "9b0d2ab38ee31482c95fdb2c7847a0d40e88d518 :7379 myself,master - 0 0 1 connected 0-5460";
    HostAndPort current = new HostAndPort("localhost", 7379);
    ClusterNodeInformation clusterNodeInfo = parser.parse(nodeInfo, current);
    assertEquals(clusterNodeInfo.getNode(), current);
}
Also used : HostAndPort(redis.clients.jedis.HostAndPort) ClusterNodeInformation(redis.clients.util.ClusterNodeInformation) Test(org.junit.Test)

Example 8 with ClusterNodeInformation

use of redis.clients.util.ClusterNodeInformation in project cachecloud by sohutv.

the class JedisClusterInfoCache method discoverClusterNodesAndSlots.

public void discoverClusterNodesAndSlots(Jedis jedis) {
    w.lock();
    try {
        this.nodes.clear();
        this.slots.clear();
        String localNodes = jedis.clusterNodes();
        for (String nodeInfo : localNodes.split("\n")) {
            ClusterNodeInformation clusterNodeInfo = nodeInfoParser.parse(nodeInfo, new HostAndPort(jedis.getClient().getHost(), jedis.getClient().getPort()));
            HostAndPort targetNode = clusterNodeInfo.getNode();
            setNodeIfNotExist(targetNode);
            assignSlotsToNode(clusterNodeInfo.getAvailableSlots(), targetNode);
        }
    } finally {
        w.unlock();
    }
}
Also used : ClusterNodeInformation(redis.clients.util.ClusterNodeInformation)

Aggregations

ClusterNodeInformation (redis.clients.util.ClusterNodeInformation)8 Test (org.junit.Test)6 HostAndPort (redis.clients.jedis.HostAndPort)6