How to ensure compatibility with HBase versions earlier than 1.0
Tablestore HBase Client supports the APIs of HBase Client 1.0.0 and later. This topic describes how to make Tablestore HBase Client compatible with the APIs of HBase versions earlier than 1.0.
Background information
HBase Client 1.0.0 introduces major changes that are not compatible with earlier versions.
This topic describes the major changes in HBase 1.0 and explains how to ensure compatibility for users of older HBase versions who want to use Tablestore.
The Connection interface
In HBase 1.0.0 and later, the HConnection interface is deprecated. Instead, you can use the org.apache.hadoop.hbase.client.ConnectionFactory class to create an object that implements the Connection interface. This factory replaces the deprecated ConnectionManager and HConnectionManager.
Creating a Connection object is an expensive operation. However, the Connection object is thread-safe. Therefore, you can create a single Connection object in your program and share it among multiple threads.
In HBase 1.0.0 and later, you must manage the lifecycle of the Connection object and close the connection after you finish using it.
The following is the latest code:
Connection connection = ConnectionFactory.createConnection(config);
// ...
connection.close();The TableName class
In versions earlier than HBase 1.0.0, you can use a string to specify the table name when you create a table. In HBase 1.0.0 and later, you must use the org.apache.hadoop.hbase.TableName class.
The following is the latest code:
String tableName = "MyTable";
// or byte[] tableName = Bytes.toBytes("MyTable");
TableName tableNameObj = TableName.valueOf(tableName);The Table, BufferedMutator, and RegionLocator interfaces
In HBase Client 1.0.0 and later, the HTable interface is deprecated. It is replaced by the Table, BufferedMutator, and RegionLocator interfaces. The following table describes these interfaces.
Interface | Description |
| Performs read, write, and other operations on a single table. |
| Performs asynchronous batch write operations. This corresponds to |
| Provides information about table partitions. |
The Table, BufferedMutator, and RegionLocator interfaces are not thread-safe. However, they are lightweight. You can create a separate object for each thread.
The Admin interface
In HBase Client 1.0.0 and later, the new org.apache.hadoop.hbase.client.Admin interface replaces the HBaseAdmin class. Because Tablestore is an Alibaba Cloud service that automatically handles most O&M operations, many methods in the Admin interface are not supported. For more information, see Features supported by Tablestore HBase Client.
The following code shows an example of how to create an Admin instance from a Connection instance:
Admin admin = connection.getAdmin();