OBKV-HBase is compatible with HBase 1.x and 2.x versions. This topic explains how to migrate your business code from the HBase client to the OBKV-HBase client by updating only the configuration files.
Preparations
If you have not performed schema migration using OceanBase Migration Service (OMS), and the corresponding tables from your original client code have not been created in OBServer, see Connect to the cluster using the OBKV-HBase Java client to create the required OBKV-HBase tables.
Migrate code
Add OBKV-HBase client dependencies
Add the OBKV-HBase client dependency to your project's pom.xml file. If you previously used HBase 1.x, select the matching OBKV-HBase 1.x.x version. If you used HBase 2.x, use the OBKV-HBase 2.x.x version.
<dependencies>
<dependency>
<groupId>com.oceanbase</groupId>
<artifactId>obkv-hbase-client</artifactId>
<version>2.1.0</version>
</dependency>
</dependencies>
Notice
- Try to use the latest version of the jar package, as older versions may not support newer server releases.
- The version number shown here may not be the latest. Check the [central repository](https://mvnrepository.com/artifact/com.oceanbase/obkv-hbase-client) for the most recent OBKV-HBase release and update the version number accordingly.
Set OBKV-HBase client connection parameters
In this step, you need to set the connection type to OHConnectionImpl in the OBKV-HBase client configuration file and add the relevant OBKV-HBase connection parameters:
- If your current HBase client uses org.apache.hadoop.hbase.HBaseConfiguration, update the
hbase-site.xmlconfiguration file. - If your current HBase client uses org.apache.hadoop.conf.Configuration, update the
core-site.xmlconfiguration file.
Change the connection type
Change the HBase connection implementation to OHConnectionImpl. All connections created through ConnectionFactory will then use OHConnectionImpl.
<configuration>
<property>
<name>hbase.client.connection.impl</name>
<value>com.alipay.oceanbase.hbase.util.OHConnectionImpl</value>
</property>
</configuration>
Add OBKV-HBase client connection parameters
Next, add the OBKV-HBase connection parameters to initialize OHConnectionImpl. The following example uses the ODP mode (the parameters required for direct connection mode are different). For details about these parameters, see the sections "Cloud mode configuration (public cloud)" and "Direct connection mode configuration (on-premises deployment)" in Connect to the cluster using the OBKV-HBase client.
<configuration>
<property>
<name>hbase.oceanbase.fullUserName</name>
<value>your user name</value>
</property>
<property>
<name>hbase.oceanbase.password</name>
<value>your user password</value>
</property>
<property>
<name>hbase.oceanbase.odpAddr</name>
<value>your odp addr</value>
</property>
<property>
<name>hbase.oceanbase.odpPort</name>
<value>3307</value>
</property>
<property>
<name>hbase.oceanbase.odpMode</name>
<value>true</value>
</property>
<property>
<name>hbase.oceanbase.database</name>
<value>your database</value>
</property>
</configuration>