Return-Path: X-Original-To: archive-asf-public-internal@cust-asf2.ponee.io Delivered-To: archive-asf-public-internal@cust-asf2.ponee.io Received: from cust-asf.ponee.io (cust-asf.ponee.io [163.172.22.183]) by cust-asf2.ponee.io (Postfix) with ESMTP id 07850200CE4 for ; Sun, 20 Aug 2017 22:04:21 +0200 (CEST) Received: by cust-asf.ponee.io (Postfix) id 05CC71640E7; Sun, 20 Aug 2017 20:04:21 +0000 (UTC) Delivered-To: archive-asf-public@cust-asf.ponee.io Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by cust-asf.ponee.io (Postfix) with SMTP id 138CB1640E8 for ; Sun, 20 Aug 2017 22:04:19 +0200 (CEST) Received: (qmail 68691 invoked by uid 500); 20 Aug 2017 20:04:18 -0000 Mailing-List: contact commits-help@hbase.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: dev@hbase.apache.org Delivered-To: mailing list commits@hbase.apache.org Received: (qmail 68340 invoked by uid 99); 20 Aug 2017 20:04:17 -0000 Received: from git1-us-west.apache.org (HELO git1-us-west.apache.org) (140.211.11.23) by apache.org (qpsmtpd/0.29) with ESMTP; Sun, 20 Aug 2017 20:04:17 +0000 Received: by git1-us-west.apache.org (ASF Mail Server at git1-us-west.apache.org, from userid 33) id 02AC1F3247; Sun, 20 Aug 2017 20:04:15 +0000 (UTC) Content-Type: text/plain; charset="us-ascii" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit From: elserj@apache.org To: commits@hbase.apache.org Date: Sun, 20 Aug 2017 20:04:17 -0000 Message-Id: <27a93dc541a3498cb246579fe03a6f8a@git.apache.org> In-Reply-To: References: X-Mailer: ASF-Git Admin Mailer Subject: [3/7] hbase git commit: HBASE-18631 Allow ChaosMonkey properties to be specified in hbase-site archived-at: Sun, 20 Aug 2017 20:04:21 -0000 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/00a4e069 Tree: http://git-wip-us.apache.org/repos/asf/hbase/tree/00a4e069 Diff: http://git-wip-us.apache.org/repos/asf/hbase/diff/00a4e069 Branch: refs/heads/branch-1 Commit: 00a4e0697a464192c817a0de89e99017e65d3b44 Parents: 7a96682 Author: Josh Elser Authored: Fri Aug 18 22:25:14 2017 -0400 Committer: Josh Elser Committed: Sun Aug 20 15:07:35 2017 -0400 ---------------------------------------------------------------------- .../hadoop/hbase/IntegrationTestBase.java | 21 +++++++++ .../hadoop/hbase/TestIntegrationTestBase.java | 48 ++++++++++++++++++++ .../hbase/chaos/factories/MonkeyConstants.java | 11 +++++ 3 files changed, 80 insertions(+) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/hbase/blob/00a4e069/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 d3433c7..46f0490 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 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/00a4e069/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/00a4e069/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 452d903..5657d39 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 { String PERIODIC_ACTION1_PERIOD = "sdm.action1.period"; @@ -42,6 +46,13 @@ public interface MonkeyConstants { String UNBALANCE_KILL_META_RS = "unbalance.action.kill.meta.rs"; String DECREASE_HFILE_SIZE_SLEEP_TIME = "decrease.hfile.size.sleep.time"; + /** + * A Set of prefixes which encompasses all of the configuration properties for the ChaosMonky. + */ + Set MONKEY_CONFIGURATION_KEY_PREFIXES = new HashSet<>( + Arrays.asList("sdm.", "move.", "restart.", "batch.", "rolling.", "compact.", + "unbalance.", "decrease.")); + long DEFAULT_PERIODIC_ACTION1_PERIOD = 60 * 1000; long DEFAULT_PERIODIC_ACTION2_PERIOD = 90 * 1000; long DEFAULT_PERIODIC_ACTION4_PERIOD = 90 * 1000;