Tablestore HBase Client is encapsulated based on HBase Client, and is used in the same way as HBase Client. However, there are still some differences. This topic describes how to migrate data from HBase Client to Tablestore HBase Client.

Dependencies

Tablestore HBase Client 1.2.0 depends on HBase Client 1.2.0 and Tablestore SDK for Java 4.2.1. The following code provides an example on how to configure pom.xml:

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

If you want to use another version of HBase Client or Tablestore SDK for Java, you can use the exclusion tag. In the following example, HBase Client 1.2.1 and Tablestore 4.2.0 are used.

   <dependencies>
        <dependency>
            <groupId>com.aliyun.openservices</groupId>
            <artifactId>tablestore-hbase-client</artifactId>
            <version>1.2.0</version>
            <exclusions>
                <exclusion>
                    <groupId>com.aliyun.openservices</groupId>
                    <artifactId>tablestore</artifactId>
                </exclusion>
                <exclusion>
                    <groupId>org.apache.hbase</groupId>
                    <artifactId>hbase-client</artifactId>
                </exclusion>
            </exclusions>
        </dependency>
        <dependency>
            <groupId>org.apache.hbase</groupId>
            <artifactId>hbase-client</artifactId>
            <version>1.2.1</version>
        </dependency>
        <dependency>
            <groupId>com.aliyun.openservices</groupId>
            <artifactId>tablestore</artifactId>
            <classifier>jar-with-dependencies</classifier>
            <version>4.2.0</version>
        </dependency>
    </dependencies>
 

Tablestore HBase Client 1.2.x is only compatible with HBase Client 1.2.x because there are differences in APIs between HBase Client 1.2.x and other versions.

If you want to use HBase Client 1.1.x, you must use Tablestore HBase Client 1.1.x.

If you want to use HBase Client 0.x.x, see Make Tablestore HBase Client compatible with HBase versions earlier than 1.0.0.

Configuration file

To migrate data from HBase Client to Tablestore HBase Client, you must modify the following parameters in the configuration file:

  • HBase Connection type

    Set Connection to TablestoreConnection.

        <property>
            <name>hbase.client.connection.impl</name>
            <value>com.alicloud.tablestore.hbase.TablestoreConnection</value>
        </property>
     
  • Configuration items of Tablestore

    Tablestore is a cloud service that enables strict permission management. To access Tablestore, you must configure authentication information such as Accesskey pairs.

    • You must configure the following items before you can access Tablestore:

       <property>
                  <name>tablestore.client.endpoint</name>
                  <value></value>
              </property>
              <property>
                  <name>tablestore.client.instancename</name>
                  <value></value>
              </property>
              <property>
                  <name>tablestore.client.accesskeyid</name>
                  <value></value>
              </property>
              <property>
                  <name>tablestore.client.accesskeysecret</name>
                  <value></value>
              </property>
       
    • You can configure the following items as needed:

              <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>
       
      • hbase.client.tablestore.family and hbase.client.tablestore.family.$tablename
        • Tablestore only supports single ColumnFamilies. When you use HBase APIs, you must set the content of the family.

          hbase.client.tablestore.family indicates the global configuration, while hbase.client.tablestore.family.$tablename indicates the configurations of a single table.

        • Rule: 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.
      • tablestore.client.max.connections

        The maximum number of connections. Default value: 300.

      • fs.oss.client.socket.timeout

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

      • tablestore.client.connection.timeout

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

      • tablestore.client.operation.timeout

        The timeout period to access an API. The default value is Integer.MAX_VALUE, indicating that the API never times out.

      • tablestore.client.retries

        The number of retry attempts when a request fails. Default value: 3.