use of io.lettuce.core.models.role.RedisNodeDescription in project lettuce-core by lettuce-io.
the class ReadFromUnitTests method subnetIpv6RuleAnyNode.
@Test
void subnetIpv6RuleAnyNode() {
ReadFrom sut = ReadFrom.subnet("::/0");
RedisClusterNode node = createNodeWithHost("2001:db8:abcd:1000::");
List<RedisNodeDescription> result = sut.select(getNodes(node));
assertThat(result).hasSize(1).containsExactly(node);
}
use of io.lettuce.core.models.role.RedisNodeDescription in project lettuce-core by lettuce-io.
the class ReadFromUnitTests method subnetIpv4RuleAnyNode.
@Test
void subnetIpv4RuleAnyNode() {
ReadFrom sut = ReadFrom.subnet("0.0.0.0/0");
RedisClusterNode node = createNodeWithHost("192.0.2.1");
List<RedisNodeDescription> result = sut.select(getNodes(node));
assertThat(result).hasSize(1).containsExactly(node);
}
use of io.lettuce.core.models.role.RedisNodeDescription in project lettuce-core by lettuce-io.
the class ReadFromUnitTests method subnetIpv4Ipv6Mixed.
@Test
void subnetIpv4Ipv6Mixed() {
ReadFrom sut = ReadFrom.subnet("192.0.2.0/24", "2001:db8:abcd:0000::/52");
RedisClusterNode nodeInSubnetIpv4 = createNodeWithHost("192.0.2.1");
RedisClusterNode nodeNotInSubnetIpv4 = createNodeWithHost("198.51.100.1");
RedisClusterNode nodeInSubnetIpv6 = createNodeWithHost("2001:db8:abcd:0000::1");
RedisClusterNode nodeNotInSubnetIpv6 = createNodeWithHost("2001:db8:abcd:1000::");
List<RedisNodeDescription> result = sut.select(getNodes(nodeInSubnetIpv4, nodeNotInSubnetIpv4, nodeInSubnetIpv6, nodeNotInSubnetIpv6));
assertThat(result).hasSize(2).containsExactly(nodeInSubnetIpv4, nodeInSubnetIpv6);
}
use of io.lettuce.core.models.role.RedisNodeDescription in project lettuce-core by lettuce-io.
the class ReadFromUnitTests method regex.
@Test
void regex() {
ReadFrom sut = ReadFrom.regex(Pattern.compile(".*region-1.*"));
RedisClusterNode node1 = createNodeWithHost("redis-node-1.region-1.example.com");
RedisClusterNode node2 = createNodeWithHost("redis-node-2.region-1.example.com");
RedisClusterNode node3 = createNodeWithHost("redis-node-1.region-2.example.com");
RedisClusterNode node4 = createNodeWithHost("redis-node-2.region-2.example.com");
List<RedisNodeDescription> result = sut.select(getNodes(node1, node2, node3, node4));
assertThat(result).hasSize(2).containsExactly(node1, node2);
}
use of io.lettuce.core.models.role.RedisNodeDescription in project lettuce-core by lettuce-io.
the class ReplicaTopologyProvider method getReplicasFromInfo.
private List<RedisNodeDescription> getReplicasFromInfo(String info) {
List<RedisNodeDescription> replicas = new ArrayList<>();
Matcher matcher = SLAVE_PATTERN.matcher(info);
while (matcher.find()) {
String group = matcher.group(2);
String ip = getNested(IP_PATTERN, group, 1);
String port = getNested(PORT_PATTERN, group, 1);
replicas.add(new RedisMasterReplicaNode(ip, Integer.parseInt(port), redisURI, RedisInstance.Role.SLAVE));
}
return replicas;
}
Aggregations