hbase-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From els...@apache.org
Subject [7/7] hbase git commit: HBASE-18631 Allow ChaosMonkey properties to be specified in hbase-site
Date Sun, 20 Aug 2017 20:04:21 GMT
HBASE-18631 Allow ChaosMonkey properties to be specified in hbase-site


Project: http://git-wip-us.apache.org/repos/asf/hbase/repo
Commit: http://git-wip-us.apache.org/repos/asf/hbase/commit/e391bb04
Tree: http://git-wip-us.apache.org/repos/asf/hbase/tree/e391bb04
Diff: http://git-wip-us.apache.org/repos/asf/hbase/diff/e391bb04

Branch: refs/heads/branch-1.1
Commit: e391bb047ed9416b9592ac4c87195ed52f7cbc22
Parents: a566f33
Author: Josh Elser <elserj@apache.org>
Authored: Fri Aug 18 22:25:14 2017 -0400
Committer: Josh Elser <elserj@apache.org>
Committed: Sun Aug 20 16:01:10 2017 -0400

----------------------------------------------------------------------
 .../hadoop/hbase/IntegrationTestBase.java       | 21 +++++++++
 .../hadoop/hbase/TestIntegrationTestBase.java   | 48 ++++++++++++++++++++
 .../hbase/chaos/factories/MonkeyConstants.java  | 10 ++++
 3 files changed, 79 insertions(+)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/hbase/blob/e391bb04/hbase-it/src/test/java/org/apache/hadoop/hbase/IntegrationTestBase.java
----------------------------------------------------------------------
diff --git a/hbase-it/src/test/java/org/apache/hadoop/hbase/IntegrationTestBase.java b/hbase-it/src/test/java/org/apache/hadoop/hbase/IntegrationTestBase.java
index 3929524..4c9aa3b 100644
--- a/hbase-it/src/test/java/org/apache/hadoop/hbase/IntegrationTestBase.java
+++ b/hbase-it/src/test/java/org/apache/hadoop/hbase/IntegrationTestBase.java
@@ -19,6 +19,7 @@
 package org.apache.hadoop.hbase;
 
 import java.io.IOException;
+import java.util.Map.Entry;
 import java.util.Properties;
 import java.util.Set;
 
@@ -27,6 +28,7 @@ import org.apache.commons.lang.StringUtils;
 import org.apache.commons.logging.Log;
 import org.apache.commons.logging.LogFactory;
 import org.apache.hadoop.conf.Configuration;
+import org.apache.hadoop.hbase.chaos.factories.MonkeyConstants;
 import org.apache.hadoop.hbase.chaos.factories.MonkeyFactory;
 import org.apache.hadoop.hbase.chaos.monkies.ChaosMonkey;
 import org.apache.hadoop.hbase.util.AbstractHBaseTool;
@@ -86,6 +88,10 @@ public abstract class IntegrationTestBase extends AbstractHBaseTool {
       noClusterCleanUp = true;
     }
     monkeyProps = new Properties();
+    // Add entries for the CM from hbase-site.xml as a convenience.
+    // Do this prior to loading from the properties file to make sure those in the properties
+    // file are given precedence to those in hbase-site.xml (backwards compatibility).
+    loadMonkeyProperties(monkeyProps, HBaseConfiguration.create());
     if (cmd.hasOption(CHAOS_MONKEY_PROPS)) {
       String chaosMonkeyPropsFile = cmd.getOptionValue(CHAOS_MONKEY_PROPS);
       if (StringUtils.isNotEmpty(chaosMonkeyPropsFile)) {
@@ -100,6 +106,21 @@ public abstract class IntegrationTestBase extends AbstractHBaseTool {
     }
   }
 
+  /**
+   * Loads entries from the provided {@code conf} into {@code props} when the configuration
key
+   * is one that may be configuring ChaosMonkey actions.
+   */
+  void loadMonkeyProperties(Properties props, Configuration conf) {
+    for (Entry<String,String> entry : conf) {
+      for (String prefix : MonkeyConstants.MONKEY_CONFIGURATION_KEY_PREFIXES) {
+        if (entry.getKey().startsWith(prefix)) {
+          props.put(entry.getKey(), entry.getValue());
+          break;
+        }
+      }
+    }
+  }
+
   @Override
   protected void processOptions(CommandLine cmd) {
     processBaseOptions(cmd);

http://git-wip-us.apache.org/repos/asf/hbase/blob/e391bb04/hbase-it/src/test/java/org/apache/hadoop/hbase/TestIntegrationTestBase.java
----------------------------------------------------------------------
diff --git a/hbase-it/src/test/java/org/apache/hadoop/hbase/TestIntegrationTestBase.java b/hbase-it/src/test/java/org/apache/hadoop/hbase/TestIntegrationTestBase.java
new file mode 100644
index 0000000..7330909
--- /dev/null
+++ b/hbase-it/src/test/java/org/apache/hadoop/hbase/TestIntegrationTestBase.java
@@ -0,0 +1,48 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.hadoop.hbase;
+
+import static org.junit.Assert.assertEquals;
+
+import java.util.Properties;
+
+import org.apache.hadoop.conf.Configuration;
+import org.apache.hadoop.hbase.chaos.factories.MonkeyConstants;
+import org.apache.hadoop.hbase.testclassification.SmallTests;
+import org.junit.Test;
+import org.junit.experimental.categories.Category;
+
+@Category(SmallTests.class)
+public class TestIntegrationTestBase {
+
+  @Test
+  public void testMonkeyPropertiesParsing() {
+    final Configuration conf = new Configuration(false);
+    conf.set(MonkeyConstants.BATCH_RESTART_RS_RATIO, "0.85");
+    conf.set(MonkeyConstants.MOVE_REGIONS_MAX_TIME, "60000");
+    conf.set("hbase.rootdir", "/foo/bar/baz");
+
+    final Properties props = new Properties();
+    IntegrationTestBase testBase = new IntegrationTestDDLMasterFailover();
+    assertEquals(0, props.size());
+    testBase.loadMonkeyProperties(props, conf);
+    assertEquals(2, props.size());
+    assertEquals("0.85", props.getProperty(MonkeyConstants.BATCH_RESTART_RS_RATIO));
+    assertEquals("60000", props.getProperty(MonkeyConstants.MOVE_REGIONS_MAX_TIME));
+  }
+}

http://git-wip-us.apache.org/repos/asf/hbase/blob/e391bb04/hbase-it/src/test/java/org/apache/hadoop/hbase/chaos/factories/MonkeyConstants.java
----------------------------------------------------------------------
diff --git a/hbase-it/src/test/java/org/apache/hadoop/hbase/chaos/factories/MonkeyConstants.java
b/hbase-it/src/test/java/org/apache/hadoop/hbase/chaos/factories/MonkeyConstants.java
index 3333b26..fe1fd2a 100644
--- a/hbase-it/src/test/java/org/apache/hadoop/hbase/chaos/factories/MonkeyConstants.java
+++ b/hbase-it/src/test/java/org/apache/hadoop/hbase/chaos/factories/MonkeyConstants.java
@@ -17,6 +17,10 @@
  */
 package org.apache.hadoop.hbase.chaos.factories;
 
+import java.util.Arrays;
+import java.util.HashSet;
+import java.util.Set;
+
 public interface MonkeyConstants {
 
   public static final String PERIODIC_ACTION1_PERIOD = "sdm.action1.period";
@@ -61,4 +65,10 @@ public interface MonkeyConstants {
   public static final long DEFAULT_UNBALANCE_WAIT_FOR_KILLS_MS = 2 * 1000;
   public static final long DEFAULT_UNBALANCE_WAIT_AFTER_BALANCE_MS = 5 * 1000;
 
+  /**
+   * A Set of prefixes which encompasses all of the configuration properties for the ChaosMonky.
+   */
+  Set<String> MONKEY_CONFIGURATION_KEY_PREFIXES = new HashSet<>(
+      Arrays.asList("sdm.", "move.", "restart.", "batch.", "rolling.", "compact.",
+          "unbalance.", "decrease."));
 }


Mime
View raw message