hbase-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From st...@apache.org
Subject git commit: HBASE-11518 doc update for how to create non-shared HConnection (Qiang Tian)
Date Thu, 17 Jul 2014 18:40:26 GMT
Repository: hbase
Updated Branches:
  refs/heads/0.98 e42883f25 -> 562756c72


HBASE-11518 doc update for how to create non-shared HConnection (Qiang Tian)


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

Branch: refs/heads/0.98
Commit: 562756c72840130edce1ab85f63149a337ea9f3b
Parents: e42883f
Author: stack <stack@apache.org>
Authored: Thu Jul 17 11:39:00 2014 -0700
Committer: stack <stack@apache.org>
Committed: Thu Jul 17 11:40:14 2014 -0700

----------------------------------------------------------------------
 .../hadoop/hbase/client/HConnectionManager.java | 40 +++++++++-----------
 1 file changed, 17 insertions(+), 23 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/hbase/blob/562756c7/hbase-client/src/main/java/org/apache/hadoop/hbase/client/HConnectionManager.java
----------------------------------------------------------------------
diff --git a/hbase-client/src/main/java/org/apache/hadoop/hbase/client/HConnectionManager.java
b/hbase-client/src/main/java/org/apache/hadoop/hbase/client/HConnectionManager.java
index 7f5f80b..d76ae2a 100644
--- a/hbase-client/src/main/java/org/apache/hadoop/hbase/client/HConnectionManager.java
+++ b/hbase-client/src/main/java/org/apache/hadoop/hbase/client/HConnectionManager.java
@@ -149,24 +149,18 @@ import com.google.protobuf.ServiceException;
  *   connection.close();
  * }
  * }</pre>
- * <p>The following logic and API will be removed in the future:
  * <p>This class has a static Map of {@link HConnection} instances keyed by
- * {@link Configuration}; all invocations of {@link #getConnection(Configuration)}
- * that pass the same {@link Configuration} instance will be returned the same
- * {@link  HConnection} instance (Adding properties to a Configuration
- * instance does not change its object identity; for more on how this is done see
- * {@link HConnectionKey}).  Sharing {@link HConnection}
- * instances is usually what you want; all clients of the {@link HConnection}
- * instances share the HConnections' cache of Region locations rather than each
- * having to discover for itself the location of meta, etc.  It makes
- * sense for the likes of the pool of HTables class {@link HTablePool}, for
- * instance (If concerned that a single {@link HConnection} is insufficient
- * for sharing amongst clients in say an heavily-multithreaded environment,
- * in practise its not proven to be an issue.  Besides, {@link HConnection} is
- * implemented atop Hadoop RPC and as of this writing, Hadoop RPC does a
- * connection per cluster-member, exclusively).
- *
- * <p>But sharing connections makes clean up of {@link HConnection} instances a little
awkward.
+ * {@link HConnectionKey}; A {@link HConnectionKey} is identified by a set of
+ * {@link Configuration} properties. Invocations of {@link #getConnection(Configuration)}
+ * that pass the same {@link Configuration} instance will return the same
+ * {@link  HConnection} instance ONLY WHEN the set of properties are the same
+ * (i.e. if you change properties in your {@link Configuration} instance, such as RPC timeout,
+ * the codec used, HBase will create a new {@link HConnection} instance. For more details
on
+ * how this is done see {@link HConnectionKey}).
+ * <p>Sharing {@link HConnection} instances is usually what you want; all clients
+ * of the {@link HConnection} instances share the HConnections' cache of Region
+ * locations rather than each having to discover for itself the location of meta, etc.
+ * But sharing connections makes clean up of {@link HConnection} instances a little awkward.
  * Currently, clients cleanup by calling {@link #deleteConnection(Configuration)}. This will
  * shutdown the zookeeper connection the HConnection was using and clean up all
  * HConnection resources as well as stopping proxies to servers out on the
@@ -176,15 +170,15 @@ import com.google.protobuf.ServiceException;
  * subsequently used by another will cause breakage so be careful running
  * cleanup.
  * <p>To create a {@link HConnection} that is not shared by others, you can
- * create a new {@link Configuration} instance, pass this new instance to
- * {@link #getConnection(Configuration)}, and then when done, close it up by
- * doing something like the following:
+ * set property "hbase.client.instance.id" to a unique value for your {@link Configuration}
+ * instance, like the following:
  * <pre>
  * {@code
- * Configuration newConfig = new Configuration(originalConf);
- * HConnection connection = HConnectionManager.getConnection(newConfig);
+ * conf.set("hbase.client.instance.id", "12345");
+ * HConnection connection = HConnectionManager.getConnection(conf);
  * // Use the connection to your hearts' delight and then when done...
- * HConnectionManager.deleteConnection(newConfig, true);
+ * conf.set("hbase.client.instance.id", "12345");
+ * HConnectionManager.deleteConnection(conf, true);
  * }
  * </pre>
  * <p>Cleanup used to be done inside in a shutdown hook.  On startup we'd


Mime
View raw message