Skip to content

HBase Java API with Oozie

HBase Java API with Oozie

One of the ways to access HBase is through Java API. It can be done in multiple ways, depending on the case and tools used. Here’s how to achieve that with Oozie Java action and Pig action with UDF doing lookups in HBase.

 

Contents

HOW TO

I used CDH 5.8.4 with Kerberos.

For some HBase 1.2.0 Java API basics take a look here.
Pig UDF for HBase lookups can be found here.

 

Oozie

Oozie allows us to execute different actions, but none of them is dedicated strictly for HBase. To use the HBase Java API you can connect to this database with Java or Pig action. In order to make it work you need to:

  • add hbase credentials
  • attach hbase-site.xml as a file option. It should contain at least those parameters:
    • hbase.security.authentication=kerberos, if you use the Kerberos
    • hbase.zookeeper.quorum
    • base.master.kerberos.principal
    • hbase.regionserver.kerberos.principal
  • the same parameters need to be specified as action configuration options. Otherwise the action won’t be able to kick in.
  • attach all needed HBase jar files. These will depend on the functionality you implement in the action. I needed:
    • for pig udf
      – hbase-client.jar
      – hbase-protocol.jar
      – hbase-server.jar
      – hbase-common.jar
    • for java action
      – hbase-common.jar
      – htrace-core.jar

    And don’t forget to attach the program compiled jar 🙂
     
    Here’s how Pig action looks like:

     

    And Java action:

Leave a Reply

Your email address will not be published. Required fields are marked *