搜尋
首頁後端開發php教程HBase & thrift & C++缂栫▼_PHP教程

HBase & thrift & C++缂栫▼

HBase & thrift & C++缂栫▼_PHP教程HBase & thrift & C++缂栫▼.pdf

鐩綍

鐩綍1

1.鍓嶈█1

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

2.1.鍚姩thrift2 1

2.2.鍋滄thrift2 1

2.3.鍚姩鍙傛暟2

3.hbase.thrift2

3.1.缂栬瘧hbase.thrift 2

4.thrift_helper.h3

5.绀轰緥浠g爜4

1.鍓嶈█

鏈枃鐩殑鏄粙缁嶄娇鐢?span>C++濡備綍鎿嶄綔HBase銆備粠HBase0.94寮€濮嬶紝HBase鏂板thrift2锛屾湰鏂囧彧浠嬬粛鍜岃璁?/span>thrift2鐩稿叧鐨勩€?/span>hbase-1.1.2浣跨敤鐨?/span>thrift浼拌鏄?/span>thrift-0.9.0鐗堟湰銆?

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

2.1.鍚姩thrift2

鐧诲綍HBasemaster鏈哄櫒锛屾墽琛屼互涓嬪懡浠ゅ惎鍔?/span>thrift2锛?/span>hbase-daemon.shstartthrift2銆?

thrift榛樿鐨勭洃鍚鍙f槸9090锛屽彲浠ラ€氳繃鍙傛暟鈥?span>-p鈥濇寚瀹氬叾瀹冪鍙c€傞粯璁や娇鐢ㄧ殑Server鏄?/span>TThreadPoolServer銆傞粯璁や娇鐢ㄧ殑Protocol鏄?/span>TBinaryProtocol銆?/span>

娉ㄦ剰瀹㈡埛绔娇鐢ㄧ殑Protocol鍜?/span>Transport鍜屾湇鍔$鐨勮淇濇寔涓€鑷达紝鍚﹀垯瀹㈡埛绔湪璋冪敤鏃讹紝鍙兘閬囧埌鈥淓AGAIN(timedout)鈥濈瓑閿欒銆?

2.2.鍋滄thrift2

hbase-daemon.shstopthrift2

2.3.鍚姩鍙傛暟

浣跨敤鈥渉base-daemon.shstartthrift2鈥濇椂锛岃繕鍙互甯︿互涓嬪弬鏁帮細

鍙傛暟鍚?/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

瀹㈡埛绔拰hbasethrift2鐨?/span>Transport鍜?/span>Protocol闇€淇濇寔涓€鑷达紝姣斿瀹㈡埛绔负FramedTransport锛屽垯涔熼渶浠モ€?/span>-f鈥濆惎鍔?/span>hbasethrift2銆?/span>

鍚﹀垯瀹㈡埛绔湪璋冪敤鏃讹紝鍙兘浼氶亣鍒扳€淓AGAIN(timedout)鈥濈瓑閿欒銆?

鍚姩鍙傛暟淇℃伅鏉ユ簮浜庡畼缃戠殑椤甸潰锛?

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

浠ヤ笂鍙傛暟涓嶆槸缁?span>hbase-daemon.sh浣跨敤锛岃€屾槸琚?/span>hbasethrift2浣跨敤锛屽彲浠ユ祻瑙堢浉鍏虫簮浠g爜浜嗚В缁嗚妭锛?/span>

hbase-thrift\src\main\java\org\apache\hadoop\hbase\thrift2\ThriftServer.java

hbase-thrift\src\main\java\org\apache\hadoop\hbase\thrift2\ThriftHBaseServiceHandler.java

?鍚姩绀轰緥锛?

hbase-daemon.shstartthrift2--framed-nonblocking

3.hbase.thrift

hbaser.thrift鏂囦欢鍦?/span>hbase婧愪唬鐮佸寘锛堜互hbase-1.1.2涓轰緥锛変腑鐨勪綅缃細

hbase-thrift\src\main\resources\org\apache\hadoop\hbase\thrift2\hbase.thrift

3.1.缂栬瘧hbase.thrift

淇濇寔鏈哄櫒涓婂凡瀹夎濂?span>thrift锛堢粡娴嬭瘯hbase-1.1.2鍜?/span>thrift-0.9.0鍏煎锛夛紝鐒跺悗浣跨敤涓嬪垪鍛戒护缂栬瘧锛?/span>thrift--gencpp-out.hbase.thrift锛岀紪璇戞垚鍔熷悗锛屼細鍦ㄢ€?span>-out鈥濇寚瀹氱殑鐩綍涓嬬敓鎴愪互涓嬩簲涓枃浠讹細

THBaseService.h

THBaseService.cpp

hbase_types.h

hbase_types.cpp

hbase_constants.h

hbase_constants.cpp

鍏朵腑渚涘鎴风浣跨敤鐨勬槸浣嶄簬鏂囦欢THBaseService.h涓殑绫?/span>THBaseServiceClient銆?

4.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锛屽畠鍙互甯姪绠€鍖栧HBasethrift2鐨勮皟鐢細

//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)%s\n",ex.getType(),ex.what());

//}

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

//{

//MYLOG_ERROR("thriftexception:%s\n",ex.what());

//}

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

//{

//MYLOG_ERROR("thriftexception:%s\n",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

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:%s\n",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::CThriftClientHelper<:thrift2::thbaseserviceclient>hbase_client(hbase_ip,hbase_port);

try

{

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

fprintf(stdout,"connect%s:%dok\n",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::vector<:thrift2::tcolumnvalue>columns_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"]:%s\n",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:%s\n",ex.what());

}

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

{

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

fprintf(stderr,"(%d)%s\n",ex.getType(),ex.what());

}

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

{

fprintf(stderr,"%s\n",ex.what());

}

catch(thrift::TException&ex)

{

fprintf(stderr,"%s\n",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.鍋滄thrift2 1 2.3.鍚姩鍙...
陳述
本文內容由網友自願投稿,版權歸原作者所有。本站不承擔相應的法律責任。如發現涉嫌抄襲或侵權的內容,請聯絡admin@php.cn
可以在PHP會話中存儲哪些數據?可以在PHP會話中存儲哪些數據?May 02, 2025 am 12:17 AM

phpsessionscanStorestrings,數字,數組和原始物。

您如何開始PHP會話?您如何開始PHP會話?May 02, 2025 am 12:16 AM

tostartaphpsession,usesesses_start()attheScript'Sbeginning.1)placeitbeforeanyOutputtosetThesessionCookie.2)useSessionsforuserDatalikeloginstatusorshoppingcarts.3)regenerateSessiveIdStopreventFentfixationAttacks.s.4)考慮使用AttActAcks.s.s.4)

什麼是會話再生,如何提高安全性?什麼是會話再生,如何提高安全性?May 02, 2025 am 12:15 AM

會話再生是指在用戶進行敏感操作時生成新會話ID並使舊ID失效,以防會話固定攻擊。實現步驟包括:1.檢測敏感操作,2.生成新會話ID,3.銷毀舊會話ID,4.更新用戶端會話信息。

使用PHP會話時有哪些性能考慮?使用PHP會話時有哪些性能考慮?May 02, 2025 am 12:11 AM

PHP会话对应用性能有显著影响。优化方法包括:1.使用数据库存储会话数据,提升响应速度;2.减少会话数据使用,只存储必要信息;3.采用非阻塞会话处理器,提高并发能力;4.调整会话过期时间,平衡用户体验和服务器负担;5.使用持久会话,减少数据读写次数。

PHP會話與Cookie有何不同?PHP會話與Cookie有何不同?May 02, 2025 am 12:03 AM

PHPsessionsareserver-side,whilecookiesareclient-side.1)Sessionsstoredataontheserver,aremoresecure,andhandlelargerdata.2)Cookiesstoredataontheclient,arelesssecure,andlimitedinsize.Usesessionsforsensitivedataandcookiesfornon-sensitive,client-sidedata.

PHP如何識別用戶的會話?PHP如何識別用戶的會話?May 01, 2025 am 12:23 AM

phpIdentifiesauser'ssessionSessionSessionCookiesAndSessionId.1)whiwsession_start()被稱為,phpgeneratesainiquesesesessionIdStoredInacookInAcookInAcienamedInAcienamedphpsessIdontheuser'sbrowser'sbrowser.2)thisIdallowSphptpptpptpptpptpptpptpptoretoreteretrieetrieetrieetrieetrieetrieetreetrieetrieetrieetrieetremthafromtheserver。

確保PHP會議的一些最佳實踐是什麼?確保PHP會議的一些最佳實踐是什麼?May 01, 2025 am 12:22 AM

PHP會話的安全可以通過以下措施實現:1.使用session_regenerate_id()在用戶登錄或重要操作時重新生成會話ID。 2.通過HTTPS協議加密傳輸會話ID。 3.使用session_save_path()指定安全目錄存儲會話數據,並正確設置權限。

PHP會話文件默認存儲在哪裡?PHP會話文件默認存儲在哪裡?May 01, 2025 am 12:15 AM

phpsessionFilesArestoredIntheDirectorySpecifiedBysession.save_path,通常是/tmponunix-likesystemsorc:\ windows \ windows \ temponwindows.tocustomizethis:tocustomizEthis:1)useession_save_save_save_path_path()

See all articles

熱AI工具

Undresser.AI Undress

Undresser.AI Undress

人工智慧驅動的應用程序,用於創建逼真的裸體照片

AI Clothes Remover

AI Clothes Remover

用於從照片中去除衣服的線上人工智慧工具。

Undress AI Tool

Undress AI Tool

免費脫衣圖片

Clothoff.io

Clothoff.io

AI脫衣器

Video Face Swap

Video Face Swap

使用我們完全免費的人工智慧換臉工具,輕鬆在任何影片中換臉!

熱工具

SecLists

SecLists

SecLists是最終安全測試人員的伙伴。它是一個包含各種類型清單的集合,這些清單在安全評估過程中經常使用,而且都在一個地方。 SecLists透過方便地提供安全測試人員可能需要的所有列表,幫助提高安全測試的效率和生產力。清單類型包括使用者名稱、密碼、URL、模糊測試有效載荷、敏感資料模式、Web shell等等。測試人員只需將此儲存庫拉到新的測試機上,他就可以存取所需的每種類型的清單。

Atom編輯器mac版下載

Atom編輯器mac版下載

最受歡迎的的開源編輯器

EditPlus 中文破解版

EditPlus 中文破解版

體積小,語法高亮,不支援程式碼提示功能

PhpStorm Mac 版本

PhpStorm Mac 版本

最新(2018.2.1 )專業的PHP整合開發工具

DVWA

DVWA

Damn Vulnerable Web App (DVWA) 是一個PHP/MySQL的Web應用程序,非常容易受到攻擊。它的主要目標是成為安全專業人員在合法環境中測試自己的技能和工具的輔助工具,幫助Web開發人員更好地理解保護網路應用程式的過程,並幫助教師/學生在課堂環境中教授/學習Web應用程式安全性。 DVWA的目標是透過簡單直接的介面練習一些最常見的Web漏洞,難度各不相同。請注意,該軟體中