use of io.lettuce.core.cluster.models.partitions.RedisClusterNode in project lettuce-core by lettuce-io.
the class RedisReactiveClusterClientIntegrationTests method testClusterCountFailureReports.
@Test
void testClusterCountFailureReports() {
RedisClusterNode ownPartition = getOwnPartition(sync);
StepVerifier.create(reactive.clusterCountFailureReports(ownPartition.getNodeId())).consumeNextWith(actual -> {
assertThat(actual).isGreaterThanOrEqualTo(0);
}).verifyComplete();
}
use of io.lettuce.core.cluster.models.partitions.RedisClusterNode in project lettuce-core by lettuce-io.
the class RoundRobinSocketAddressSupplierUnitTests method nodeIPChanges.
@Test
void nodeIPChanges() {
RoundRobinSocketAddressSupplier sut = new RoundRobinSocketAddressSupplier(() -> partitions, redisClusterNodes -> redisClusterNodes, clientResourcesMock);
assertThat(sut.get()).isEqualTo(addr1);
assertThat(partitions.remove(new RedisClusterNode(hap1, "2", true, "", 0, 0, 0, new ArrayList<>(), new HashSet<>()))).isTrue();
assertThat(partitions.add(new RedisClusterNode(hap5, "2", true, "", 0, 0, 0, new ArrayList<>(), new HashSet<>()))).isTrue();
assertThat(sut.get()).isEqualTo(addr1);
assertThat(sut.get()).isEqualTo(addr3);
assertThat(sut.get()).isEqualTo(addr5);
}
use of io.lettuce.core.cluster.models.partitions.RedisClusterNode in project lettuce-core by lettuce-io.
the class RoundRobinSocketAddressSupplierUnitTests method before.
@BeforeEach
void before() {
when(clientResourcesMock.socketAddressResolver()).thenReturn(SocketAddressResolver.create(DnsResolvers.JVM_DEFAULT));
partitions = new Partitions();
partitions.addPartition(new RedisClusterNode(hap1, "1", true, "", 0, 0, 0, new ArrayList<>(), new HashSet<>()));
partitions.addPartition(new RedisClusterNode(hap2, "2", true, "", 0, 0, 0, new ArrayList<>(), new HashSet<>()));
partitions.addPartition(new RedisClusterNode(hap3, "3", true, "", 0, 0, 0, new ArrayList<>(), new HashSet<>()));
partitions.updateCache();
}
use of io.lettuce.core.cluster.models.partitions.RedisClusterNode in project lettuce-core by lettuce-io.
the class RoundRobinUnitTests method shouldDetermineConsistencyWithEqualityCheck.
@Test
void shouldDetermineConsistencyWithEqualityCheck() {
RedisClusterNode node1 = new RedisClusterNode(RedisURI.create("127.0.0.1", 1), "1", true, "", 0, 0, 0, new ArrayList<>(), new HashSet<>());
RedisClusterNode node2 = new RedisClusterNode(RedisURI.create("127.0.0.0", 1), "2", true, "", 0, 0, 0, new ArrayList<>(), new HashSet<>());
RedisClusterNode newNode1 = new RedisClusterNode(RedisURI.create("127.0.0.0", 1), "1", true, "", 0, 0, 0, new ArrayList<>(), new HashSet<>());
RoundRobin<RedisClusterNode> roundRobin = new RoundRobin<>((l, r) -> l.getUri().equals(r.getUri()));
roundRobin.rebuild(Arrays.asList(node1, node2));
assertThat(roundRobin.isConsistent(Arrays.asList(node1, node2))).isTrue();
// RedisClusterNode compares by Id only.
assertThat(roundRobin.isConsistent(Arrays.asList(newNode1, node2))).isFalse();
assertThat(roundRobin.isConsistent(Collections.singletonList(newNode1))).isFalse();
assertThat(roundRobin.isConsistent(Collections.singletonList(node2))).isFalse();
assertThat(roundRobin.isConsistent(Arrays.asList(RedisClusterNode.of("1"), node2))).isFalse();
}
use of io.lettuce.core.cluster.models.partitions.RedisClusterNode in project lettuce-core by lettuce-io.
the class RoundRobinUnitTests method shouldDetermineConsistencyWithEqualityCheckOppositeCheck.
@Test
void shouldDetermineConsistencyWithEqualityCheckOppositeCheck() {
RedisClusterNode node1 = RedisClusterNode.of("1");
RedisClusterNode node2 = RedisClusterNode.of("2");
RedisClusterNode newNode1 = new RedisClusterNode(RedisURI.create("127.0.0.0", 1), "1", true, "", 0, 0, 0, new ArrayList<>(), new HashSet<>());
RoundRobin<RedisClusterNode> roundRobin = new RoundRobin<>((l, r) -> l.getUri() == r.getUri() || (l.getUri() != null && l.getUri().equals(r.getUri())));
roundRobin.rebuild(Arrays.asList(node1, node2));
assertThat(roundRobin.isConsistent(Arrays.asList(node1, node2))).isTrue();
// RedisClusterNode compares by Id only.
assertThat(roundRobin.isConsistent(Arrays.asList(newNode1, node2))).isFalse();
assertThat(roundRobin.isConsistent(Collections.singletonList(newNode1))).isFalse();
assertThat(roundRobin.isConsistent(Collections.singletonList(node2))).isFalse();
}
Aggregations