The previous recipe introduced the command-line interface for HBase. This recipe demonstrates how we can use the Java API to interact with HBase.
This recipe requires an Apache HBase installation integrated with a Hadoop YARN cluster. Make sure to start all the configured HBase Master and RegionServer processes before we begin.
The following step executes an HBase Java client to store and retrieve data from an HBase table.
Run the HBaseClient
Java program by running the following command from the chapter 7
folder of the sample source repository:
$ gradle execute HBaseClient
The source code for the preceding Java program is available in the chapter7/src/chapter7/hbase/HBaseClient.java
file in the source repository. The following code creates an HBase configuration object and then creates a connection to the test
HBase table. This step obtains the HBase hostnames and ports using ZooKeeper. In high throughput...