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();
}
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();
}
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();
}
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();
}
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();
}
Aggregations