MaintenanceWhenPendingGlobalMerges implements ClusterStateDeriver { @Override public AnnotatedClusterState derivedFrom(AnnotatedClusterState baselineState, String bucketSpace) { if (!bucketSpace.equals(bucketSpaceToDerive)) { return baselineState.clone(); } Set<Integer> incompleteNodeIndices = availableContentNodes(baselineState.getClusterState()).stream() .filter(nodeIndex -> mayHaveMergesPending(bucketSpaceToCheck, nodeIndex)) .filter(maintenanceTransitionConstraint::maintenanceTransitionAllowed) .collect(Collectors.toSet()); if (incompleteNodeIndices.isEmpty()) { return baselineState.clone(); } return setNodesInMaintenance(baselineState, incompleteNodeIndices); } MaintenanceWhenPendingGlobalMerges(MergePendingChecker mergePendingChecker,
                                              MaintenanceTransitionConstraint maintenanceTransitionConstraint); @Override AnnotatedClusterState derivedFrom(AnnotatedClusterState baselineState, String bucketSpace);  }
@Test public void no_nodes_set_to_maintenance_when_no_merges_pending() { Fixture f = new Fixture(); AnnotatedClusterState derived = f.deriver.derivedFrom(stateFromString("distributor:5 storage:5"), defaultSpace()); assertThat(derived, equalTo(stateFromString("distributor:5 storage:5"))); }