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

Contributed by Ajay Kumar.
This commit is contained in:
Anu Engineer 2018-09-12 11:32:46 -07:00
parent 78bd3b1db9
commit 64c7a12b57
5 changed files with 35 additions and 7 deletions

View File

@ -75,6 +75,10 @@ private HddsConfigKeys() {
"hdds.container.close.threshold"; "hdds.container.close.threshold";
public static final float HDDS_CONTAINER_CLOSE_THRESHOLD_DEFAULT = 0.9f; 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 // % of containers which should have at least one reported replica
// before SCM comes out of chill mode. // before SCM comes out of chill mode.
public static final String HDDS_SCM_CHILLMODE_THRESHOLD_PCT = public static final String HDDS_SCM_CHILLMODE_THRESHOLD_PCT =

View File

@ -1121,6 +1121,14 @@
</description> </description>
</property> </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> <property>
<name>hdds.container.action.max.limit</name> <name>hdds.container.action.max.limit</name>
<value>20</value> <value>20</value>

View File

@ -58,10 +58,15 @@ public class SCMChillModeManager implements
private Configuration config; private Configuration config;
private static final String CONT_EXIT_RULE = "ContainerChillModeRule"; 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; this.config = conf;
exitRules exitRules
.put(CONT_EXIT_RULE, new ContainerChillModeRule(config, allContainers)); .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) { private void validateChillModeExitRules(EventPublisher eventQueue) {

View File

@ -233,7 +233,8 @@ private StorageContainerManager(OzoneConfiguration conf) throws IOException {
new ContainerReportHandler(scmContainerManager, node2ContainerMap, new ContainerReportHandler(scmContainerManager, node2ContainerMap,
replicationStatus); replicationStatus);
scmChillModeManager = new SCMChillModeManager(conf, scmChillModeManager = new SCMChillModeManager(conf,
getScmContainerManager().getStateManager().getAllContainers()); getScmContainerManager().getStateManager().getAllContainers(),
eventQueue);
PipelineActionEventHandler pipelineActionEventHandler = PipelineActionEventHandler pipelineActionEventHandler =
new PipelineActionEventHandler(); new PipelineActionEventHandler();

View File

@ -17,11 +17,10 @@
*/ */
package org.apache.hadoop.hdds.scm.server; package org.apache.hadoop.hdds.scm.server;
import static org.junit.Assert.assertTrue;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.List; import java.util.List;
import org.apache.hadoop.conf.Configuration; import org.apache.hadoop.conf.Configuration;
import org.apache.hadoop.hdds.HddsConfigKeys;
import org.apache.hadoop.hdds.conf.OzoneConfiguration; import org.apache.hadoop.hdds.conf.OzoneConfiguration;
import org.apache.hadoop.hdds.scm.HddsTestUtils; import org.apache.hadoop.hdds.scm.HddsTestUtils;
import org.apache.hadoop.hdds.scm.container.common.helpers.ContainerInfo; import org.apache.hadoop.hdds.scm.container.common.helpers.ContainerInfo;
@ -33,6 +32,9 @@
import org.junit.Test; import org.junit.Test;
import org.junit.rules.Timeout; import org.junit.rules.Timeout;
import static org.junit.Assert.assertTrue;
import static org.junit.Assert.assertFalse;
/** Test class for SCMChillModeManager. /** Test class for SCMChillModeManager.
*/ */
public class TestSCMChillModeManager { public class TestSCMChillModeManager {
@ -62,13 +64,13 @@ public void testChillModeState() throws Exception {
@Test @Test
public void testChillModeStateWithNullContainers() { public void testChillModeStateWithNullContainers() {
new SCMChillModeManager(config, null); new SCMChillModeManager(config, null, queue);
} }
private void testChillMode(int numContainers) throws Exception { private void testChillMode(int numContainers) throws Exception {
containers = new ArrayList<>(); containers = new ArrayList<>();
containers.addAll(HddsTestUtils.getContainerInfo(numContainers)); containers.addAll(HddsTestUtils.getContainerInfo(numContainers));
scmChillModeManager = new SCMChillModeManager(config, containers); scmChillModeManager = new SCMChillModeManager(config, containers, queue);
queue.addHandler(SCMEvents.NODE_REGISTRATION_CONT_REPORT, queue.addHandler(SCMEvents.NODE_REGISTRATION_CONT_REPORT,
scmChillModeManager); scmChillModeManager);
assertTrue(scmChillModeManager.getInChillMode()); assertTrue(scmChillModeManager.getInChillMode());
@ -83,7 +85,7 @@ private void testChillMode(int numContainers) throws Exception {
public void testChillModeExitRule() throws Exception { public void testChillModeExitRule() throws Exception {
containers = new ArrayList<>(); containers = new ArrayList<>();
containers.addAll(HddsTestUtils.getContainerInfo(25 * 4)); containers.addAll(HddsTestUtils.getContainerInfo(25 * 4));
scmChillModeManager = new SCMChillModeManager(config, containers); scmChillModeManager = new SCMChillModeManager(config, containers, queue);
queue.addHandler(SCMEvents.NODE_REGISTRATION_CONT_REPORT, queue.addHandler(SCMEvents.NODE_REGISTRATION_CONT_REPORT,
scmChillModeManager); scmChillModeManager);
assertTrue(scmChillModeManager.getInChillMode()); assertTrue(scmChillModeManager.getInChillMode());
@ -101,6 +103,14 @@ public void testChillModeExitRule() throws Exception {
}, 100, 1000 * 5); }, 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, private void testContainerThreshold(List<ContainerInfo> dnContainers,
double expectedThreshold) double expectedThreshold)
throws Exception { throws Exception {