HBase & thrift & C 炂栫▼

鐩綍
鐩綍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.Thrift22.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. Guocangthrift2hbase-daemon.shstopthrift22.3.弬鏁狠狠鍙傛暟钖?/span> | 鏄惁樿 | 鍙傛暟璇ancun | |||||||||||||||||||||||||||
-h,--help
|
鏄剧ず宁姪奇℃伅 | ||||||||||||||||||||||||||||
-b,--bind | 缁戝畾鎸囧畾鍦 Board潃锛屼絶涶嶆镮鸸?span>TNonblockingServer鍜?/span>THsHaServer锛屼袱Key呮€painting槸汸袤鈥?/span>0.0.0.0鈥?/span> | ||||||||||||||||||||||||||||
-p,--port | 9090缁戝鎸囧畾绔彛锛岲粯璁やnegative9090 | ||||||||||||||||||||||||||||
-f,--framed | Huan Kuao TFramedTransport | ||||||||||||||||||||||||||||
-c,--compact | HTCompactProtocol锛岄粯璁ゆ槸TBinaryProtocol | ||||||||||||||||||||||||||||
-threadpool | 鏄?/span> | Huan Cross-threadPoolServerServer | |||||||||||||||||||||||||||
-nonblocking | Huancuan敤瀹炵絇浜?span>FramedTransport鄄?/span>TNonblockingServer | tr>||||||||||||||||||||||||||||
-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.thrifthbase.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> |
|
5.绀淥淠g爜
//HBasethrift2C 缂栫▼绀轰緥 #include"THBaseService.h" #include #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::CThriftClientHelper<:thrift2::thbaseserviceclient>hbase_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::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 { 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; } |

The main advantages of using database storage sessions include persistence, scalability, and security. 1. Persistence: Even if the server restarts, the session data can remain unchanged. 2. Scalability: Applicable to distributed systems, ensuring that session data is synchronized between multiple servers. 3. Security: The database provides encrypted storage to protect sensitive information.

Implementing custom session processing in PHP can be done by implementing the SessionHandlerInterface interface. The specific steps include: 1) Creating a class that implements SessionHandlerInterface, such as CustomSessionHandler; 2) Rewriting methods in the interface (such as open, close, read, write, destroy, gc) to define the life cycle and storage method of session data; 3) Register a custom session processor in a PHP script and start the session. This allows data to be stored in media such as MySQL and Redis to improve performance, security and scalability.

SessionID is a mechanism used in web applications to track user session status. 1. It is a randomly generated string used to maintain user's identity information during multiple interactions between the user and the server. 2. The server generates and sends it to the client through cookies or URL parameters to help identify and associate these requests in multiple requests of the user. 3. Generation usually uses random algorithms to ensure uniqueness and unpredictability. 4. In actual development, in-memory databases such as Redis can be used to store session data to improve performance and security.

Managing sessions in stateless environments such as APIs can be achieved by using JWT or cookies. 1. JWT is suitable for statelessness and scalability, but it is large in size when it comes to big data. 2.Cookies are more traditional and easy to implement, but they need to be configured with caution to ensure security.

To protect the application from session-related XSS attacks, the following measures are required: 1. Set the HttpOnly and Secure flags to protect the session cookies. 2. Export codes for all user inputs. 3. Implement content security policy (CSP) to limit script sources. Through these policies, session-related XSS attacks can be effectively protected and user data can be ensured.

Methods to optimize PHP session performance include: 1. Delay session start, 2. Use database to store sessions, 3. Compress session data, 4. Manage session life cycle, and 5. Implement session sharing. These strategies can significantly improve the efficiency of applications in high concurrency environments.

Thesession.gc_maxlifetimesettinginPHPdeterminesthelifespanofsessiondata,setinseconds.1)It'sconfiguredinphp.iniorviaini_set().2)Abalanceisneededtoavoidperformanceissuesandunexpectedlogouts.3)PHP'sgarbagecollectionisprobabilistic,influencedbygc_probabi

In PHP, you can use the session_name() function to configure the session name. The specific steps are as follows: 1. Use the session_name() function to set the session name, such as session_name("my_session"). 2. After setting the session name, call session_start() to start the session. Configuring session names can avoid session data conflicts between multiple applications and enhance security, but pay attention to the uniqueness, security, length and setting timing of session names.


Hot AI Tools

Undresser.AI Undress
AI-powered app for creating realistic nude photos

AI Clothes Remover
Online AI tool for removing clothes from photos.

Undress AI Tool
Undress images for free

Clothoff.io
AI clothes remover

Video Face Swap
Swap faces in any video effortlessly with our completely free AI face swap tool!

Hot Article

Hot Tools

SublimeText3 English version
Recommended: Win version, supports code prompts!

Notepad++7.3.1
Easy-to-use and free code editor

SublimeText3 Chinese version
Chinese version, very easy to use

mPDF
mPDF is a PHP library that can generate PDF files from UTF-8 encoded HTML. The original author, Ian Back, wrote mPDF to output PDF files "on the fly" from his website and handle different languages. It is slower than original scripts like HTML2FPDF and produces larger files when using Unicode fonts, but supports CSS styles etc. and has a lot of enhancements. Supports almost all languages, including RTL (Arabic and Hebrew) and CJK (Chinese, Japanese and Korean). Supports nested block-level elements (such as P, DIV),

Zend Studio 13.0.1
Powerful PHP integrated development environment