pythonhadoophbasethrifthappybase

Connect to Hbase from Python and happybase / Thrift


I have installed Cloudera Manager Express 5.9.0 installed HBase, with Thrift server running on port 9090 on CentOS 7.3 in a VirtualBox vm.

Please help in figuring out why I am unable to successfully interface via happybase, or help identify next steps to pursue.

I am an experienced Java programmer, learning Python. I have experience using Hbase from Java using the native interface, although not in this specific environment.

Python Script taken virtually directly from happybase howto:

import happybase

connection = happybase.Connection(host='localhost',port=9090,transport='buffered', protocol='compact')

connection.create_table('mytable',
    {'cf1': dict(max_versions=10),
     'cf2': dict(max_versions=1, block_cache_enabled=False),
     'cf3': dict(),  # use defaults
    }
)

Error Message, which I can't find great reference for:

[root@data1 ~]# python testhbase.py
Traceback (most recent call last):
  File "testhbase.py", line 10, in <module> 'cf3': dict(),  # use defaults
  File "build/bdist.linux-x86_64/egg/happybase/connection.py", line 311, in create_table
  File "/usr/lib64/python2.7/site-packages/thriftpy/thrift.py", line 198, in _req return self._recv(_api)
  File "/usr/lib64/python2.7/site-packages/thriftpy/thrift.py", line 210, in _recv fname, mtype, rseqid = self._iprot.read_message_begin()
  File "/usr/lib64/python2.7/site-packages/thriftpy/protocol/compact.py", line 147, in read_message_begin % proto_id)
thriftpy.protocol.exc.TProtocolException: TProtocolException(type=4)
 [root@data1 ~]#

I have Thift web service manager running on port 9095 which reports:

HBase Version   1.2.0-cdh5.9.0, rUnknown    HBase version and revision
Thrift Impl Type    threadpool  Thrift RPC engine implementation type chosen by this Thrift server
Compact Protocol    true    Thrift RPC engine uses compact protocol
Framed Transport    false   Thrift RPC engine uses framed transport

Any help is greatly appreciated. Thank you.


Solution

  • i guess you are not using the supported version of the thrift daemon.

    are you sure the thrift 1 (not thrift2) daemon is used, with the right protocol and transport?