[SHDP-46] Template for HBase Data Access Created: 22/Jul/09  Updated: 11/Jun/12  Resolved: 11/Jun/12

Status: Resolved
Project: Spring for Apache Hadoop
Component/s: HBase
Affects Version/s: None
Fix Version/s: 1.0.0.M2

Type: New Feature Priority: Major
Reporter: Vaibhav Puranik Assignee: Costin Leau
Resolution: Complete Votes: 13
Labels: None
Remaining Estimate: Not Specified
Time Spent: Not Specified
Original Estimate: Not Specified

Attachments: Java Source File HBaseCallback.java     Java Source File HBaseConfigurationFactoryBean.java     Java Source File HBaseConfigurationFactoryBean.java     Java Source File HBaseConfigurationFactoryBean.java     Java Source File HBaseTemplate.java     Java Source File HBaseTemplate.java     Java Source File HBaseTemplate.java     Java Source File RowCallback.java     Java Source File TableCallback.java     Java Source File TableCallback.java    


HBase is an open source implementation of the BigTable - Google's column store. It's an Apache project and is the integral part of the hadoop family of projects.

Hbase is gaining popularity very fast. Like we have DataSources, Connection Pools and Templates for other persistence technologies, we have written similar classes for Hbase.

(I am attaching the files with this issue. I can create patch if required.)

Here is how one would configure HBase data access beans in their applicationContext-hbase.xml

    <bean id="hbaseTemplate" class="com.gumgum.hbase.HBaseTemplate">
        <constructor-arg ref="hTablePool"/>

    <bean id="hbaseConfiguration" class="com.gumgum.hbase.HBaseConfigurationFactoryBean">
        <property name="hbaseMaster" value="${hbase.master}"/>

    <bean id="hTablePool" class="org.apache.hadoop.hbase.client.HTablePool">
        <constructor-arg ref="hbaseConfiguration"/>
        <constructor-arg value="${hbase.htable.pool.size}"/>

It will be nice if you could include these classes in Spring-DA so that all the spring community using hbase will be benefited.

These classes are based on Hbase 0.20 which is about to release soon.

Comment by Vaibhav Puranik [ 27/Jul/09 ]

Updated version of HBaseConfigurationFactoryBean.java attached. The bean configuration class is rewritten in a way that will allow developers to set any property.

Here is the changed configuration:

<bean id="hbaseConfiguration" class="com.gumgum.hbase.HBaseConfigurationFactoryBean">
<property name="hbaseProperties">
<!-- hbase.zookeeper.quorum must be specified. Other properties are optional-->
<prop key="hbase.zookeeper.quorum">${hbase.zookeeper.quorum}</prop>

Comment by Jay Sellers [ 24/May/11 ]

This task is referenced on the "Supporting Projects" page for hadoop: http://wiki.apache.org/hadoop/SupportingProjects

Is there any update on this, I don't see any activity since 2009.

Comment by Asif Akhtar [ 27/Sep/11 ]

Is there any update on this?? I was looking to create a HBaseTemplate Spring set of classes and stumbled across this.

Comment by Vaibhav Puranik [ 28/Sep/11 ]

Attaching latest code. I have made some changes to make it compatible with latest Hbase versions. The code is tested with HBase 0.90.3

Comment by Vaibhav Puranik [ 28/Sep/11 ]

Here is some sample code on how to use the templates:

Comment by Alex Vasilenko [ 27/Jan/12 ]

Vaibhav, why do you use HTable instead HTableInterface? And I think TableCallback can be generic interface

Comment by Vaibhav Puranik [ 27/Jan/12 ]

Adding modified HBaseTemplate and TableCallback classes. They now use HTableInterface instead of HTable. Thanks for pointing out Alex. (Actually funny thing is that, we contributed HTableInterface to HBase code!)

Comment by Deejay [ 21/Mar/12 ]

What's the status of this work? Spring Data HBase would be incredibly useful for my organisation!

Comment by Vaibhav Puranik [ 21/Mar/12 ]

Deejay, you can download the files attached to this issue and start using them. I am going to put them on github in a week or two. if you have any questions, feel free to comment this issue. We are using that code in production and it works fine.

Comment by Deejay [ 21/Mar/12 ]


Comment by Vaibhav Puranik [ 05/Apr/12 ]

I have made the code open source at https://github.com/vpuranik/SpringHBase. Please feel free to use it. It will work with HBase 0.92.x.

Comment by Costin Leau [ 05/Apr/12 ]

Guys, support for HBase has been added to Spring for Hadoop project - initially on a branch which has been merged into main some days ago [1]. It covers the areas mentioned in this issue and more.
Do take a look, take it for a spin and let us know what missing - feedback and contributions welcome.


[1] https://github.com/SpringSource/spring-hadoop/tree/master/src/main/java/org/springframework/data/hadoop/hbase

Comment by Costin Leau [ 05/Apr/12 ]

Everyone, I've moved the issue under Spring for Apache Hadoop project.

Comment by Mark Pollack [ 23/Apr/12 ]

Few comments on the code as it now sits in spring-hadoop

1. Change the name to use HBaseTemplate and not with lowercase 'b'. This agrees with API naming of HBase itself in http://hbase.apache.org/apidocs/org/apache/hadoop/hbase/util/package-summary.html
2. Add an interface, HBaseOperations, as with other templates to support easier mocking
3. Naming of methods, 'execute' methods should take a callback, but in there are a few in this class that take ResultsExtractor. I think a series of method naming conventions such as findWithRowMapper or findWithResultsExtractor would make the API easier to navigate I think.

Comment by Deejay [ 10/May/12 ]

Are there any plans to write a supporting blog post explaining how to use this?

Comment by Costin Leau [ 11/Jun/12 ]

Support available in M2. Docs available at
http://static.springsource.org/spring-hadoop/docs/snapshot/reference/html/hbase.html (note this is the current shapshot of the upcoming 1.0 M2).

Generated at Fri Jan 24 00:01:46 UTC 2020 using Jira 7.13.8#713008-sha1:1606a5c1e7006e1ab135aac81f7a9566b2dbc3a6.