hbase-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ecl...@apache.org
Subject hbase git commit: HBASE-14658 Allow loading a MonkeyFactory by class name
Date Thu, 22 Oct 2015 15:56:10 GMT
Repository: hbase
Updated Branches:
  refs/heads/branch-1.2 1faee4ca7 -> 52dfde1bf


HBASE-14658 Allow loading a MonkeyFactory by class name


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

Branch: refs/heads/branch-1.2
Commit: 52dfde1bfbddc95cfbb5c7be7ad82818c9862660
Parents: 1faee4c
Author: Elliott Clark <eclark@apache.org>
Authored: Tue Oct 20 18:28:48 2015 -0700
Committer: Elliott Clark <eclark@apache.org>
Committed: Thu Oct 22 08:54:40 2015 -0700

----------------------------------------------------------------------
 .../hadoop/hbase/chaos/factories/MonkeyFactory.java | 16 +++++++++++++++-
 1 file changed, 15 insertions(+), 1 deletion(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/hbase/blob/52dfde1b/hbase-it/src/test/java/org/apache/hadoop/hbase/chaos/factories/MonkeyFactory.java
----------------------------------------------------------------------
diff --git a/hbase-it/src/test/java/org/apache/hadoop/hbase/chaos/factories/MonkeyFactory.java
b/hbase-it/src/test/java/org/apache/hadoop/hbase/chaos/factories/MonkeyFactory.java
index 0cf3318..2e5fd7b 100644
--- a/hbase-it/src/test/java/org/apache/hadoop/hbase/chaos/factories/MonkeyFactory.java
+++ b/hbase-it/src/test/java/org/apache/hadoop/hbase/chaos/factories/MonkeyFactory.java
@@ -22,16 +22,20 @@ import java.util.Map;
 import java.util.Properties;
 import java.util.Set;
 
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
 import org.apache.hadoop.hbase.IntegrationTestingUtility;
 import org.apache.hadoop.hbase.TableName;
 import org.apache.hadoop.hbase.chaos.monkies.ChaosMonkey;
 
 import com.google.common.collect.ImmutableMap;
+import org.apache.hadoop.hbase.util.ReflectionUtils;
 
 /**
  * Base class of the factory that will create a ChaosMonkey.
  */
 public abstract class MonkeyFactory {
+  private static final Log LOG = LogFactory.getLog(MonkeyFactory.class);
 
   protected TableName tableName;
   protected Set<String> columnFamilies;
@@ -84,6 +88,16 @@ public abstract class MonkeyFactory {
     .build();
 
   public static MonkeyFactory getFactory(String factoryName) {
-    return FACTORIES.get(factoryName);
+    MonkeyFactory fact = FACTORIES.get(factoryName);
+    if (fact == null) {
+      Class klass = null;
+      try {
+        klass = Class.forName(factoryName);
+        fact = (MonkeyFactory) ReflectionUtils.newInstance(klass);
+      } catch (ClassNotFoundException e) {
+        LOG.error("Error trying to create " + factoryName + " could not load it by class
name");
+      }
+    }
+    return fact;
   }
 }


Mime
View raw message