2 * Licensed to the Apache Software Foundation (ASF) under one
3 * or more contributor license agreements. See the NOTICE file
4 * distributed with this work for additional information
5 * regarding copyright ownership. The ASF licenses this file
6 * to you under the Apache License, Version 2.0 (the
7 * "License"); you may not use this file except in compliance
8 * with the License. You may obtain a copy of the License at
10 * http://www.apache.org/licenses/LICENSE-2.0
12 * Unless required by applicable law or agreed to in writing, software
13 * distributed under the License is distributed on an "AS IS" BASIS,
14 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15 * See the License for the specific language governing permissions and
16 * limitations under the License.
18 package org
.apache
.hadoop
.hbase
.client
;
20 import java
.io
.Closeable
;
21 import java
.util
.concurrent
.ExecutorService
;
23 import org
.apache
.hadoop
.conf
.Configuration
;
24 import org
.apache
.hadoop
.hbase
.TableName
;
25 import org
.apache
.hadoop
.hbase
.classification
.InterfaceAudience
;
28 * The asynchronous version of Connection.
30 @InterfaceAudience.Public
31 public interface AsyncConnection
extends Closeable
{
34 * Returns the {@link org.apache.hadoop.conf.Configuration} object used by this instance.
36 * The reference returned is not a copy, so any change made to it will affect this instance.
38 Configuration
getConfiguration();
41 * Retrieve a AsyncRegionLocator implementation to inspect region information on a table. The
42 * returned AsyncRegionLocator is not thread-safe, so a new instance should be created for each
43 * using thread. This is a lightweight operation. Pooling or caching of the returned
44 * AsyncRegionLocator is neither required nor desired.
45 * @param tableName Name of the table who's region is to be examined
46 * @return An AsyncRegionLocator instance
48 AsyncTableRegionLocator
getRegionLocator(TableName tableName
);
51 * Retrieve an {@link RawAsyncTable} implementation for accessing a table.
53 * The returned instance will use default configs. Use {@link #getRawTableBuilder(TableName)} if you
54 * want to customize some configs.
56 * This method no longer checks table existence. An exception will be thrown if the table does not
57 * exist only when the first operation is attempted.
58 * @param tableName the name of the table
59 * @return an RawAsyncTable to use for interactions with this table
60 * @see #getRawTableBuilder(TableName)
62 default RawAsyncTable
getRawTable(TableName tableName
) {
63 return getRawTableBuilder(tableName
).build();
67 * Returns an {@link AsyncTableBuilder} for creating {@link RawAsyncTable}.
69 * This method no longer checks table existence. An exception will be thrown if the table does not
70 * exist only when the first operation is attempted.
71 * @param tableName the name of the table
73 AsyncTableBuilder
<RawAsyncTable
> getRawTableBuilder(TableName tableName
);
76 * Retrieve an AsyncTable implementation for accessing a table.
78 * This method no longer checks table existence. An exception will be thrown if the table does not
79 * exist only when the first operation is attempted.
80 * @param tableName the name of the table
81 * @param pool the thread pool to use for executing callback
82 * @return an AsyncTable to use for interactions with this table
84 default AsyncTable
getTable(TableName tableName
, ExecutorService pool
) {
85 return getTableBuilder(tableName
, pool
).build();
89 * Returns an {@link AsyncTableBuilder} for creating {@link AsyncTable}.
91 * This method no longer checks table existence. An exception will be thrown if the table does not
92 * exist only when the first operation is attempted.
93 * @param tableName the name of the table
94 * @param pool the thread pool to use for executing callback
96 AsyncTableBuilder
<AsyncTable
> getTableBuilder(TableName tableName
, ExecutorService pool
);
99 * Retrieve an {@link AsyncAdmin} implementation to administer an HBase cluster.
101 * The returned instance will use default configs. Use {@link #getAdminBuilder()} if you want to
102 * customize some configs.
104 * The admin operation's returned {@code CompletableFuture} will be finished directly in the rpc
105 * framework's callback thread, so typically you should not do any time consuming work inside
107 * @return an {@link AsyncAdmin} instance for cluster administration
109 default AsyncAdmin
getAdmin() {
110 return getAdminBuilder().build();
114 * Returns an {@link AsyncAdminBuilder} for creating {@link AsyncAdmin}.
116 * The admin operation's returned {@code CompletableFuture} will be finished directly in the rpc
117 * framework's callback thread, so typically you should not do any time consuming work inside
120 AsyncAdminBuilder
<RawAsyncHBaseAdmin
> getAdminBuilder();
123 * Retrieve an {@link AsyncAdmin} implementation to administer an HBase cluster.
125 * The returned instance will use default configs. Use {@link #getAdminBuilder(ExecutorService)}
126 * if you want to customize some configs.
127 * @param pool the thread pool to use for executing callback
128 * @return an {@link AsyncAdmin} instance for cluster administration
130 default AsyncAdmin
getAdmin(ExecutorService pool
) {
131 return getAdminBuilder(pool
).build();
135 * Returns an {@link AsyncAdminBuilder} for creating {@link AsyncAdmin}.
136 * @param pool the thread pool to use for executing callback
138 AsyncAdminBuilder
<AsyncHBaseAdmin
> getAdminBuilder(ExecutorService pool
);