HDDS-2198. SCM should not consider containers in CLOSING state to come out of safemode. (#1540)

This commit is contained in:
Nanda kumar 2019-10-04 08:20:58 +05:30 committed by GitHub
parent 1dde3efb91
commit cdaa480dbf
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 16 additions and 14 deletions

View File

@ -19,6 +19,7 @@
import java.util.List; import java.util.List;
import java.util.Map; import java.util.Map;
import java.util.Optional;
import java.util.concurrent.ConcurrentHashMap; import java.util.concurrent.ConcurrentHashMap;
import java.util.concurrent.atomic.AtomicLong; import java.util.concurrent.atomic.AtomicLong;
@ -63,19 +64,18 @@ public ContainerSafeModeRule(String ruleName, EventQueue eventQueue,
" value should be >= 0.0 and <= 1.0"); " value should be >= 0.0 and <= 1.0");
containerMap = new ConcurrentHashMap<>(); containerMap = new ConcurrentHashMap<>();
if(containers != null) { containers.forEach(container -> {
containers.forEach(c -> { // There can be containers in OPEN/CLOSING state which were never
// TODO: There can be containers in OPEN state which were never
// created by the client. We are not considering these containers for // created by the client. We are not considering these containers for
// now. These containers can be handled by tracking pipelines. // now. These containers can be handled by tracking pipelines.
if (c != null && c.getState() != null &&
!c.getState().equals(HddsProtos.LifeCycleState.OPEN)) { Optional.ofNullable(container.getState())
containerMap.put(c.getContainerID(), c); .filter(state -> state != HddsProtos.LifeCycleState.OPEN)
} .filter(state -> state != HddsProtos.LifeCycleState.CLOSING)
.ifPresent(s -> containerMap.put(container.getContainerID(),
container));
}); });
maxContainer = containerMap.size(); maxContainer = containerMap.size();
}
long cutOff = (long) Math.ceil(maxContainer * safeModeCutoff); long cutOff = (long) Math.ceil(maxContainer * safeModeCutoff);
getSafeModeMetrics().setNumContainerWithOneReplicaReportedThreshold(cutOff); getSafeModeMetrics().setNumContainerWithOneReplicaReportedThreshold(cutOff);
} }

View File

@ -23,6 +23,7 @@
import java.io.File; import java.io.File;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.Collections;
import java.util.List; import java.util.List;
import java.util.UUID; import java.util.UUID;
@ -60,7 +61,7 @@ public class TestSCMSafeModeManager {
private static EventQueue queue; private static EventQueue queue;
private SCMSafeModeManager scmSafeModeManager; private SCMSafeModeManager scmSafeModeManager;
private static Configuration config; private static Configuration config;
private List<ContainerInfo> containers; private List<ContainerInfo> containers = Collections.emptyList();
@Rule @Rule
public Timeout timeout = new Timeout(1000 * 300); public Timeout timeout = new Timeout(1000 * 300);
@ -85,7 +86,8 @@ public void testSafeModeState() throws Exception {
@Test @Test
public void testSafeModeStateWithNullContainers() { public void testSafeModeStateWithNullContainers() {
new SCMSafeModeManager(config, null, null, queue); new SCMSafeModeManager(config, Collections.emptyList(),
null, queue);
} }
private void testSafeMode(int numContainers) throws Exception { private void testSafeMode(int numContainers) throws Exception {