Search in sources :

Example 6 with Partitions

use of io.lettuce.core.cluster.models.partitions.Partitions in project lettuce-core by lettuce-io.

the class ClusterTopologyRefreshUnitTests method getNodeSpecificViewTestingNoAddrFilter.

@Test
void getNodeSpecificViewTestingNoAddrFilter() throws Exception {
    String nodes1 = "n1 10.37.110.63:7000 slave n3 0 1452553664848 43 connected\n" + "n2 10.37.110.68:7000 slave n6 0 1452553664346 45 connected\n" + "badSlave :0 slave,fail,noaddr n5 1449160058028 1449160053146 46 disconnected\n" + "n3 10.37.110.69:7000 master - 0 1452553662842 43 connected 3829-6787 7997-9999\n" + "n4 10.37.110.62:7000 slave n3 0 1452553663844 43 connected\n" + "n5 10.37.110.70:7000 myself,master - 0 0 46 connected 10039-14999\n" + "n6 10.37.110.65:7000 master - 0 1452553663844 45 connected 0-3828 6788-7996 10000-10038 15000-16383";
    Requests clusterNodesRequests = createClusterNodesRequests(1, nodes1);
    Requests clientRequests = createClientListRequests(1, "# Clients\r\nconnected_clients:2\r\nclient_longest_output_list:0\r\nclient_biggest_input_buf:0\r\nblocked_clients:0");
    NodeTopologyViews nodeSpecificViews = sut.getNodeSpecificViews(clusterNodesRequests, clientRequests);
    List<Partitions> values = new ArrayList<>(nodeSpecificViews.toMap().values());
    assertThat(values).hasSize(1);
    for (Partitions value : values) {
        assertThat(value).extracting("nodeId").containsOnly("n1", "n2", "n3", "n4", "n5", "n6");
    }
    RedisClusterNodeSnapshot firstPartition = (RedisClusterNodeSnapshot) values.get(0).getPartition(0);
    RedisClusterNodeSnapshot selfPartition = (RedisClusterNodeSnapshot) values.get(0).getPartition(4);
    assertThat(firstPartition.getConnectedClients()).isEqualTo(2);
    assertThat(selfPartition.getConnectedClients()).isNull();
}
Also used : Partitions(io.lettuce.core.cluster.models.partitions.Partitions) ArrayList(java.util.ArrayList) Test(org.junit.jupiter.api.Test)

Example 7 with Partitions

use of io.lettuce.core.cluster.models.partitions.Partitions in project lettuce-core by lettuce-io.

the class TopologyComparatorsUnitTests method isChangedDifferentOrder.

@Test
void isChangedDifferentOrder() {
    String nodes1 = "3d005a179da7d8dc1adae6409d47b39c369e992b 127.0.0.1:7380 master,myself - 0 1401258245007 2 disconnected 8000-11999\n" + "c37ab8396be428403d4e55c0d317348be27ed973 127.0.0.1:7381 master - 111 1401258245007 222 connected 7000 12000 12002-16383\n";
    String nodes2 = "c37ab8396be428403d4e55c0d317348be27ed973 127.0.0.1:7381 master,myself - 111 1401258245007 222 connected 7000 12000 12002-16383\n" + "3d005a179da7d8dc1adae6409d47b39c369e992b 127.0.0.1:7380 master - 0 1401258245007 2 disconnected 8000-11999\n";
    assertThat(nodes1).isNotEqualTo(nodes2);
    Partitions partitions1 = ClusterPartitionParser.parse(nodes1);
    Partitions partitions2 = ClusterPartitionParser.parse(nodes2);
    assertThat(isChanged(partitions1, partitions2)).isFalse();
}
Also used : Partitions(io.lettuce.core.cluster.models.partitions.Partitions) Test(org.junit.jupiter.api.Test)

Example 8 with Partitions

use of io.lettuce.core.cluster.models.partitions.Partitions in project lettuce-core by lettuce-io.

the class TopologyComparatorsUnitTests method isChangedFlagsChangedReplicaToMaster.

@Test
void isChangedFlagsChangedReplicaToMaster() {
    String nodes1 = "3d005a179da7d8dc1adae6409d47b39c369e992b 127.0.0.1:7380 slave - 0 1401258245007 2 disconnected 8000-11999\n" + "c37ab8396be428403d4e55c0d317348be27ed973 127.0.0.1:7381 master - 111 1401258245007 222 connected 7000 12000 12002-16383\n";
    String nodes2 = "3d005a179da7d8dc1adae6409d47b39c369e992b 127.0.0.1:7380 master - 0 1401258245007 2 disconnected 8000-11999\n" + "c37ab8396be428403d4e55c0d317348be27ed973 127.0.0.1:7381 master - 111 1401258245007 222 connected 7000 12000 12002-16383\n";
    Partitions partitions1 = ClusterPartitionParser.parse(nodes1);
    Partitions partitions2 = ClusterPartitionParser.parse(nodes2);
    assertThat(isChanged(partitions1, partitions2)).isTrue();
}
Also used : Partitions(io.lettuce.core.cluster.models.partitions.Partitions) Test(org.junit.jupiter.api.Test)

Example 9 with Partitions

use of io.lettuce.core.cluster.models.partitions.Partitions in project lettuce-core by lettuce-io.

the class TopologyComparatorsUnitTests method isChangedFlagsChangedMasterToReplica.

@Test
void isChangedFlagsChangedMasterToReplica() {
    String nodes1 = "3d005a179da7d8dc1adae6409d47b39c369e992b 127.0.0.1:7380 master - 0 1401258245007 2 disconnected 8000-11999\n" + "c37ab8396be428403d4e55c0d317348be27ed973 127.0.0.1:7381 master - 111 1401258245007 222 connected 7000 12000 12002-16383\n";
    String nodes2 = "3d005a179da7d8dc1adae6409d47b39c369e992b 127.0.0.1:7380 slave - 0 1401258245007 2 disconnected 8000-11999\n" + "c37ab8396be428403d4e55c0d317348be27ed973 127.0.0.1:7381 master - 111 1401258245007 222 connected 7000 12000 12002-16383\n";
    Partitions partitions1 = ClusterPartitionParser.parse(nodes1);
    Partitions partitions2 = ClusterPartitionParser.parse(nodes2);
    assertThat(isChanged(partitions1, partitions2)).isTrue();
}
Also used : Partitions(io.lettuce.core.cluster.models.partitions.Partitions) Test(org.junit.jupiter.api.Test)

Example 10 with Partitions

use of io.lettuce.core.cluster.models.partitions.Partitions in project lettuce-core by lettuce-io.

the class TopologyComparatorsUnitTests method shouldConsiderNodesWithoutSlotsUnchanged.

@Test
void shouldConsiderNodesWithoutSlotsUnchanged() {
    String nodes1 = "3d005a179da7d8dc1adae6409d47b39c369e992b 127.0.0.1:7380 slave - 0 1401258245007 2 disconnected\n" + "c37ab8396be428403d4e55c0d317348be27ed973 127.0.0.1:7381 master - 111 1401258245007 222 connected 7000 12000 12002-16383\n";
    Partitions partitions1 = ClusterPartitionParser.parse(nodes1);
    Partitions partitions2 = ClusterPartitionParser.parse(nodes1);
    assertThat(isChanged(partitions1, partitions2)).isFalse();
}
Also used : Partitions(io.lettuce.core.cluster.models.partitions.Partitions) Test(org.junit.jupiter.api.Test)

Aggregations

Partitions (io.lettuce.core.cluster.models.partitions.Partitions)69 Test (org.junit.jupiter.api.Test)50 RedisClusterNode (io.lettuce.core.cluster.models.partitions.RedisClusterNode)36 RedisURI (io.lettuce.core.RedisURI)20 ArrayList (java.util.ArrayList)13 StatefulRedisConnection (io.lettuce.core.api.StatefulRedisConnection)10 PartitionsConsensusTestSupport.createPartitions (io.lettuce.core.cluster.PartitionsConsensusTestSupport.createPartitions)9 RedisCodec (io.lettuce.core.codec.RedisCodec)9 CompletableFuture (java.util.concurrent.CompletableFuture)8 Exceptions (io.lettuce.core.internal.Exceptions)6 Futures (io.lettuce.core.internal.Futures)6 InternalLogger (io.netty.util.internal.logging.InternalLogger)6 InternalLoggerFactory (io.netty.util.internal.logging.InternalLoggerFactory)6 List (java.util.List)6 Function (java.util.function.Function)6 LettuceAssert (io.lettuce.core.internal.LettuceAssert)5 Collection (java.util.Collection)5 Iterator (java.util.Iterator)5 Map (java.util.Map)5 CompletionStage (java.util.concurrent.CompletionStage)5