Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Python program to connect to HBase via thrift server in Http mode

I am trying to write a simple program to connect to HBase server through thrift which is started in Http mode.(cluster is kerberized ) but I always gets 'read zero bytes error message'

I have refered below links but those examples work only if the thrift server starts in Binary mode (??) https://github.com/joshelser/hbase-thrift1-python-sasl/blob/master/get_row.py,

I did Klist and Kinit everything looks fine and also I have followed below HDP documentation and my setup is correct

https://community.hortonworks.com/articles/87655/start-and-test-hbase-thrift-server-in-a-kerberised.html

I was able to list the tables when I run the below command

hbase org.apache.hadoop.hbase.thrift.HttpDoAsClient host 9090 hbase true

any reference to sample code to connect to HBase through thrift http mode is greatly appreciated

thank you

like image 259
Suresh Avatar asked Sep 11 '18 03:09

Suresh


People also ask

What is Thrift server in HBase?

Thrift is a software framework that allows you to create cross-language bindings. In the context of HBase, Java is the only first-class citizen. However, the HBase Thrift interface allows other languages to access HBase over Thrift by connecting to a Thrift server that interfaces with the Java client.


1 Answers

Error "read 0 bytes" is very generic message that appear when server gets an exception. Better check thrift server logs to get exact error message stack trace. If logs are not getting generated then you need to set up minimal logging to the server side.

import logging
logging.basicConfig(level=logging.DEBUG)

You might also need to increase hbase.thrift.server.socket.read.timeout to keep the connection open for optimal processing time.

You can find the sample python code here.

like image 164
Sourav Avatar answered Sep 22 '22 08:09

Sourav