Selaa lähdekoodia

HDDS-436. Allow SCM chill mode to be disabled by configuration.
Contributed by Ajay Kumar.

Anu Engineer 6 vuotta sitten
vanhempi
commit
64c7a12b57

+ 4 - 0
hadoop-hdds/common/src/main/java/org/apache/hadoop/hdds/HddsConfigKeys.java

@@ -75,6 +75,10 @@ public final class 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 =

+ 8 - 0
hadoop-hdds/common/src/main/resources/ozone-default.xml

@@ -1121,6 +1121,14 @@
     </description>
   </property>
 
+  <property>
+    <name>hdds.scm.chillmode.enabled</name>
+    <value>true</value>
+    <tag>HDDS,SCM,OPERATION</tag>
+    <description>Boolean value to enable or disable SCM chill mode.
+    </description>
+  </property>
+
   <property>
     <name>hdds.container.action.max.limit</name>
     <value>20</value>

+ 6 - 1
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<ContainerInfo> allContainers) {
+  SCMChillModeManager(Configuration conf, List<ContainerInfo> 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) {

+ 2 - 1
hadoop-hdds/server-scm/src/main/java/org/apache/hadoop/hdds/scm/server/StorageContainerManager.java

@@ -233,7 +233,8 @@ public final class StorageContainerManager extends ServiceRuntimeInfoImpl
         new ContainerReportHandler(scmContainerManager, node2ContainerMap,
             replicationStatus);
     scmChillModeManager = new SCMChillModeManager(conf,
-        getScmContainerManager().getStateManager().getAllContainers());
+        getScmContainerManager().getStateManager().getAllContainers(),
+        eventQueue);
     PipelineActionEventHandler pipelineActionEventHandler =
         new PipelineActionEventHandler();
 

+ 15 - 5
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.Rule;
 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 class TestSCMChillModeManager {
 
   @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 @@ public class TestSCMChillModeManager {
   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 class TestSCMChillModeManager {
     }, 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<ContainerInfo> dnContainers,
       double expectedThreshold)
       throws Exception {