hbase-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From syuanji...@apache.org
Subject [35/50] [abbrv] hbase git commit: HBASE-14658 Allow loading a MonkeyFactory by class name
Date Fri, 23 Oct 2015 22:49:55 GMT
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/2e2cbd02
Tree: http://git-wip-us.apache.org/repos/asf/hbase/tree/2e2cbd02
Diff: http://git-wip-us.apache.org/repos/asf/hbase/diff/2e2cbd02

Branch: refs/heads/hbase-12439
Commit: 2e2cbd0201a34b7a24eb0e4c1621f7d11c2f9c04
Parents: 9a5423f
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:12 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/2e2cbd02/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 12f57d9..e479975 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;
@@ -88,6 +92,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