The Cloud Bigtable HBase client for Java targets the Apache HBase 1.0 API and later. Version 1.0 of the API included some notable changes from earlier versions of HBase. If you are migrating to Cloud 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 Cloud Bigtable.
To assist with your migration, this page summarizes the most notable changes in the HBase 1.0 API.
In HBase 1.0 and later, instead of relying upon the deprecated
interface, you should use
This class creates objects that implement the new
ConnectionFactory replaces the deprecated
Connection object is a relatively expensive operation. You should
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); // ... connection.close();
In previous versions of HBase, when you manipulated a table, you could specify
the table name as a
byte value. In HBase 1.0 and later, you must
specify the table name by creating an instance of
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 three new interfaces:
org.apache.hadoop.hbase.client.Table: Allows you to work with data in a single table.
org.apache.hadoop.hbase.client.BufferedMutator: Allows you to perform asynchronous batch writes to a table. Use this class instead of calling the
org.apache.hadoop.hbase.client.RegionLocator: Provides access to information about a table's regions.
Connection object to obtain an instance of these interfaces:
Table table = connection.getTable(tableNameObj); BufferedMutator mutator = connection.getBufferedMutator(tableNameObj); RegionLocator regionLocator = connection.getRegionLocator(tableNameObj);
RegionLocator are not
thread-safe. However, these are lightweight objects, so you can create them as
needed within the context of a single thread.
In HBase 1.0, the
HBaseAdmin class is replaced by the
org.apache.hadoop.hbase.client.Admin interface. Because
Cloud Bigtable handles maintenance tasks automatically, many of the methods in
Admin interface are not supported. See Differences between the HBase and
Cloud Bigtable APIs for details.
Connection object to obtain an instance of the
Admin admin = connection.getAdmin();