Migrate from earlier HBase versions

The Cloud Bigtable HBase client for Java targets versions 1.x and 2.x of the Apache HBase API. Version 1.0 of the API included some notable changes from earlier versions of HBase. If you are migrating to Bigtable from HBase, and your application targets an older version of the HBase API, you will need to update your application to make it compatible with Bigtable.

To assist with your migration, this page summarizes the most notable changes in the HBase 1.0 API.

Connection interface

In HBase 1.0 and later, instead of relying upon the deprecated HConnection interface, you should use org.apache.hadoop.hbase.client.ConnectionFactory. This class creates objects that implement the new Connection interface. ConnectionFactory replaces the deprecated classes ConnectionManager and HConnectionManager.

Creating a Connection object is a relatively expensive operation. You should create one Connection object per process and share the object as needed. Connection objects are thread-safe.

In addition, be sure to close the connection once you are done using it. In HBase 1.0 and later, it is the application's responsibility to manage the lifecycle of the connection.

Your updated code should look similar to the following example:

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

TableName class

In previous versions of HBase, when you manipulated a table, you could specify the table name as a String or byte[] value. In HBase 1.0 and later, you must specify the table name by creating an instance of org.apache.hadoop.hbase.TableName:

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

Table, BufferedMutator, and RegionLocator interfaces

In HBase 1.0, the HTable class is replaced by the following interfaces:

Use a Connection object to obtain an instance of these interfaces:

Table table = connection.getTable(tableNameObj);
BufferedMutator mutator = connection.getBufferedMutator(tableNameObj);
RegionLocator regionLocator = connection.getRegionLocator(tableNameObj);

Instances of Table, BufferedMutator, and RegionLocator are not thread-safe. However, these are lightweight objects, so you can create them as needed within the context of a single thread.

Admin interface

In HBase 1.0, the HBaseAdmin class is replaced by the org.apache.hadoop.hbase.client.Admin interface. Because Bigtable handles maintenance tasks automatically, many of the methods in the Admin interface are not supported. See Differences between the HBase and Bigtable APIs for details.

Use a Connection object to obtain an instance of the Admin interface:

Admin admin = connection.getAdmin();