AggregatedStatsMergePendingChecker implements MergePendingChecker { @Override public boolean mayHaveMergesPending(String bucketSpace, int contentNodeIndex) { if (!stats.hasUpdatesFromAllDistributors()) { return true; } ContentNodeStats nodeStats = stats.getStats().getContentNode(contentNodeIndex); if (nodeStats != null) { ContentNodeStats.BucketSpaceStats bucketSpaceStats = nodeStats.getBucketSpace(bucketSpace); return (bucketSpaceStats != null && bucketSpaceStats.mayHaveBucketsPending(minMergeCompletionRatio)); } return true; } AggregatedStatsMergePendingChecker(AggregatedClusterStats stats,
                                              double minMergeCompletionRatio); @Override boolean mayHaveMergesPending(String bucketSpace, int contentNodeIndex);  }
@Test public void unknown_content_node_may_have_merges_pending() { Fixture f = Fixture.fromBucketsPending(1); assertTrue(f.mayHaveMergesPending("default", 2)); }
@Test public void unknown_bucket_space_has_no_merges_pending() { Fixture f = Fixture.fromBucketsPending(1); assertFalse(f.mayHaveMergesPending("global", 1)); }
@Test public void valid_bucket_space_stats_can_have_no_merges_pending() { Fixture f = Fixture.fromBucketsPending(0); assertFalse(f.mayHaveMergesPending("default", 1)); }
@Test public void valid_bucket_space_stats_may_have_merges_pending() { Fixture f = Fixture.fromBucketsPending(1); assertTrue(f.mayHaveMergesPending("default", 1)); }
@Test public void invalid_bucket_space_stats_may_have_merges_pending() { Fixture f = Fixture.fromInvalidBucketStats(); assertTrue(f.mayHaveMergesPending("default", 1)); }
@Test public void cluster_without_updates_from_all_distributors_may_have_merges_pending() { Fixture f = Fixture.fromIncompleteStats(); assertTrue(f.mayHaveMergesPending("default", 1)); }
@Test public void min_merge_completion_ratio_is_used_when_calculating_may_have_merges_pending() { assertTrue(Fixture.fromBucketsPending(3, 0.6).mayHaveMergesPending("default", 1)); assertFalse(Fixture.fromBucketsPending(2, 0.6).mayHaveMergesPending("default", 1)); }