diff --git a/hadoop-hdds/common/src/main/java/org/apache/hadoop/hdds/HddsConfigKeys.java b/hadoop-hdds/common/src/main/java/org/apache/hadoop/hdds/HddsConfigKeys.java index 63fb17ef76..492be82359 100644 --- a/hadoop-hdds/common/src/main/java/org/apache/hadoop/hdds/HddsConfigKeys.java +++ b/hadoop-hdds/common/src/main/java/org/apache/hadoop/hdds/HddsConfigKeys.java @@ -75,6 +75,10 @@ private HddsConfigKeys() { "hdds.container.close.threshold"; public static final float HDDS_CONTAINER_CLOSE_THRESHOLD_DEFAULT = 0.9f; + public static final String HDDS_SCM_CHILLMODE_ENABLED = + "hdds.scm.chillmode.enabled"; + public static final boolean HDDS_SCM_CHILLMODE_ENABLED_DEFAULT = true; + // % of containers which should have at least one reported replica // before SCM comes out of chill mode. public static final String HDDS_SCM_CHILLMODE_THRESHOLD_PCT = diff --git a/hadoop-hdds/common/src/main/resources/ozone-default.xml b/hadoop-hdds/common/src/main/resources/ozone-default.xml index 850044d1e5..6afc8708e9 100644 --- a/hadoop-hdds/common/src/main/resources/ozone-default.xml +++ b/hadoop-hdds/common/src/main/resources/ozone-default.xml @@ -1121,6 +1121,14 @@ + + hdds.scm.chillmode.enabled + true + HDDS,SCM,OPERATION + Boolean value to enable or disable SCM chill mode. + + + hdds.container.action.max.limit 20 diff --git a/hadoop-hdds/server-scm/src/main/java/org/apache/hadoop/hdds/scm/server/SCMChillModeManager.java b/hadoop-hdds/server-scm/src/main/java/org/apache/hadoop/hdds/scm/server/SCMChillModeManager.java index d2786372f5..74affa8177 100644 --- a/hadoop-hdds/server-scm/src/main/java/org/apache/hadoop/hdds/scm/server/SCMChillModeManager.java +++ b/hadoop-hdds/server-scm/src/main/java/org/apache/hadoop/hdds/scm/server/SCMChillModeManager.java @@ -58,10 +58,15 @@ public class SCMChillModeManager implements private Configuration config; private static final String CONT_EXIT_RULE = "ContainerChillModeRule"; - SCMChillModeManager(Configuration conf, List allContainers) { + SCMChillModeManager(Configuration conf, List allContainers, + EventPublisher eventQueue) { this.config = conf; exitRules .put(CONT_EXIT_RULE, new ContainerChillModeRule(config, allContainers)); + if (!conf.getBoolean(HddsConfigKeys.HDDS_SCM_CHILLMODE_ENABLED, + HddsConfigKeys.HDDS_SCM_CHILLMODE_ENABLED_DEFAULT)) { + exitChillMode(eventQueue); + } } private void validateChillModeExitRules(EventPublisher eventQueue) { diff --git a/hadoop-hdds/server-scm/src/main/java/org/apache/hadoop/hdds/scm/server/StorageContainerManager.java b/hadoop-hdds/server-scm/src/main/java/org/apache/hadoop/hdds/scm/server/StorageContainerManager.java index 67d5496bec..28a4983f80 100644 --- a/hadoop-hdds/server-scm/src/main/java/org/apache/hadoop/hdds/scm/server/StorageContainerManager.java +++ b/hadoop-hdds/server-scm/src/main/java/org/apache/hadoop/hdds/scm/server/StorageContainerManager.java @@ -233,7 +233,8 @@ private StorageContainerManager(OzoneConfiguration conf) throws IOException { new ContainerReportHandler(scmContainerManager, node2ContainerMap, replicationStatus); scmChillModeManager = new SCMChillModeManager(conf, - getScmContainerManager().getStateManager().getAllContainers()); + getScmContainerManager().getStateManager().getAllContainers(), + eventQueue); PipelineActionEventHandler pipelineActionEventHandler = new PipelineActionEventHandler(); diff --git a/hadoop-hdds/server-scm/src/test/java/org/apache/hadoop/hdds/scm/server/TestSCMChillModeManager.java b/hadoop-hdds/server-scm/src/test/java/org/apache/hadoop/hdds/scm/server/TestSCMChillModeManager.java index e98a9ae1a3..486c604cd0 100644 --- a/hadoop-hdds/server-scm/src/test/java/org/apache/hadoop/hdds/scm/server/TestSCMChillModeManager.java +++ b/hadoop-hdds/server-scm/src/test/java/org/apache/hadoop/hdds/scm/server/TestSCMChillModeManager.java @@ -17,11 +17,10 @@ */ package org.apache.hadoop.hdds.scm.server; -import static org.junit.Assert.assertTrue; - import java.util.ArrayList; import java.util.List; import org.apache.hadoop.conf.Configuration; +import org.apache.hadoop.hdds.HddsConfigKeys; import org.apache.hadoop.hdds.conf.OzoneConfiguration; import org.apache.hadoop.hdds.scm.HddsTestUtils; import org.apache.hadoop.hdds.scm.container.common.helpers.ContainerInfo; @@ -33,6 +32,9 @@ import org.junit.Test; import org.junit.rules.Timeout; +import static org.junit.Assert.assertTrue; +import static org.junit.Assert.assertFalse; + /** Test class for SCMChillModeManager. */ public class TestSCMChillModeManager { @@ -62,13 +64,13 @@ public void testChillModeState() throws Exception { @Test public void testChillModeStateWithNullContainers() { - new SCMChillModeManager(config, null); + new SCMChillModeManager(config, null, queue); } private void testChillMode(int numContainers) throws Exception { containers = new ArrayList<>(); containers.addAll(HddsTestUtils.getContainerInfo(numContainers)); - scmChillModeManager = new SCMChillModeManager(config, containers); + scmChillModeManager = new SCMChillModeManager(config, containers, queue); queue.addHandler(SCMEvents.NODE_REGISTRATION_CONT_REPORT, scmChillModeManager); assertTrue(scmChillModeManager.getInChillMode()); @@ -83,7 +85,7 @@ private void testChillMode(int numContainers) throws Exception { public void testChillModeExitRule() throws Exception { containers = new ArrayList<>(); containers.addAll(HddsTestUtils.getContainerInfo(25 * 4)); - scmChillModeManager = new SCMChillModeManager(config, containers); + scmChillModeManager = new SCMChillModeManager(config, containers, queue); queue.addHandler(SCMEvents.NODE_REGISTRATION_CONT_REPORT, scmChillModeManager); assertTrue(scmChillModeManager.getInChillMode()); @@ -101,6 +103,14 @@ public void testChillModeExitRule() throws Exception { }, 100, 1000 * 5); } + @Test + public void testDisableChillMode() { + OzoneConfiguration conf = new OzoneConfiguration(config); + conf.setBoolean(HddsConfigKeys.HDDS_SCM_CHILLMODE_ENABLED, false); + scmChillModeManager = new SCMChillModeManager(conf, containers, queue); + assertFalse(scmChillModeManager.getInChillMode()); + } + private void testContainerThreshold(List dnContainers, double expectedThreshold) throws Exception {