Migrate from HBase Client to Tablestore HBase Client
The Tablestore HBase Client is a wrapper for the HBase Client. It functions in almost the same way as the HBase Client, but with a few differences. This topic describes how to migrate from the HBase Client to the Tablestore HBase Client.
Procedure
Step 1: Add the Tablestore HBase Client dependency
The following code shows the pom.xml configuration for Tablestore HBase Client 2.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 the HBase Client to the Tablestore HBase Client, modify the HBase connection type and add Tablestore configuration items to the hbase-site.xml file.
1. Modify the HBase connection type
Set the connection type to TablestoreConnection.
<property>
<name>hbase.client.connection.impl</name>
<value>com.alicloud.tablestore.hbase.TablestoreConnection</value>
</property> 2. Add Tablestore configuration items
Tablestore is an Alibaba Cloud service that provides strict permission management. To access Tablestore, you must configure required items, such as the AccessKey pair and instance information. You can also configure optional items as needed.
Required items
To access Tablestore, you must configure the AccessKey pair and instance information. The
tablestore.client.endpointparameter specifies the Tablestore endpoint, and thetablestore.client.instancenameparameter specifies the Tablestore instance name. Thetablestore.client.accesskeyidandtablestore.client.accesskeysecretparameters 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 items
The following example shows how to configure optional items, such as the table name, maximum connections, and timeout.
<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 configuration items.
Configuration item
Description
hbase.client.tablestore.family
Tablestore supports only a single column family. The HBase API requires a family item. Use these parameters to provide the content for the family item.
hbase.client.tablestore.familyis the global configuration.hbase.client.tablestore.family.$tablenameis the configuration for a single table.For a table named T, the system first looks for
hbase.client.tablestore.family.T. If not found, it looks forhbase.client.tablestore.family. If that is also not found, the default value `f` is used.hbase.client.tablestore.family.$tablename
tablestore.client.max.connections
The maximum number of connections. The default value is 300.
tablestore.client.socket.timeout
The socket timeout. The default value is 15 seconds.
tablestore.client.connection.timeout
The connection timeout. The default value is 15 seconds.
tablestore.client.operation.timeout
The API timeout. The default value is
Integer.MAX_VALUE. This value means the operation never times out.tablestore.client.retries
The number of retries for a failed request. The default value is 3.
References
For more information about migrating HBase data to Tablestore, see Data Integration service and Use DataX to synchronize HBase data to Tablestore.