hbase-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From e...@apache.org
Subject git commit: HBASE-12127 Move the core Connection creation functionality into ConnectionFactory (Solomon Duskis)
Date Thu, 02 Oct 2014 02:04:10 GMT
Repository: hbase
Updated Branches:
  refs/heads/branch-1 e00492b2c -> 17b2c0f90


HBASE-12127 Move the core Connection creation functionality into ConnectionFactory (Solomon
Duskis)


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

Branch: refs/heads/branch-1
Commit: 17b2c0f90e5af5565a1dd01593c0ff85a04a60c0
Parents: e00492b
Author: Enis Soztutar <enis@apache.org>
Authored: Wed Oct 1 19:00:59 2014 -0700
Committer: Enis Soztutar <enis@apache.org>
Committed: Wed Oct 1 19:02:56 2014 -0700

----------------------------------------------------------------------
 .../hadoop/hbase/client/ConnectionFactory.java  | 25 +++++++++++++++++++-
 .../hadoop/hbase/client/ConnectionManager.java  | 20 +---------------
 2 files changed, 25 insertions(+), 20 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/hbase/blob/17b2c0f9/hbase-client/src/main/java/org/apache/hadoop/hbase/client/ConnectionFactory.java
----------------------------------------------------------------------
diff --git a/hbase-client/src/main/java/org/apache/hadoop/hbase/client/ConnectionFactory.java
b/hbase-client/src/main/java/org/apache/hadoop/hbase/client/ConnectionFactory.java
index 6070615..74f7c54 100644
--- a/hbase-client/src/main/java/org/apache/hadoop/hbase/client/ConnectionFactory.java
+++ b/hbase-client/src/main/java/org/apache/hadoop/hbase/client/ConnectionFactory.java
@@ -19,6 +19,7 @@
 package org.apache.hadoop.hbase.client;
 
 import java.io.IOException;
+import java.lang.reflect.Constructor;
 import java.util.concurrent.ExecutorService;
 
 import org.apache.hadoop.hbase.classification.InterfaceAudience;
@@ -179,7 +180,29 @@ public class ConnectionFactory {
       user = provider.getCurrent();
     }
 
-    return ConnectionManager.createConnection(conf, pool, user);
+    return createConnection(conf, false, pool, user);
   }
 
+  static Connection createConnection(final Configuration conf, final boolean managed,
+      final ExecutorService pool, final User user)
+  throws IOException {
+    String className = conf.get(HConnection.HBASE_CLIENT_CONNECTION_IMPL,
+      ConnectionManager.HConnectionImplementation.class.getName());
+    Class<?> clazz = null;
+    try {
+      clazz = Class.forName(className);
+    } catch (ClassNotFoundException e) {
+      throw new IOException(e);
+    }
+    try {
+      // Default HCM#HCI is not accessible; make it so before invoking.
+      Constructor<?> constructor =
+        clazz.getDeclaredConstructor(Configuration.class,
+          boolean.class, ExecutorService.class, User.class);
+      constructor.setAccessible(true);
+      return (Connection) constructor.newInstance(conf, managed, pool, user);
+    } catch (Exception e) {
+      throw new IOException(e);
+    }
+  }
 }

http://git-wip-us.apache.org/repos/asf/hbase/blob/17b2c0f9/hbase-client/src/main/java/org/apache/hadoop/hbase/client/ConnectionManager.java
----------------------------------------------------------------------
diff --git a/hbase-client/src/main/java/org/apache/hadoop/hbase/client/ConnectionManager.java
b/hbase-client/src/main/java/org/apache/hadoop/hbase/client/ConnectionManager.java
index 398d209..00c2b51 100644
--- a/hbase-client/src/main/java/org/apache/hadoop/hbase/client/ConnectionManager.java
+++ b/hbase-client/src/main/java/org/apache/hadoop/hbase/client/ConnectionManager.java
@@ -21,7 +21,6 @@ package org.apache.hadoop.hbase.client;
 import java.io.Closeable;
 import java.io.IOException;
 import java.io.InterruptedIOException;
-import java.lang.reflect.Constructor;
 import java.lang.reflect.UndeclaredThrowableException;
 import java.util.ArrayList;
 import java.util.Date;
@@ -404,24 +403,7 @@ class ConnectionManager {
   static ClusterConnection createConnection(final Configuration conf, final boolean managed,
       final ExecutorService pool, final User user)
   throws IOException {
-    String className = conf.get(HConnection.HBASE_CLIENT_CONNECTION_IMPL,
-      HConnectionImplementation.class.getName());
-    Class<?> clazz = null;
-    try {
-      clazz = Class.forName(className);
-    } catch (ClassNotFoundException e) {
-      throw new IOException(e);
-    }
-    try {
-      // Default HCM#HCI is not accessible; make it so before invoking.
-      Constructor<?> constructor =
-        clazz.getDeclaredConstructor(Configuration.class,
-          boolean.class, ExecutorService.class, User.class);
-      constructor.setAccessible(true);
-      return (ClusterConnection) constructor.newInstance(conf, managed, pool, user);
-    } catch (Exception e) {
-      throw new IOException(e);
-    }
+    return (ClusterConnection) ConnectionFactory.createConnection(conf, managed, pool, user);
   }
 
   /**


Mime
View raw message