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 85BB8200CEC for ; Mon, 21 Aug 2017 17:47:42 +0200 (CEST) Received: by cust-asf.ponee.io (Postfix) id 8499816555D; Mon, 21 Aug 2017 15:47:42 +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 C9E8416555C for ; Mon, 21 Aug 2017 17:47:41 +0200 (CEST) Received: (qmail 26166 invoked by uid 500); 21 Aug 2017 15:47:40 -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 26153 invoked by uid 99); 21 Aug 2017 15:47:40 -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; Mon, 21 Aug 2017 15:47:40 +0000 Received: by git1-us-west.apache.org (ASF Mail Server at git1-us-west.apache.org, from userid 33) id DA9A7DFA3B; Mon, 21 Aug 2017 15:47:39 +0000 (UTC) Content-Type: text/plain; charset="us-ascii" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit From: tedyu@apache.org To: commits@hbase.apache.org Message-Id: <126a99da5ea34e77a45723b19b272b78@git.apache.org> X-Mailer: ASF-Git Admin Mailer Subject: hbase git commit: HBASE-18629 Enhance ChaosMonkeyRunner with interruptibility Date: Mon, 21 Aug 2017 15:47:39 +0000 (UTC) archived-at: Mon, 21 Aug 2017 15:47:42 -0000 Repository: hbase Updated Branches: refs/heads/HBASE-14850 583d4e2d4 -> 000c14328 HBASE-18629 Enhance ChaosMonkeyRunner with interruptibility Project: http://git-wip-us.apache.org/repos/asf/hbase/repo Commit: http://git-wip-us.apache.org/repos/asf/hbase/commit/000c1432 Tree: http://git-wip-us.apache.org/repos/asf/hbase/tree/000c1432 Diff: http://git-wip-us.apache.org/repos/asf/hbase/diff/000c1432 Branch: refs/heads/HBASE-14850 Commit: 000c14328f71ba710b2564b96893b5c524227353 Parents: 583d4e2 Author: tedyu Authored: Mon Aug 21 08:47:06 2017 -0700 Committer: tedyu Committed: Mon Aug 21 08:47:06 2017 -0700 ---------------------------------------------------------------------- .../hbase/chaos/util/ChaosMonkeyRunner.java | 26 ++++++++++++++++++-- 1 file changed, 24 insertions(+), 2 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/hbase/blob/000c1432/hbase-it/src/test/java/org/apache/hadoop/hbase/chaos/util/ChaosMonkeyRunner.java ---------------------------------------------------------------------- diff --git a/hbase-it/src/test/java/org/apache/hadoop/hbase/chaos/util/ChaosMonkeyRunner.java b/hbase-it/src/test/java/org/apache/hadoop/hbase/chaos/util/ChaosMonkeyRunner.java index 1ee7d93..7c56a33 100644 --- a/hbase-it/src/test/java/org/apache/hadoop/hbase/chaos/util/ChaosMonkeyRunner.java +++ b/hbase-it/src/test/java/org/apache/hadoop/hbase/chaos/util/ChaosMonkeyRunner.java @@ -52,6 +52,7 @@ public class ChaosMonkeyRunner extends AbstractHBaseTool { protected boolean noClusterCleanUp = false; private String tableName = "ChaosMonkeyRunner.tableName"; private String familyName = "ChaosMonkeyRunner.familyName"; + private volatile boolean stop = false; @Override public void addOptions() { @@ -92,9 +93,14 @@ public class ChaosMonkeyRunner extends AbstractHBaseTool { protected int doWork() throws Exception { setUpCluster(); getAndStartMonkey(); - while (true) {// loop here until got killed + while (!stop) {// loop here until got killed Thread.sleep(10000); } + return 0; + } + + public void stopRunner() { + stop = true; } public void setUpCluster() throws Exception { @@ -151,10 +157,26 @@ public class ChaosMonkeyRunner extends AbstractHBaseTool { return Sets.newHashSet(familyName); } + /* + * If caller wants to add config parameters contained in a file, the path of conf file + * can be passed as the first two arguments like this: + * -c + */ public static void main(String[] args) throws Exception { Configuration conf = HBaseConfiguration.create(); + String[] actualArgs = args; + if (args.length > 0 && "-c".equals(args[0])) { + int argCount = args.length - 2; + if (argCount < 0) { + throw new IllegalArgumentException("Missing path for -c parameter"); + } + // load the resource specified by the second parameter + conf.addResource(args[1]); + actualArgs = new String[argCount]; + System.arraycopy(args, 2, actualArgs, 0, argCount); + } IntegrationTestingUtility.setUseDistributedCluster(conf); - int ret = ToolRunner.run(conf, new ChaosMonkeyRunner(), args); + int ret = ToolRunner.run(conf, new ChaosMonkeyRunner(), actualArgs); System.exit(ret); }