Book Image

Hadoop MapReduce v2 Cookbook - Second Edition: RAW

Book Image

Hadoop MapReduce v2 Cookbook - Second Edition: RAW

Overview of this book

Table of Contents (19 chapters)
Hadoop MapReduce v2 Cookbook Second Edition
Credits
About the Author
Acknowledgments
About the Author
About the Reviewers
www.PacktPub.com
Preface
Index

Data random access using Java client APIs


The previous recipe introduced the command-line interface for HBase. This recipe demonstrates how we can use the Java API to interact with HBase.

Getting ready

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.

How to do it...

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

How it works...

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...