use of io.lettuce.core.cluster.models.partitions.RedisClusterNode in project lettuce-core by lettuce-io.
the class RedisClusterPubSubConnectionIntegrationTests method testNodeHostAndPortMessagePropagationSubscription.
@Test
void testNodeHostAndPortMessagePropagationSubscription() throws Exception {
RedisClusterNode partition = pubSubConnection.getPartitions().getPartition(0);
pubSubConnection.setNodeMessagePropagation(true);
pubSubConnection.addListener(connectionListener);
RedisURI uri = partition.getUri();
StatefulRedisPubSubConnection<String, String> node = pubSubConnection.getConnection(uri.getHost(), uri.getPort());
node.sync().subscribe("channel");
pubSubConnection2.sync().publish("channel", "message");
assertThat(connectionListener.getMessages().take()).isEqualTo("message");
}
use of io.lettuce.core.cluster.models.partitions.RedisClusterNode in project lettuce-core by lettuce-io.
the class ClusterTopologyRefreshUnitTests method undiscoveredAdditionalNodesShouldBeLastUsingClientCount.
@Test
void undiscoveredAdditionalNodesShouldBeLastUsingClientCount() {
List<RedisURI> seed = Collections.singletonList(RedisURI.create("127.0.0.1", 7380));
when(nodeConnectionFactory.connectToNodeAsync(any(RedisCodec.class), eq(InetSocketAddress.createUnresolved("127.0.0.1", 7380)))).thenReturn(completedFuture((StatefulRedisConnection) connection1));
Map<RedisURI, Partitions> partitionsMap = sut.loadViews(seed, Duration.ofSeconds(1), false).toCompletableFuture().join();
Partitions partitions = partitionsMap.values().iterator().next();
List<RedisClusterNode> nodes = TopologyComparators.sortByClientCount(partitions);
assertThat(nodes).hasSize(2).extracting(RedisClusterNode::getUri).containsSequence(seed.get(0), RedisURI.create("127.0.0.1", 7381));
}
use of io.lettuce.core.cluster.models.partitions.RedisClusterNode in project lettuce-core by lettuce-io.
the class ClusterTopologyRefreshUnitTests method undiscoveredAdditionalNodesShouldBeLastUsingLatency.
@Test
void undiscoveredAdditionalNodesShouldBeLastUsingLatency() {
List<RedisURI> seed = Collections.singletonList(RedisURI.create("127.0.0.1", 7380));
when(nodeConnectionFactory.connectToNodeAsync(any(RedisCodec.class), eq(InetSocketAddress.createUnresolved("127.0.0.1", 7380)))).thenReturn(completedFuture((StatefulRedisConnection) connection1));
Map<RedisURI, Partitions> partitionsMap = sut.loadViews(seed, Duration.ofSeconds(1), false).toCompletableFuture().join();
Partitions partitions = partitionsMap.values().iterator().next();
List<RedisClusterNode> nodes = TopologyComparators.sortByLatency(partitions);
assertThat(nodes).hasSize(2).extracting(RedisClusterNode::getUri).containsSequence(seed.get(0), RedisURI.create("127.0.0.1", 7381));
}
use of io.lettuce.core.cluster.models.partitions.RedisClusterNode in project lettuce-core by lettuce-io.
the class ClusterTopologyRefreshUnitTests method discoveredAdditionalNodesShouldBeOrderedUsingClientCount.
@Test
void discoveredAdditionalNodesShouldBeOrderedUsingClientCount() {
List<RedisURI> seed = Collections.singletonList(RedisURI.create("127.0.0.1", 7380));
when(nodeConnectionFactory.connectToNodeAsync(any(RedisCodec.class), eq(InetSocketAddress.createUnresolved("127.0.0.1", 7380)))).thenReturn(completedFuture((StatefulRedisConnection) connection1));
when(nodeConnectionFactory.connectToNodeAsync(any(RedisCodec.class), eq(InetSocketAddress.createUnresolved("127.0.0.1", 7381)))).thenReturn(completedFuture((StatefulRedisConnection) connection2));
Map<RedisURI, Partitions> partitionsMap = sut.loadViews(seed, Duration.ofSeconds(1), true).toCompletableFuture().join();
Partitions partitions = partitionsMap.values().iterator().next();
List<RedisClusterNode> nodes = TopologyComparators.sortByClientCount(partitions);
assertThat(nodes).hasSize(2).extracting(RedisClusterNode::getUri).contains(RedisURI.create("127.0.0.1", 7381), seed.get(0));
}
use of io.lettuce.core.cluster.models.partitions.RedisClusterNode in project lettuce-core by lettuce-io.
the class TopologyComparatorsUnitTests method nodesShouldHaveSameSlots.
@Test
void nodesShouldHaveSameSlots() {
RedisClusterNode nodeA = createNode(1, 4, 36, 98);
RedisClusterNode nodeB = createNode(4, 36, 1, 98);
assertThat(nodeA.getSlots().containsAll(nodeB.getSlots())).isTrue();
assertThat(nodeA.hasSameSlotsAs(nodeB)).isTrue();
}
Aggregations