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

Compared with earlier versions, HBase 1.0.0 has some major changes, which are incompatible with HBase of earlier versions.

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

Connections

HConnection is deprecated in HBase 1.0.0 and later. We recommend that you use org.apache.hadoop.hbase.client.ConnectionFactory to create a class to implement Connections, replacing the deprecated ConnectionManager and HConnectionManager with ConnectionFactory.

Connection creation is a heavy-weight operation. Connection implementations are thread-safe, so that the client can create a connection once, and share it with different threads.

For HBase 1.0.0 and later, you must manage the lifecycle of the connection and close the connection after use.

The latest code used to create a connection is as follows:

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

TableName class

If you use HBase versions earlier than 1.0.0, you can specify a STRING-type table name when you create a table. For HBase 1.0.0 and later, you must use the org.apache.hadoop.hbase.TableName class.

The latest code used to specify a STRING-type table name is as follows:

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

Table, BufferedMutator, and RegionLocator APIs

The HTable API is replaced by the Table, BufferedMutator, and RegionLocator APIs in HBase 1.0.0 and later.

  • org.apache.hadoop.hbase.client.Table: performs read and write operations on a single table.

  • org.apache.hadoop.hbase.client.BufferedMutator: writes data asynchronously. This API corresponds to setAutoFlush(boolean) of the HTableInterface API of the earlier HBase versions.

  • org.apache.hadoop.hbase.client.RegionLocator: indicates the partition information of the table.

The Table, BufferedMutator, and RegionLocator APIs are not thread-safe. However, they are lightweight and can be used to create an object for each thread.

Admin API

The HBaseAdmin API is replaced by org.apache.hadoop.hbase.client.Admin in HBase 1.0.0 and later. Tablestore is a cloud service, and most Tablestore O&M API operations are automatically processed. Therefore, most Admin API operations are not supported by Tablestore. For more information, see Differences between Tablestore and HBase.

Use a connection instance to create an admin instance:

Admin admin = connection.getAdmin();