use of io.lettuce.core.cluster.models.partitions.Partitions in project lettuce-core by lettuce-io.
the class HealthyMajorityPartitionsConsensusUnitTests method sameSharedViewShouldDecideForHealthyNodes.
@Test
void sameSharedViewShouldDecideForHealthyNodes() {
Partitions partitions1 = createPartitions(node1, node2, node3, node4, node5);
Partitions partitions2 = createPartitions(node1, node2, node3, node4, node5);
Partitions partitions3 = createPartitions(node1, node2, node3, node4, node5);
Map<RedisURI, Partitions> map = createMap(partitions1, partitions2, partitions3);
Partitions result = PartitionsConsensus.HEALTHY_MAJORITY.getPartitions(null, 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 HealthyMajorityPartitionsConsensusUnitTests method unhealthyNodeViewShouldDecideForHealthyNodes.
@Test
void unhealthyNodeViewShouldDecideForHealthyNodes() {
Partitions partitions1 = createPartitions(node1, node2);
Partitions partitions2 = createPartitions(node2, node3, node4, node5);
Partitions partitions3 = createPartitions(node2, node3, node4, node5);
Map<RedisURI, Partitions> map = createMap(partitions1, partitions2, partitions3);
node2.setFlags(Collections.singleton(RedisClusterNode.NodeFlag.FAIL));
node3.setFlags(Collections.singleton(RedisClusterNode.NodeFlag.FAIL));
node4.setFlags(Collections.singleton(RedisClusterNode.NodeFlag.FAIL));
node5.setFlags(Collections.singleton(RedisClusterNode.NodeFlag.FAIL));
Partitions result = PartitionsConsensus.HEALTHY_MAJORITY.getPartitions(null, map);
assertThat(result).isSameAs(partitions1);
}
use of io.lettuce.core.cluster.models.partitions.Partitions in project lettuce-core by lettuce-io.
the class HealthyMajorityPartitionsConsensusUnitTests method splitNodeViewShouldDecideForHealthyNodes.
@Test
void splitNodeViewShouldDecideForHealthyNodes() {
Partitions partitions1 = createPartitions(node1, node2, node3);
Partitions partitions2 = createPartitions();
Partitions partitions3 = createPartitions(node3, node4, node5);
Map<RedisURI, Partitions> map = createMap(partitions1, partitions2, partitions3);
node1.setFlags(Collections.singleton(RedisClusterNode.NodeFlag.FAIL));
node2.setFlags(Collections.singleton(RedisClusterNode.NodeFlag.FAIL));
node3.setFlags(Collections.singleton(RedisClusterNode.NodeFlag.FAIL));
Partitions result = PartitionsConsensus.HEALTHY_MAJORITY.getPartitions(null, map);
assertThat(result).isSameAs(partitions3);
}
use of io.lettuce.core.cluster.models.partitions.Partitions in project lettuce-core by lettuce-io.
the class KnownMajorityPartitionsConsensusUnitTests method addedNodeViewShouldDecideForKnownMajority.
@Test
void addedNodeViewShouldDecideForKnownMajority() {
Partitions current = createPartitions(node1, node2, node3, node4);
Partitions partitions1 = createPartitions(node1, node2, node3, node4, node5);
Partitions partitions2 = createPartitions(node1, node2, node3, node4, node5);
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(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 mixedViewShouldDecideForKnownMajority.
@Test
void mixedViewShouldDecideForKnownMajority() {
Partitions current = createPartitions(node1, node2, node3, node4, node5);
Partitions partitions1 = createPartitions(node1, node2, node3, node4);
Partitions partitions2 = createPartitions(node1, node2, node3, node5);
Partitions partitions3 = createPartitions(node1, node2, node4, node5);
Map<RedisURI, Partitions> map = createMap(partitions1, partitions2, partitions3);
Partitions result = PartitionsConsensus.KNOWN_MAJORITY.getPartitions(current, map);
assertThat(Arrays.asList(partitions1, partitions2, partitions3)).contains(result);
}
Aggregations