Operating hbase with spring-hadoop

Source: Internet
Author: User

Srping is familiar to java web programmers and jdbcTemplate. Let's take a look at the Spring-data-hadoop project, a new member of the Spring family. The Spring-hadoop project should be part of the Spring Data Project (the REST of the Srping data includes combining Spring with JDBC, REST, and mainstream NoSQL ). In fact, what happens when Spring and Hadoop are combined is to unify the configuration of Hadoop components, task deployment, and other things into Spring bean management.

The procedure is as follows:

1. Download and import the required jar package:

                                                                                                        

2. Configure web. xml:

                  contextConfigLocation         classpath:beans.xml                             org.springframework.web.context.ContextLoaderListener                        org.springframework.web.util.IntrospectorCleanupListener                        login.jsp      

3. Configure beans. xml:

                                                                  

4. Copy the hbase-site.xml configuration file to the src directory. The reference content is as follows:

          hbase.rootdir     hdfs://nameservice1/hbase           hbase.client.write.buffer     62914560           hbase.client.pause     1000           hbase.client.retries.number     10           hbase.client.scanner.caching     1           hbase.client.keyvalue.maxsize     62914560           hbase.rpc.timeout     60000           hbase.security.authentication     simple           zookeeper.session.timeout     60000           zookeeper.znode.parent     /hbase           zookeeper.znode.rootserver     root-region-server           hbase.zookeeper.quorum     xinhong-hadoop-56,xinhong-hadoop-52,xinhong-hadoop-53           hbase.zookeeper.property.clientPort     2181    

5. hbase template demo:

Query the data of columns in the column family:

  List<String>         List<String> rows = hbaseTemplate.find(tableName, family,cloumn,  RowMapper<String>              String mapRow(Result result,  rowNum)                                  }

Query a data column of a specified row key:

          String context = hbaseTemplate.get(tableName, "NCEP_p_wa_2014032212_tp_006.nc", family, cloumn,  RowMapper<String>              String mapRow(Result result,  rowNum)                                  }

PS: For details about how to use the RowMapper callback function, refer to http://www.cnblogs.com/zhangyukun/p/4265).html.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.