hbase-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From chia7...@apache.org
Subject hbase git commit: HBASE-18213 Add documentation about the new async client
Date Mon, 18 Dec 2017 10:54:36 GMT
Repository: hbase
Updated Branches:
  refs/heads/branch-2 67029f93e -> 73942e37d


HBASE-18213 Add documentation about the new async client

Signed-off-by: Chia-Ping Tsai <chia7712@gmail.com>


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

Branch: refs/heads/branch-2
Commit: 73942e37daf93d27aa84fe6b729ac9fc0dae8e6a
Parents: 67029f9
Author: zhangduo <zhangduo@apache.org>
Authored: Mon Dec 18 18:51:05 2017 +0800
Committer: Chia-Ping Tsai <chia7712@gmail.com>
Committed: Mon Dec 18 18:52:06 2017 +0800

----------------------------------------------------------------------
 src/main/asciidoc/_chapters/architecture.adoc | 35 ++++++++++++++++++++++
 1 file changed, 35 insertions(+)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/hbase/blob/73942e37/src/main/asciidoc/_chapters/architecture.adoc
----------------------------------------------------------------------
diff --git a/src/main/asciidoc/_chapters/architecture.adoc b/src/main/asciidoc/_chapters/architecture.adoc
index 72da45a..a4601ca 100644
--- a/src/main/asciidoc/_chapters/architecture.adoc
+++ b/src/main/asciidoc/_chapters/architecture.adoc
@@ -220,6 +220,41 @@ In HBase 2.0 and later, link:http://hbase.apache.org/devapidocs/org/apache/hadoo
 For additional information on write durability, review the link:/acid-semantics.html[ACID
semantics] page.
 
 For fine-grained control of batching of ``Put``s or ``Delete``s, see the link:http://hbase.apache.org/apidocs/org/apache/hadoop/hbase/client/Table.html#batch-java.util.List-java.lang.Object:A-[batch]
methods on Table.
+
+[[async.client]]
+=== Asynchronous Client ===
+
+It is a new API introduced in HBase 2.0 which aims to provide the ability to access HBase
asynchronously.
+
+You can obtain an `AsyncConnection` from `ConnectionFactory`, and then get a asynchronous
table instance from it to access HBase. When done, close the `AsyncConnection` instance(usually
when your program exits).
+
+For the asynchronous table, most methods have the same meaning with the old `Table` interface,
expect that the return value is wrapped with a CompletableFuture usually. We do not have any
buffer here so there is no close method for asynchronous table, you do not need to close it.
And it is thread safe.
+
+There are several differences for scan:
+
+* There is still a `getScanner` method which returns a `ResultScanner`. You can use it in
the old way and it works like the old `ClientAsyncPrefetchScanner`.
+* There is a `scanAll` method which will return all the results at once. It aims to provide
a simpler way for small scans which you want to get the whole results at once usually.
+* The Observer Pattern. There is a scan method which accepts a `ScanResultConsumer` as a
parameter. It will pass the results to the consumer.
+
+Notice that `AsyncTable` interface is templatized. The template parameter specifies the type
of `ScanResultConsumerBase` used by scans, which means the observer style scan APIs are different.
The two types of scan consumers are - `ScanResultConsumer` and `AdvancedScanResultConsumer`.
+
+`ScanResultConsumer` needs a separate thread pool which is used to execute the callbacks
registered to the returned CompletableFuture. Because the use of separate thread pool frees
up RPC threads, callbacks are free to do anything. Use this if the callbacks are not quick,
or when in doubt.
+
+`AdvancedScanResultConsumer` executes callbacks inside the framework thread. It is not allowed
to do time consuming work in the callbacks else it will likely block the framework threads
and cause very bad performance impact. As its name, it is designed for advanced users who
want to write high performance code. See `org.apache.hadoop.hbase.client.example.HttpProxyExample`
for how to write fully asynchronous code with it.
+
+[[async.admin]]
+=== Asynchronous Admin ===
+
+You can obtain an `AsyncConnection` from `ConnectionFactory`, and then get a `AsyncAdmin`
instance from it to access HBase. Notice that there are two `getAdmin` methods to get a `AsyncAdmin`
instance. One method has one extra thread pool parameter which is used to execute callbacks.
It is designed for normal users. Another method doesn't need a thread pool and all the callbacks
are executed inside the framework thread so it is not allowed to do time consuming works in
the callbacks. It is designed for advanced users.
+
+The default `getAdmin` methods will return a `AsyncAdmin` instance which use default configs.
If you want to customize some configs, you can use `getAdminBuilder` methods to get a `AsyncAdminBuilder`
for creating `AsyncAdmin` instance. Users are free to only set the configs they care about
to create a new `AsyncAdmin` instance.
+
+For the `AsyncAdmin` interface, most methods have the same meaning with the old `Admin` interface,
expect that the return value is wrapped with a CompletableFuture usually.
+
+For most admin operations, when the returned CompletableFuture is done, it means the admin
operation has also been done. But for compact operation, it only means the compact request
was sent to HBase and may need some time to finish the compact operation. For `rollWALWriter`
method, it only means the rollWALWriter request was sent to the region server and may need
some time to finish the `rollWALWriter` operation.
+
+For region name, we only accept `byte[]` as the parameter type and it may be a full region
name or a encoded region name. For server name, we only accept `ServerName` as the parameter
type. For table name, we only accept `TableName` as the parameter type. For `list*` operations,
we only accept `Pattern` as the parameter type if you want to do regex matching.
+
 [[client.external]]
 === External Clients
 


Mime
View raw message