All Products
Search
Document Center

Tablestore:Migrate from HBase Client to Tablestore HBase Client

Last Updated:Jan 20, 2025

Tablestore HBase Client is encapsulated based on HBase Client. Compared with HBase Client, Tablestore HBase Client is used in a similar but differentiated way. This topic describes how to migrate from HBase Client to Tablestore HBase Client.

Procedure

Step 1: Import Tablestore HBase Client dependencies

The following code shows the content in the pom.xml configuration file of Tablestore HBase Client V2.0.12:

 <dependencies>
    <dependency>
        <groupId>com.aliyun.openservices</groupId>
        <artifactId>tablestore-hbase-client</artifactId>
        <version>2.0.12</version>
    </dependency>
</dependencies>		

Step 2: Modify the configuration file

To migrate from HBase Client to Tablestore HBase Client, modify the type of HBase Connection and add the parameters of Tablestore in the hbase-site.xml configuration file.

1. Modify the type of HBase Connection

Set the HBase Connection type to TablestoreConnection.

<property>
    <name>hbase.client.connection.impl</name>
    <value>com.alicloud.tablestore.hbase.TablestoreConnection</value>
</property>				

2. Add the parameters of Tablestore

Tablestore is a cloud service that provides strict permission management. To access Tablestore, you must configure the required parameters such as the AccessKey pair and Tablestore instance. You can configure optional parameters based on your business requirements.

  • Required parameters

    You must configure required parameters such as the AccessKey pair and instance before you can access Tablestore. tablestore.client.endpoint specifies the endpoint of the Tablestore instance that you want to access. tablestore.client.instancename specifies the name of the Tablestore instance that you want to access. tablestore.client.accesskeyid and tablestore.client.accesskeysecret specify the AccessKey ID and AccessKey secret of an Alibaba Cloud account or a Resource Access Management (RAM) user.

    <property>
        <name>tablestore.client.endpoint</name>
        <value>https://exampleinstance.cn-hangzhou.ots.aliyuncs.com</value>
    </property>
    <property>
        <name>tablestore.client.instancename</name>
        <value>exampleinstance</value>
    </property>
    <property>
        <name>tablestore.client.accesskeyid</name>
        <value>*****************</value>
    </property>
    <property>
        <name>tablestore.client.accesskeysecret</name>
        <value>***********</value>
    </property>							
  • Optional parameters

    You can configure optional parameters such as the name of the table that you want to access, the maximum number of connections, and the timeout periods by referring to the following sample code.

    <property>
        <name>hbase.client.tablestore.family</name>
        <value>f1</value>
    </property>
    <property>
        <name>hbase.client.tablestore.family.$tablename</name>
        <value>f2</value>
    </property>
    <property>
        <name>tablestore.client.max.connections</name>
        <value>300</value>
    </property>
    <property>
        <name>tablestore.client.socket.timeout</name>
        <value>15000</value>
    </property>
    <property>
        <name>tablestore.client.connection.timeout</name>
        <value>15000</value>
    </property>
    <property>
        <name>tablestore.client.operation.timeout</name>
        <value>2147483647</value>
    </property>
    <property>
        <name>tablestore.client.retries</name>
        <value>3</value>
    </property>						

    The following table describes the optional parameters.

    Parameter

    Description

    hbase.client.tablestore.family

    Tablestore supports only single-column families. When you call the HBase API, you must specify the content of the family.

    hbase.client.tablestore.family specifies the global configurations, and hbase.client.tablestore.family.$tablename specifies the configurations of a single table.

    For a table named T, search for hbase.client.tablestore.family.T. If the family does not exist, search for hbase.client.tablestore.family. If the family does not exist, use the default value f.

    hbase.client.tablestore.family.$tablename

    tablestore.client.max.connections

    The maximum number of connections. Default value: 300.

    tablestore.client.socket.timeout

    The socket timeout period. Unit: seconds. Default value: 15.

    tablestore.client.connection.timeout

    The connection timeout period. Unit: seconds. Default value: 15.

    tablestore.client.operation.timeout

    The API timeout period. Default value: Integer.MAX_VALUE. The default value specifies that the API never times out.

    tablestore.client.retries

    The number of retry attempts upon a request failure. Default value: 3.

References

For information about how to migrate data from HBase to Tablestore, see Data Integration.