Support Questions
Find answers, ask questions, and share your expertise
Announcements
Alert: Welcome to the Unified Cloudera Community. Former HCC members be sure to read and learn how to activate your account here.

nodejs integration with hbase rest api

nodejs integration with hbase rest api

Explorer

We have hbase setup with application integrating using java. I need to try and setup a way to have nodejs scripts interact with the tables and finding it hard to get workable resources on how to do this. I found the rest/thrift tutorials but need to test a simple way first before getting any new software installed.

1 - rest api start and test fails

hbase(main):005:0> bin/hbase-daemon.sh start rest 
<a href="http://1xx.xxx.xxx.xx:8080/version">http://1xx.xxx.xxx.xx:8080/version</a>
{
  "status": 404,
  "message": "Not Found"
}

How do I activate the rest API and then also could someone provide resources on how to integrate with hbase. My understanding from the tutorials, is setting up thrift on the same hbase server where it interacts with the REST API. The nodejs scripts however are run on the same machine which does not help me.

Thanks in advance for any suggestions.

EDIT:

Tried the following based on another site:

# hbase rest start

2017-06-07 07:40:32,341 INFO [main] util.VersionInfo: HBase 1.1.2.2.3.4.0-3485 2017-06-07 07:40:32,342 INFO [main] util.VersionInfo: Source code repository .....

org.apache.hadoop.hbase.http.HttpServer.openListeners(HttpServer.java:1009) ... 3 more Exception in thread "main" java.net.BindException: Port in use: 0.0.0.0:8085 at org.apache.hadoop.hbase.http.HttpServer.openListeners(HttpServer.java:1014) at org.apache.hadoop.hbase.http.HttpServer.start(HttpServer.java:950) at org.apache.hadoop.hbase.http.InfoServer.start(InfoServer.java:90) at org.apache.hadoop.hbase.rest.RESTServer.main(RESTServer.java:248) Caused by: java.net.BindException: Address already in use at sun.nio.ch.Net.bind0(Native Method) at sun.nio.ch.Net.bind(Net.java:437) at sun.nio.ch.Net.bind(Net.java:429) at sun.nio.ch.ServerSocketChannelImpl.bind(ServerSocketChannelImpl.java:223) at sun.nio.ch.ServerSocketAdaptor.bind(ServerSocketAdaptor.java:74) at org.mortbay.jetty.nio.SelectChannelConnector.open(SelectChannelConnector.java:216) at org.apache.hadoop.hbase.http.HttpServer.openListeners(HttpServer.java:1009) ... 3 more 2017-06-07 07:40:33,437 INFO [Shutdown] mortbay.log: Shutdown hook executing 2017-06-07 07:40:33,438 INFO [Shutdown] mortbay.log: Shutdown hook complete [

4 REPLIES 4

Re: nodejs integration with hbase rest api

The HBase REST, https://hbase.apache.org/book.html#_rest, and Thrift, https://hbase.apache.org/book.html#_thrift, external APIs are two separate things and do not depend on one-another.

Your first error is because you used the wrong URL. Again, refer to the documentation: https://hbase.apache.org/book.html#_using_rest_endpoints. You want /version/cluster, not /version.

The second error is because you instructed HBase to start an instance of the REST server listening on port 8085 but there was another process already bound to that port. Thus, your new REST server instance failed to start. Consider using a tool like netstat to understand what process is listening on that port already.

Highlighted

Re: nodejs integration with hbase rest api

Explorer

Thank you so much for responding. It's working now and I hope you could answer one more question for me please: to connect to hbase using nodejs, is there a client library that needs to be downloaded or could I just create a script that will be able to make a GET request for a specific record?

Re: nodejs integration with hbase rest api

I am not aware of any NodeJS library which is abstracts the HBase REST API. However, there are numerous libraries and APIs available which you can use to make REST calls.

e.g. https://github.com/request/request

Re: nodejs integration with hbase rest api

Explorer

Thanks Josh. I managed to figure how to get this working but realized that you cannot query with a GET for multiple columns ( at least not aware of a way to do it). The PUT so far does not work for me either. The java library and API works well so not sure why making requests through the API with nodejs is so difficult. But thanks again.

Don't have an account?
Coming from Hortonworks? Activate your account here