You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@hbase.apache.org by te...@apache.org on 2017/08/21 15:44:21 UTC
hbase git commit: HBASE-18629 Enhance ChaosMonkeyRunner with
interruptibility
Repository: hbase
Updated Branches:
refs/heads/master 820ee91fe -> 192e87309
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/192e8730
Tree: http://git-wip-us.apache.org/repos/asf/hbase/tree/192e8730
Diff: http://git-wip-us.apache.org/repos/asf/hbase/diff/192e8730
Branch: refs/heads/master
Commit: 192e87309e387ef9fdf7f9808d221ca28ab69889
Parents: 820ee91
Author: tedyu <yu...@gmail.com>
Authored: Mon Aug 21 08:44:11 2017 -0700
Committer: tedyu <yu...@gmail.com>
Committed: Mon Aug 21 08:44:11 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/192e8730/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 82c51ad..f142321 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 <path-to-conf>
+ */
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);
}