HDDS-2198. SCM should not consider containers in CLOSING state to come out of safemode. (#1540)
This commit is contained in:
parent
1dde3efb91
commit
cdaa480dbf
|
@ -19,6 +19,7 @@ package org.apache.hadoop.hdds.scm.safemode;
|
|||
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Optional;
|
||||
import java.util.concurrent.ConcurrentHashMap;
|
||||
import java.util.concurrent.atomic.AtomicLong;
|
||||
|
||||
|
@ -63,19 +64,18 @@ public class ContainerSafeModeRule extends
|
|||
" value should be >= 0.0 and <= 1.0");
|
||||
|
||||
containerMap = new ConcurrentHashMap<>();
|
||||
if(containers != null) {
|
||||
containers.forEach(c -> {
|
||||
// TODO: There can be containers in OPEN state which were never
|
||||
// created by the client. We are not considering these containers for
|
||||
// now. These containers can be handled by tracking pipelines.
|
||||
if (c != null && c.getState() != null &&
|
||||
!c.getState().equals(HddsProtos.LifeCycleState.OPEN)) {
|
||||
containerMap.put(c.getContainerID(), c);
|
||||
}
|
||||
});
|
||||
maxContainer = containerMap.size();
|
||||
}
|
||||
containers.forEach(container -> {
|
||||
// There can be containers in OPEN/CLOSING state which were never
|
||||
// created by the client. We are not considering these containers for
|
||||
// now. These containers can be handled by tracking pipelines.
|
||||
|
||||
Optional.ofNullable(container.getState())
|
||||
.filter(state -> state != HddsProtos.LifeCycleState.OPEN)
|
||||
.filter(state -> state != HddsProtos.LifeCycleState.CLOSING)
|
||||
.ifPresent(s -> containerMap.put(container.getContainerID(),
|
||||
container));
|
||||
});
|
||||
maxContainer = containerMap.size();
|
||||
long cutOff = (long) Math.ceil(maxContainer * safeModeCutoff);
|
||||
getSafeModeMetrics().setNumContainerWithOneReplicaReportedThreshold(cutOff);
|
||||
}
|
||||
|
|
|
@ -23,6 +23,7 @@ import static org.junit.Assert.fail;
|
|||
|
||||
import java.io.File;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
import java.util.UUID;
|
||||
|
||||
|
@ -60,7 +61,7 @@ public class TestSCMSafeModeManager {
|
|||
private static EventQueue queue;
|
||||
private SCMSafeModeManager scmSafeModeManager;
|
||||
private static Configuration config;
|
||||
private List<ContainerInfo> containers;
|
||||
private List<ContainerInfo> containers = Collections.emptyList();
|
||||
|
||||
@Rule
|
||||
public Timeout timeout = new Timeout(1000 * 300);
|
||||
|
@ -85,7 +86,8 @@ public class TestSCMSafeModeManager {
|
|||
|
||||
@Test
|
||||
public void testSafeModeStateWithNullContainers() {
|
||||
new SCMSafeModeManager(config, null, null, queue);
|
||||
new SCMSafeModeManager(config, Collections.emptyList(),
|
||||
null, queue);
|
||||
}
|
||||
|
||||
private void testSafeMode(int numContainers) throws Exception {
|
||||
|
|
Loading…
Reference in New Issue