Preparing a thrift server and client

Learn how to prepare a Thrift server and client before using a Thrift Proxy API.

Ensure that the thrift server is configured and running.

  1. Generate Thrift bindings for the language of your choice, using an HBase IDL file, named HBase.thrift that is included as part of HBase.
  2. Copy the Thrift libraries for your language into the same directory as the generated bindings.
  3. Verify that the Thrift compiler version is newer than 0.9.0 by running the thrift -version command. You need to find the Hbase.thrift file from the HBase node or copy it to co-locate with the Thrift compiler.
    In the following Python example, these libraries provide the thrift.transport and thrift.protocol libraries. These commands show how you might generate the Thrift bindings for Python and copy the libraries on a Linux system.
    mkdir HBaseThrift
    cd HBaseThrift/
    thrift -gen py /path/to/Hbase.thrift
    mv gen-py/* .
    rm -rf gen-py/
    mkdir thrift
    cp -rp ~/Downloads/thrift/lib/py/src/* ./thrift/
As a result, the HBase thrift Python bindings appears as follows:
HbaseThrift/
|-- hbased
|   |-- constants.py
|   |-- Hbase.py
|   |-- Hbase-remote
|   |-- __init__.py
|   `-- ttypes.py
|-- __init__.py
`-- thrift
    |-- compat.py
    |-- ext
    |   |-- binary.cpp
    |   |-- binary.h
    |   |-- compact.cpp
    |   |-- compact.h
    |   |-- endian.h
    |   |-- module.cpp
    |   |-- protocol.h
    |   |-- protocol.tcc
    |   |-- types.cpp
    |   `-- types.h
    |-- __init__.py
    |-- protocol
    |   |-- __init__.py
    |   |-- TBase.py
    |   |-- TBinaryProtocol.py
    |   |-- TCompactProtocol.py
    |   |-- THeaderProtocol.py
    |   |-- TJSONProtocol.py
    |   |-- TMultiplexedProtocol.py
    |   |-- TProtocolDecorator.py
    |   `-- TProtocol.py
    |-- server
    |   |-- __init__.py
    |   |-- THttpServer.py
    |   |-- TNonblockingServer.py
    |   |-- TProcessPoolServer.py
    |   `-- TServer.py
    |-- Thrift.py
    |-- TMultiplexedProcessor.py
    |-- transport
    |   |-- __init__.py
    |   |-- sslcompat.py
    |   |-- THeaderTransport.py
    |   |-- THttpClient.py
    |   |-- TSocket.py
    |   |-- TSSLSocket.py
    |   |-- TTransport.py
    |   |-- TTwisted.py
    |   `-- TZlibTransport.py
    |-- TRecursive.py
    |-- TSCons.py
    |-- TSerialization.py
    `-- TTornado.py