You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@hbase.apache.org by la...@apache.org on 2014/01/08 00:01:35 UTC

svn commit: r1556395 - /hbase/branches/0.94/src/test/java/org/apache/hadoop/hbase/util/ChaosMonkey.java

Author: larsh
Date: Tue Jan  7 23:01:35 2014
New Revision: 1556395

URL: http://svn.apache.org/r1556395
Log:
HBASE-10286 All for configurable policies in ChaosMonkey (Cody Marcel)

Modified:
    hbase/branches/0.94/src/test/java/org/apache/hadoop/hbase/util/ChaosMonkey.java

Modified: hbase/branches/0.94/src/test/java/org/apache/hadoop/hbase/util/ChaosMonkey.java
URL: http://svn.apache.org/viewvc/hbase/branches/0.94/src/test/java/org/apache/hadoop/hbase/util/ChaosMonkey.java?rev=1556395&r1=1556394&r2=1556395&view=diff
==============================================================================
--- hbase/branches/0.94/src/test/java/org/apache/hadoop/hbase/util/ChaosMonkey.java (original)
+++ hbase/branches/0.94/src/test/java/org/apache/hadoop/hbase/util/ChaosMonkey.java Tue Jan  7 23:01:35 2014
@@ -37,8 +37,8 @@ import org.apache.hadoop.hbase.HBaseClus
 import org.apache.hadoop.hbase.HBaseConfiguration;
 import org.apache.hadoop.hbase.HRegionInfo;
 import org.apache.hadoop.hbase.HServerLoad;
-import org.apache.hadoop.hbase.IntegrationTestingUtility;
 import org.apache.hadoop.hbase.IntegrationTestDataIngestWithChaosMonkey;
+import org.apache.hadoop.hbase.IntegrationTestingUtility;
 import org.apache.hadoop.hbase.ServerName;
 import org.apache.hadoop.hbase.Stoppable;
 import org.apache.hadoop.hbase.client.HBaseAdmin;
@@ -84,6 +84,14 @@ public class ChaosMonkey extends Abstrac
   /**
    * Construct a new ChaosMonkey
    * @param util the HBaseIntegrationTestingUtility already configured
+   */
+  public ChaosMonkey(IntegrationTestingUtility util) {
+	  this.util = util;
+  }
+  
+  /**
+   * Construct a new ChaosMonkey
+   * @param util the HBaseIntegrationTestingUtility already configured
    * @param policies names of pre-defined policies to use
    */
   public ChaosMonkey(IntegrationTestingUtility util, String... policies) {
@@ -108,6 +116,13 @@ public class ChaosMonkey extends Abstrac
     }
   }
 
+  private void setPolicies(Policy... policies) {
+    this.policies = new Policy[policies.length];
+    for (int i = 0; i < policies.length; i++) {
+      this.policies[i] = policies[i];
+    }
+  }
+
   /**
    * Context for Action's
    */
@@ -786,6 +801,9 @@ public class ChaosMonkey extends Abstrac
     String[] policies = cmd.getOptionValues("policy");
     if (policies != null) {
       setPoliciesByName(policies);
+    } else {
+      // Set a default policy if none is provided
+      setPolicies(NAMED_POLICIES.get(EVERY_MINUTE_RANDOM_ACTION_POLICY));
     }
   }
 
@@ -802,7 +820,7 @@ public class ChaosMonkey extends Abstrac
     IntegrationTestingUtility util = new IntegrationTestingUtility(conf);
     util.initializeCluster(1);
 
-    ChaosMonkey monkey = new ChaosMonkey(util, EVERY_MINUTE_RANDOM_ACTION_POLICY);
+    ChaosMonkey monkey = new ChaosMonkey(util);
     int ret = ToolRunner.run(conf, monkey, args);
     System.exit(ret);
   }