Table of Contents
HBase & thrift & C 炂栫▼
鐩綍
3.hbase.thrift
Qiyi寔chain coax渒渓婂fan瀹夎濂?span>thrift曰堢粡Xian嬭瘯hbase-1.1.2鍜?/span>thrift-0.9.0鍏锛Thrift--gencpp-out.hbase.thrift -out:
5.绀淥淠g爜
Home Backend Development PHP Tutorial HBase & thrift & C 炠栫▼_PHP Tutorial

HBase & thrift & C 炠栫▼_PHP Tutorial

Jul 12, 2016 am 08:59 AM
android

HBase & thrift & C 炂栫▼

HBase & thrift & C 炠栫▼_PHP TutorialHBase & thrift & C 炂栫▼.pdf

鐩綍

鐩綍1

1.鍓嶈█1

2.钖姩鍜屽仠姝?span>thrift2 1

2.1.钖姩thrift2 1

2.2.Thrift2 1

2.3.hbase.thrift 2

4.thrift_helper.h3

5.绀淥浠g爜4

1.铓嶈█

Chain枃What is the value of HBase?span>C? Brilliant ?/span>thrift2_thrift_hbase-1.1.2_thrift_thrift_0.9.0_thrift_hbase-1.1.2

2.Thrift2

2.1.thrift2

The HBasemaster chain is connected to浠ゅ惎锷?/span>thrift2锛?/span>hbase-daemon.shstartthrift2銆?

thrift hazelnut鄄勭洃钖鍙f槸9090锛屽彲浠ラ€氲tension四暟鈥?span>-p鈥濇寚瀹氩叾瀹卂鍙c€卞粯璁やJiao鐢ㄧ殑Server鄄?/span>TThreadPoolServer銆邞粯璁や Jiao鐢ㄧ殑Protocol鏄?/ span> TBinaryProtocol銆?/span>

娉ㄦ剰瀹㈡埛绔小鐢ㄧ殑Protocol鍜?/span>Transport鍜屾湇锷$鄄勮俇寔涓€銊达纴钖﹀寯瀹㈡埛绔湪湋卂椤镞雹纴鍙兘阆囧埌鈥淓AGAIN(timedout)鈥戈瓑阌抾銆?

2.2. Guocangthrift2

hbase-daemon.shstopthrift2

2.3.弬鏁狠狠

9090 tr>
鍙傛暟钖?/span>

鏄惁樿

鍙傛暟璇ancun

-h,--help

鍙傛暟鍚?/span>

鏄惁榛樿

鍙傛暟璇存槑

-h,--help

鏄剧ず甯姪淇℃伅

-b,--bind

缁戝畾鎸囧畾鍦板潃锛屼絾涓嶆敮鎸?span>TNonblockingServer鍜?/span>THsHaServer锛屼袱鑰呮€绘槸浣跨敤鈥?/span>0.0.0.0鈥?/span>

-p,--port

9090

缁戝鎸囧畾绔彛锛岄粯璁や负9090

-f,--framed

浣跨敤TFramedTransport

-c,--compact

浣跨敤TCompactProtocol锛岄粯璁ゆ槸TBinaryProtocol

-threadpool

鏄?/span>

浣跨敤TThreadPoolServer锛屼负榛樿Server

-nonblocking

浣跨敤瀹炵幇浜?span>FramedTransport鐨?/span>TNonblockingServer

-hsha

浣跨敤瀹炵幇浜?span>FramedTransport鐨?/span>THsHaServer

鏄剧ず宁姪奇℃伅
-b,--bind 缁戝畾鎸囧畾鍦 Board潃锛屼絶涶嶆镮鸸?span>TNonblockingServer鍜?/span>THsHaServer锛屼袱Key呮€painting槸汸袤鈥?/span>0.0.0.0鈥?/span>
-p,--port缁戝鎸囧畾绔彛锛岲粯璁やnegative9090
-f,--framed Huan Kuao TFramedTransport
-c,--compact HTCompactProtocol锛岄粯璁ゆ槸TBinaryProtocol
-threadpool 鏄?/span> Huan Cross-threadPoolServerServer
-nonblocking Huancuan敤瀹炵絇浜?span>FramedTransport鄄?/span>TNonblockingServer
-hsha

瀹㈡埛绔拰hbasethrift2鄄?/span>Transport鍜?/span>Protocol黑€簿濇寔涓€镊达纴秣斿瀹㈡埛绔negative FramedTransport锛屽寯涔熼渶浠モ€?/span>-f鈥濆掎锷?/span>hbasethrift2銆?/span>

钖﹀垯瀹㈡埛绔湪璋卂椤镞讹纴鍙 AGAIN (timedout) AGAIN(timedout)?

annihilate

https://hbase.apache.org/devapidocs/org/apache/hadoop/hbase/thrift2/package-summary.html銆?

hbase-daemon.sh |爜朜 WuВ缁woo妭锛?/span>

hbase-thriftsrcmainjavaorgapachehadoophbasethrift2ThriftServer.java

hbase-thriftsrcmainjavaorgapachehadoophbasethrift2ThriftHBaseServiceHandler.java

? Hbase-daemon.shstartthrift2--framed-nonblocking

hbase-daemon.shstartthrift2--framed-nonblocking

3.hbase.thrift

hbase.thrift hbase Jing 镰 佸 佸 锛堜 锛堜 锛堜 锛堜 h h h h h 緥锛変 镄勪綅缃 镄勪綅缃 镄勪綅缃 镄勪綅缃 镄勪綅缃

HBase-Thriftsrcmain base .thrift

Qiyi寔chain coax渒渓婂fan瀹夎濂?span>thrift曰堢粡Xian嬭瘯hbase-1.1.2鍜?/span>thrift-0.9.0鍏锛Thrift--gencpp-out.hbase.thrift -out:

THBaseService.h

THBaseService.cpp hbase_types.h

hbase_types.cpp

hbase_constants.h

hbase_constants.cpp

鍏多腑渚涘鎴风Thrift_helper.h

Thrift_helper.h

Thrift_helper.h ?span>C 瀹㈡埛绔殑炂栫▼锛屽彲浠ヤ小鐢?/span>thrift_helper.h锛?/span>

https://github.com/eyjian/mooon/ blob/master/common_library/include/mooon/net/thrift_helper. h :0pt 5.4pt;">

//thrift瀹㈡埛绔緟锷╃是

//

//淥啤礀淥锛?/span>

//thrift瀹㈡埛绔緟鍔╃被

//

//浣跨敤绀轰緥锛?/span>

//mooon::net::CThriftClientHelperclient(rpc_server_ip,rpc_server_port);

//try

//{

//client.connect();

//client->foo();

//}

//catch(apache::thrift::transport::TTransportException&ex)

//{

//MYLOG_ERROR("thriftexception:(%d)%sn",ex.getType(),ex.what());

//}

//catch(apache::thrift::transport::TApplicationException&ex)

//{

//MYLOG_ERROR("thriftexception:%sn",ex.what());

//}

//catch(apache::thrift::TException&ex)

//{

//MYLOG_ERROR("thriftexception:%sn",ex.what());

//}

//Transport闄ら粯璁ょ殑TFramedTransport(TBufferTransports.h)锛岃繕鍙€夋嫨锛?/span>

//TBufferedTransport(TBufferTransports.h)

//THttpTransport

//TZlibTransport

//TFDTransport(TSimpleFileTransport)

//

//Protocol闄ら粯璁ょ殑apache::thrift::protocol::TBinaryProtocol锛岃繕鍙€夋嫨锛?/span>

//TCompactProtocol

//TJSONProtocol

//TDebugProtocol

template

classProtocol=apache::thrift::protocol::TBinaryProtocol,

classTransport=apache::thrift::transport::TFramedTransport>

classCThriftClientHelper

//mooon::net::CThriftClientHelperclient( rpc_server_ip,rpc_server_port);//try//{//client.connect();//client->foo ();//}//catch(apache::thrift::transport::TTransportException&ex)//{// MYLOG_ERROR("thriftexception:(%d)%sn",ex.getType(),ex.what());//}//catch(apache::thrift: :transport::TApplicationException&ex)//{//MYLOG_ERROR("thriftexception:%sn",ex.what());//}//catch(apache::thrift::TException&ex)//{//MYLOG_ERROR("thriftexception:%sn",ex.what());//}//TransportTransport(TBufferTransports.h)Transport(TBufferTransports.h) TBufferedTransport(TBufferTransports.h)//THttpTransport//TZlibTransport//TFDTransport(TSimpleFileTransport)// //Protocol 闄ら粯璁ょ殑apache::thrift::protocol::TBinaryProtocol锛岃缮鍙€夋嫨锛?/span>//TCompactProtocol//TJSONProtocol //TDebugProtocoltemplate<🎜>classProtocol=apache::thrift::protocol::TBinaryProtocol,<🎜><🎜>classTransport=apache::thrift ::transport::TFramedTransport>classCThriftClientHelper

5.绀淥淠g爜

//HBasethrift2C 缂栫▼绀轰緥

#include"THBaseService.h"

#include//PRIu64

#include

#include

#include

//璇锋敞鎰忓鎴风浣跨敤鐨則hrift鐨凾ransport鍜孭rotocol瑕佸拰hbasethrift2鏈嶅姟绔繚鎸佷竴鑷达紝

//鍚﹀垯璋冪敤鏃讹紝鍙兘鎬绘槸鎶ヨ秴鏃讹紝鎴栧叾瀹冮敊璇紒锛侊紒

//

//杩愯涔嬪墠锛岃閫氳繃HBaseshell鍒涘缓濂借〃锛歝reate'test','cf1','cf2'

//鎴栨寚瀹氱増鏈暟锛歝reate'test',{NAME=>'cf1',VERSIONS=>2},{NAME=>'cf2',VERSIONS=>3}

//鍒犻櫎琛紝鎸夐『搴忔墽琛屼互涓嬩袱鏉Baseshell鍛戒护锛?/span>

//disable'test'

//drop'test'

STRING_ARG_DEFINE(hbase_ip,"192.168.0.1","hbasethriftip");

INTEGER_ARG_DEFINE(uint16_t,hbase_port,9090,1000,50000,"hbasethriftport");

intmain(intargc,char*argv[])

{

std::stringerrmsg;

if(!mooon::utils::parse_arguments(argc,argv,&errmsg))

{

fprintf(stderr,"parametererror:%sn",errmsg.c_str());

exit(1);

}

usingnamespaceapache;

usingnamespaceapache::hadoop;

std::stringhbase_ip=mooon::argument::hbase_ip->value();

uint16_thbase_port=mooon::argument::hbase_port->value();

mooon::net::CThriftClientHelperhbase_client(hbase_ip,hbase_port);

try

{

hbase_client.connect();//杩炴帴hbasethrift2server

fprintf(stdout,"connect%s:%dokn",hbase_ip.c_str(),hbase_port);

std::stringtablename="test";//琛ㄥ悕锛岀‘淇濊繍琛屼箣鍓嶅凡鍒涘缓濂?/span>

std::stringrowkey="row1";//琛孠ey

std::stringfamily="cf1";//渚嬫棌鍚?/span>

std::stringcolumnname="f1";//渚嬪悕

std::stringcolumnvalue="value1";//渚嬪€?/span>

//鎻掑叆鍙傛暟璁剧疆

std::vectorcolumns_value(1);

columns_value[0].__set_family(family);

columns_value[0].__set_qualifier(columnname);

columns_value[0].__set_value(columnvalue);

hbase::thrift2::TPutput;

put.__set_row(rowkey);

put.__set_columnValues(columns_value);

hbase_client->put(tablename,put);//鎻掑叆锛屽嚭閿欐姏寮傚父hbase::thrift2::TIOError

//鏌ヨ鍙傛暟璁剧疆

hbase::thrift2::TGetinput;

input.__set_row(rowkey);

hbase::thrift2::TResultresult;//鏌ヨ缁撴灉瀛樻斁鍦ㄨ繖閲?/span>

hbase_client->get(result,tablename,input);//鏌ヨ锛屽嚭閿欐姏寮傚父hbase::thrift2::TIOError

//鏄剧ず鏌ヨ缁撴灉

for(inti=0;i(result.columnValues.size()); i)

{

consthbase::thrift2::TColumnValue&column_value_ref=result.columnValues[i];

fprintf(stdout,"family[%s]/qualifier[%s]/timestamp[%"PRIu64"]:%sn",column_value_ref.family.c_str(),

column_value_ref.qualifier.c_str(),

column_value_ref.timestamp,

column_value_ref.value.c_str());

}

}

catch(hbase::thrift2::TIOError&ex)

{

fprintf(stderr,"IOError:%sn",ex.what());

}

catch(apache::thrift::transport::TTransportException&ex)

{

//濡傛灉鍜屾湇鍔$鐨凾ransport鍜孭rotocol涓嶅悓锛岃繖閲岀殑閿欒鏄€淓AGAIN(timedout)鈥?/span>

fprintf(stderr,"(%d)%sn",ex.getType(),ex.what());

}

catch(apache::thrift::TApplicationException&ex)

{

fprintf(stderr,"%sn",ex.what());

}

catch(thrift::TException&ex)

{

fprintf(stderr,"%sn",ex.what());

}

return0;

}

www.bkjia.comtruehttp: //www.bkjia.com/PHPjc/1096388.htmlTechArticleHBase C 炂栫▼ HBase thrift C 炂栫▼.pdf 鐩綍鐩綍1 1.铓嶈█1 2.钖姩鍜屽仠姝?span>thrift2 1 2.1.钖姩thrift2 1 2.2.Guocangthrift2 1 2.3.钖姩鍙...
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn

Hot AI Tools

Undresser.AI Undress

Undresser.AI Undress

AI-powered app for creating realistic nude photos

AI Clothes Remover

AI Clothes Remover

Online AI tool for removing clothes from photos.

Undress AI Tool

Undress AI Tool

Undress images for free

Clothoff.io

Clothoff.io

AI clothes remover

AI Hentai Generator

AI Hentai Generator

Generate AI Hentai for free.

Hot Tools

Notepad++7.3.1

Notepad++7.3.1

Easy-to-use and free code editor

SublimeText3 Chinese version

SublimeText3 Chinese version

Chinese version, very easy to use

Zend Studio 13.0.1

Zend Studio 13.0.1

Powerful PHP integrated development environment

Dreamweaver CS6

Dreamweaver CS6

Visual web development tools

SublimeText3 Mac version

SublimeText3 Mac version

God-level code editing software (SublimeText3)

New report delivers damning assessment of rumoured Samsung Galaxy S25, Galaxy S25 Plus and Galaxy S25 Ultra camera upgrades New report delivers damning assessment of rumoured Samsung Galaxy S25, Galaxy S25 Plus and Galaxy S25 Ultra camera upgrades Sep 12, 2024 pm 12:23 PM

In recent days, Ice Universe has been steadily revealing details about the Galaxy S25 Ultra, which is widely believed to be Samsung's next flagship smartphone. Among other things, the leaker claimed that Samsung only plans to bring one camera upgrade

Samsung Galaxy S25 Ultra leaks in first render images with rumoured design changes revealed Samsung Galaxy S25 Ultra leaks in first render images with rumoured design changes revealed Sep 11, 2024 am 06:37 AM

OnLeaks has now partnered with Android Headlines to provide a first look at the Galaxy S25 Ultra, a few days after a failed attempt to generate upwards of $4,000 from his X (formerly Twitter) followers. For context, the render images embedded below h

IFA 2024 | TCL\'s NXTPAPER 14 won\'t match the Galaxy Tab S10 Ultra in performance, but it nearly matches it in size IFA 2024 | TCL\'s NXTPAPER 14 won\'t match the Galaxy Tab S10 Ultra in performance, but it nearly matches it in size Sep 07, 2024 am 06:35 AM

Alongside announcing two new smartphones, TCL has also announced a new Android tablet called the NXTPAPER 14, and its massive screen size is one of its selling points. The NXTPAPER 14 features version 3.0 of TCL's signature brand of matte LCD panels

Vivo Y300 Pro packs 6,500 mAh battery in a slim 7.69 mm body Vivo Y300 Pro packs 6,500 mAh battery in a slim 7.69 mm body Sep 07, 2024 am 06:39 AM

The Vivo Y300 Pro just got fully revealed, and it's one of the slimmest mid-range Android phones with a large battery. To be exact, the smartphone is only 7.69 mm thick but features a 6,500 mAh battery. This is the same capacity as the recently launc

Samsung Galaxy S24 FE billed to launch for less than expected in four colours and two memory options Samsung Galaxy S24 FE billed to launch for less than expected in four colours and two memory options Sep 12, 2024 pm 09:21 PM

Samsung has not offered any hints yet about when it will update its Fan Edition (FE) smartphone series. As it stands, the Galaxy S23 FE remains the company's most recent edition, having been presented at the start of October 2023. However, plenty of

New report delivers damning assessment of rumoured Samsung Galaxy S25, Galaxy S25 Plus and Galaxy S25 Ultra camera upgrades New report delivers damning assessment of rumoured Samsung Galaxy S25, Galaxy S25 Plus and Galaxy S25 Ultra camera upgrades Sep 12, 2024 pm 12:22 PM

In recent days, Ice Universe has been steadily revealing details about the Galaxy S25 Ultra, which is widely believed to be Samsung's next flagship smartphone. Among other things, the leaker claimed that Samsung only plans to bring one camera upgrade

Xiaomi Redmi Note 14 Pro Plus arrives as first Qualcomm Snapdragon 7s Gen 3 smartphone with Light Hunter 800 camera Xiaomi Redmi Note 14 Pro Plus arrives as first Qualcomm Snapdragon 7s Gen 3 smartphone with Light Hunter 800 camera Sep 27, 2024 am 06:23 AM

The Redmi Note 14 Pro Plus is now official as a direct successor to last year'sRedmi Note 13 Pro Plus(curr. $375 on Amazon). As expected, the Redmi Note 14 Pro Plus heads up the Redmi Note 14 series alongside theRedmi Note 14and Redmi Note 14 Pro. Li

iQOO Z9 Turbo Plus: Reservations begin for the potentially beefed-up series flagship iQOO Z9 Turbo Plus: Reservations begin for the potentially beefed-up series flagship Sep 10, 2024 am 06:45 AM

OnePlus'sister brand iQOO has a 2023-4 product cycle that might be nearlyover; nevertheless, the brand has declared that it is not done with itsZ9series just yet. Its final, and possibly highest-end,Turbo+variant has just beenannouncedas predicted. T

See all articles