Using the libhbase Library
libhbase is a JNI-based, thread-safe C library that implements a native HBase client. You can use libhbase to build applications that access HBase.
This page contains the following topics:
- Installing libhbase
- Upgrading libhbase
- Building applications with libhbase
- Configuring the application environment
- Running a libhbase performance test
For examples that show how to use the APIs, see the sample source file.
Installing libhbase
Install libhbase on the nodes from which you will build and run the application.
Complete the following steps to install libhbase from a repository:
- Configure the
repository to point to http://package.ezmeral.hpe.com/releases/MEP/MEP-6.3.0/.IMPORTANTTo access the Data Fabric internet repository, you must specify the email and token of an HPE Passport account. For more information, see Using the HPE Ezmeral Token-Authenticated Internet Repository.
- Based on your operating system, run one of the following commands to install the
package:
- On Red Hat /Centos:
yum install mapr-libhbase
- On SLES:
zypper install mapr-libhbase
- On Ubuntu:
apt-get install mapr-libhbase
- On Red Hat /Centos:
Once the installation completes, the libhbase installation includes the following
directories under /opt/mapr/libhbase/libhbase-<version>
:
/
+---bin/
+---conf/
+---include/
| +--hbase/
+---lib/
| +---native/
+---src
+---examples/
| +---async/
+---test/
+---native/
+---common/
include
folder contains the headers required to build
applications. The lib/native
directory contains shared libraries. Upgrading libhbase
To upgrade to a more recent version of libhbase:
- Install the new version.
- Re-configure the application environment to refer to the new libraries.
Building Applications with libhbase
libhbase should be installed on each node that builds the application.
Note the following items when you build applications with libhbase:
- The headers required to build applications are located under
/opt/mapr/libhbase/libhbase-<version>/include
.
- libhbase shared library is located in the following directory:
/opt/mapr/libhbase/libhbase-<version>/lib/native
.
- Since libhbase uses JNI, you must also link your application against libjvm. In general, the libjvm library is located within the JDK/JRE installation directory.
For example, the following command builds the hello_hbase
application
with the hello_hbase.c
source code:
gcc -o hello_hbase hello_hbase.c -I/opt/mapr/libhbase/libhbase-0.98.7/include -L/opt/mapr/libhbase/libhbase-0.98.7/lib/native -lhbase -L/usr/lib/jvm/java-7-sun/jre/lib/amd64/server -ljvm
Configuring the Application Environment
Complete the following steps to configure the node from which you run the application:
-
Verify that libhbase is installed on the node.
-
Verify that both the libhbase and libjvm shared libraries are in the application’s library search path. The libhbase shared library is located under
/opt/mapr/libhbase/libhbase-<version>/lib/native
. In general, the libjvm library is located within the JDK/JRE installation directory. -
Specify any JARs required by the application with one of the following environment variables:
CLASSPATH
orHBASE_LIB_DIR
. - Specify custom JVM options, such as
-Xmx
, using the environment variableLIBHBASE_OPTS
.
Running a libhbase Performance Test
libhbase 0.98.7 includes a performance test that supports sequential/random gets and puts. In libhbase 0.98.9, the performance test utility also includes support for Zipfian, support for uniform random key generation, and it test for scans. You can run the test using this shell script.