use of io.lettuce.core.cluster.models.partitions.Partitions in project lettuce-core by lettuce-io.
the class KnownMajorityPartitionsConsensusUnitTests method removedNodeViewShouldDecideForKnownMajority.
@Test
void removedNodeViewShouldDecideForKnownMajority() {
Partitions current = createPartitions(node1, node2, node3, node4, node5);
Partitions partitions1 = createPartitions(node1, node2, node3, node4);
Partitions partitions2 = createPartitions(node1, node2, node3, node4);
Partitions partitions3 = createPartitions(node1, node2, node3, node4);
Map<RedisURI, Partitions> map = createMap(partitions1, partitions2, partitions3);
Partitions result = PartitionsConsensus.KNOWN_MAJORITY.getPartitions(current, map);
assertThat(Arrays.asList(partitions1, partitions2, partitions3)).contains(result);
}
use of io.lettuce.core.cluster.models.partitions.Partitions in project lettuce-core by lettuce-io.
the class KnownMajorityPartitionsConsensusUnitTests method strangeClusterSplitViewShouldDecideForKnownMajority.
@Test
void strangeClusterSplitViewShouldDecideForKnownMajority() {
Partitions current = createPartitions(node1, node2, node3, node4, node5);
Partitions partitions1 = createPartitions(node1);
Partitions partitions2 = createPartitions(node2);
Partitions partitions3 = createPartitions(node3);
Map<RedisURI, Partitions> map = createMap(partitions1, partitions2, partitions3);
Partitions result = PartitionsConsensus.KNOWN_MAJORITY.getPartitions(current, map);
assertThat(Arrays.asList(partitions1, partitions2, partitions3)).contains(result);
}
use of io.lettuce.core.cluster.models.partitions.Partitions in project lettuce-core by lettuce-io.
the class KnownMajorityPartitionsConsensusUnitTests method clusterSplitViewShouldDecideForKnownMajority.
@Test
void clusterSplitViewShouldDecideForKnownMajority() {
Partitions current = createPartitions(node1, node2, node3, node4, node5);
Partitions partitions1 = createPartitions(node1, node2);
Partitions partitions2 = createPartitions(node1, node2);
Partitions partitions3 = createPartitions(node1, node2, node3, node4, node5);
Map<RedisURI, Partitions> map = createMap(partitions1, partitions2, partitions3);
Partitions result = PartitionsConsensus.KNOWN_MAJORITY.getPartitions(current, map);
assertThat(result).isEqualTo(partitions3).isNotEqualTo(partitions1);
}
use of io.lettuce.core.cluster.models.partitions.Partitions in project lettuce-core by lettuce-io.
the class ClusterDistributionChannelWriterBenchmark method setup.
@Setup
public void setup() {
writer = new ClusterDistributionChannelWriter(CLIENT_OPTIONS, EMPTY_WRITER, ClusterEventListener.NO_OP);
Partitions partitions = new Partitions();
partitions.add(new RedisClusterNode(RedisURI.create("localhost", 1), "1", true, null, 0, 0, 0, IntStream.range(0, 8191).boxed().collect(Collectors.toList()), new HashSet<>()));
partitions.add(new RedisClusterNode(RedisURI.create("localhost", 2), "2", true, null, 0, 0, 0, IntStream.range(8192, SlotHash.SLOT_COUNT).boxed().collect(Collectors.toList()), new HashSet<>()));
partitions.updateCache();
CompletableFuture<EmptyStatefulRedisConnection> connectionFuture = CompletableFuture.completedFuture(CONNECTION);
writer.setPartitions(partitions);
writer.setClusterConnectionProvider(new PooledClusterConnectionProvider(new EmptyRedisClusterClient(RedisURI.create("localhost", 7379)), EMPTY_WRITER, ByteArrayCodec.INSTANCE, ClusterEventListener.NO_OP) {
public CompletableFuture getConnectionAsync(Intent intent, int slot) {
return connectionFuture;
}
});
writer.setPartitions(partitions);
}
Aggregations