All Products
Search
Document Center

Tablestore:Make Tablestore HBase Client compatible with HBase Client versions earlier than 1.0

Last Updated:Jan 21, 2025

Tablestore HBase Client supports the operations of HBase Client 1.0.0 and later. This topic describes how to make Tablestore HBase Client compatible with the operations of HBase Client versions earlier than 1.0.

Background information

Compared with earlier versions, HBase Client V1.0.0 has some major changes, which are incompatible with HBase Client of earlier versions.

This topic also describes the major changes to facilitate your operations.

Connection operations

The HConnection operation is deprecated in HBase Client V1.0.0 and later. We recommend that you use org.apache.hadoop.hbase.client.ConnectionFactory to create a class to implement Connection operations, and replace the deprecated ConnectionManager and HConnectionManager with ConnectionFactory.

Creating a Connection object is time-consuming and labor intensive. A Connection object can be securely shared by multiple threads. You can create one Connection object in a program. Multiple threads can share the object.

In HBase Client V1.0.0 and later, you need to manage the lifecycle of Connection objects and close the Connection objects if you no longer require the objects.

The following code is the latest code used to create and close a Connection object:

Connection connection = ConnectionFactory.createConnection(config);
// ...
connection.close();

TableName class

In HBase Client versions earlier than 1.0.0, you can use a table name of the String type when creating a table. HBase Client versions later than 1.0.0 require the org.apache.hadoop.hbase.TableName class.

The following code is the latest code used to create a TableName object to represent the name of a table:

String tableName = "MyTable";
// or byte[] tableName = Bytes.toBytes("MyTable");
TableName tableNameObj = TableName.valueOf(tableName);

Table, BufferedMutator, and RegionLocator operations

In HBase Client V1.0.0 and later, the HTable operation is deprecated and replaced by the Table, BufferedMutator, and RegionLocator operations. The following table describes the Table, BufferedMutator, and RegionLocator operations.

Operation

Configuration

Description

Table

org.apache.hadoop.hbase.client.Table

Used to perform operations on read and write requests on a single table.

BufferedMutator

org.apache.hadoop.hbase.client.BufferedMutator

Used for asynchronous batch write requests. This operation is equivalent to setAutoFlush(boolean) of the HTableInterface operation in earlier versions.

RegionLocator

org.apache.hadoop.hbase.client.RegionLocator

The table partition information.

The Table, BufferedMutator, and RegionLocator operations are not thread-safe. Creating a Table, BufferedMutator, or RegionLocator object is not time-consuming or labor intensive. You can create an object for each thread.

Admin operations

The HBaseAdmin operation is replaced by org.apache.hadoop.hbase.client.Admin in HBase Client V1.0.0 and later. Tablestore is a cloud service that automatically processes most O&M operations. Therefore, most Admin operations are not supported by Tablestore. For more information, see Features supported by Tablestore HBase Client.

The following code shows how to create an Admin object by using a Connection object:

Admin admin = connection.getAdmin();