@Test public void non_uniform_group_sizes_are_supported() { GroupAvailabilityCalculator calc = calcForHierarchicCluster( DistributionBuilder.withGroupNodes(1, 2, 3, 4), 0.67); assertThat(calc.nodesThatShouldBeDown(clusterState( "distributor:10 storage:10")), equalTo(emptySet())); assertThat(calc.nodesThatShouldBeDown(clusterState( "distributor:10 storage:10 .0.s:d")), equalTo(emptySet())); assertThat(calc.nodesThatShouldBeDown(clusterState( "distributor:10 storage:10 .1.s:d")), equalTo(indices(2))); assertThat(calc.nodesThatShouldBeDown(clusterState( "distributor:10 storage:10 .3.s:d")), equalTo(indices(4, 5))); assertThat(calc.nodesThatShouldBeDown(clusterState( "distributor:10 storage:10 .7.s:d")), equalTo(emptySet())); assertThat(calc.nodesThatShouldBeDown(clusterState( "distributor:10 storage:9 .7.s:d")), equalTo(indices(6, 8))); }
public Set<Integer> nodesThatShouldBeDown(ClusterState state) { if (distribution == null) { return Collections.emptySet(); } if (isFlatCluster(distribution.getRootGroup())) { return new HashSet<>(); } InsufficientAvailabilityGroupVisitor visitor = new InsufficientAvailabilityGroupVisitor(state); distribution.visitGroups(visitor); return visitor.implicitlyDownNodeIndices(); }
GroupAvailabilityCalculator { public Set<Integer> nodesThatShouldBeDown(ClusterState state) { if (distribution == null) { return Collections.emptySet(); } if (isFlatCluster(distribution.getRootGroup())) { return new HashSet<>(); } InsufficientAvailabilityGroupVisitor visitor = new InsufficientAvailabilityGroupVisitor(state); distribution.visitGroups(visitor); return visitor.implicitlyDownNodeIndices(); } }
GroupAvailabilityCalculator { public Set<Integer> nodesThatShouldBeDown(ClusterState state) { if (distribution == null) { return Collections.emptySet(); } if (isFlatCluster(distribution.getRootGroup())) { return new HashSet<>(); } InsufficientAvailabilityGroupVisitor visitor = new InsufficientAvailabilityGroupVisitor(state); distribution.visitGroups(visitor); return visitor.implicitlyDownNodeIndices(); } private  GroupAvailabilityCalculator(Distribution distribution,
                                        double minNodeRatioPerGroup); }
GroupAvailabilityCalculator { public Set<Integer> nodesThatShouldBeDown(ClusterState state) { if (distribution == null) { return Collections.emptySet(); } if (isFlatCluster(distribution.getRootGroup())) { return new HashSet<>(); } InsufficientAvailabilityGroupVisitor visitor = new InsufficientAvailabilityGroupVisitor(state); distribution.visitGroups(visitor); return visitor.implicitlyDownNodeIndices(); } private  GroupAvailabilityCalculator(Distribution distribution,
                                        double minNodeRatioPerGroup); static Builder builder(); Set<Integer> nodesThatShouldBeDown(ClusterState state); }
GroupAvailabilityCalculator { public Set<Integer> nodesThatShouldBeDown(ClusterState state) { if (distribution == null) { return Collections.emptySet(); } if (isFlatCluster(distribution.getRootGroup())) { return new HashSet<>(); } InsufficientAvailabilityGroupVisitor visitor = new InsufficientAvailabilityGroupVisitor(state); distribution.visitGroups(visitor); return visitor.implicitlyDownNodeIndices(); } private  GroupAvailabilityCalculator(Distribution distribution,
                                        double minNodeRatioPerGroup); static Builder builder(); Set<Integer> nodesThatShouldBeDown(ClusterState state);  }