use of io.lettuce.core.models.role.RedisNodeDescription in project lettuce-core by lettuce-io.
the class ReplicaTopologyProvider method getNodesFromInfo.
protected List<RedisNodeDescription> getNodesFromInfo(String info) {
List<RedisNodeDescription> result = new ArrayList<>();
RedisNodeDescription currentNodeDescription = getCurrentNodeDescription(info);
result.add(currentNodeDescription);
if (currentNodeDescription.getRole().isUpstream()) {
result.addAll(getReplicasFromInfo(info));
} else {
result.add(getMasterFromInfo(info));
}
return result;
}
use of io.lettuce.core.models.role.RedisNodeDescription in project lettuce-core by lettuce-io.
the class ReadFromUnitTests method subnetIpv4RuleIpv6NodeGiven.
@Test
void subnetIpv4RuleIpv6NodeGiven() {
ReadFrom sut = ReadFrom.subnet("0.0.0.0/0");
RedisClusterNode ipv6node = createNodeWithHost("2001:db8:abcd:1000::");
List<RedisNodeDescription> result = sut.select(getNodes(ipv6node));
assertThat(result).isEmpty();
}
use of io.lettuce.core.models.role.RedisNodeDescription in project lettuce-core by lettuce-io.
the class ReadFromUnitTests method subnetNodeWithHostname.
@Test
void subnetNodeWithHostname() {
ReadFrom sut = ReadFrom.subnet("0.0.0.0/0");
RedisClusterNode hostNode = createNodeWithHost("example.com");
RedisClusterNode localhostNode = createNodeWithHost("localhost");
List<RedisNodeDescription> result = sut.select(getNodes(hostNode, localhostNode));
assertThat(result).isEmpty();
}
use of io.lettuce.core.models.role.RedisNodeDescription in project lettuce-core by lettuce-io.
the class ReadFromUnitTests method subnetIpv6RuleIpv4NodeGiven.
@Test
void subnetIpv6RuleIpv4NodeGiven() {
ReadFrom sut = ReadFrom.subnet("::/0");
RedisClusterNode node = createNodeWithHost("192.0.2.1");
List<RedisNodeDescription> result = sut.select(getNodes(node));
assertThat(result).isEmpty();
}
use of io.lettuce.core.models.role.RedisNodeDescription in project lettuce-core by lettuce-io.
the class MasterReplicaTopologyRefreshUnitTests method shouldRetrieveTopology.
@Test
void shouldRetrieveTopology() {
MasterReplicaTopologyRefresh refresh = new MasterReplicaTopologyRefresh(connectionFactory, executorService, provider);
CompletableFuture<StatefulRedisConnection<String, String>> master = CompletableFuture.completedFuture(connection);
CompletableFuture<StatefulRedisConnection<String, String>> replica = CompletableFuture.completedFuture(connection);
when(connectionFactory.connectToNodeAsync(any(), any())).thenReturn((CompletableFuture) master, (CompletableFuture) replica);
RedisURI redisURI = new RedisURI();
redisURI.setTimeout(Duration.ofMillis(1));
List<RedisNodeDescription> nodes = refresh.getNodes(redisURI).block();
assertThat(nodes).hasSize(2);
}
Aggregations