1、保证服务端的hbase thrift2服务正常运行。(hbase版本 1.1.2; hadoop版本 2.4.2; 系统 ubuntu14.04 x64)
2、客户端代码: cpp代码、Makefile、 gen-cpp
a、从hbase 安装目录下拷贝hbase2.thrift 到当前目录 (ex:/usr/hdp/2.4.2.0-258/hbase/include/thrift)。
b、用thrift --gen cpp hbase2.thrift 生成c++代码 ,生成位置为hbase2.thrift 同目录下的 gen-cpp(hbase2_constants.cpp hbase2_constants.h hbase2_types.cpp hbase2_types.h THBaseService.cpp THBaseService.h THBaseService_server.skeleton.cpp)。
c 、HbaseClient.cpp文件内容
#include "THBaseService.h"
#include <config.h>
#include <vector>
#include <transport/TSocket.h>
#include <transport/TBufferTransports.h>
#include <protocol/TBinaryProtocol.h>
using namespace std;
using namespace apache::thrift;
using namespace apache::thrift::protocol;