




已閱讀5頁(yè),還剩2頁(yè)未讀, 繼續(xù)免費(fèi)閱讀
版權(quán)說(shuō)明:本文檔由用戶(hù)提供并上傳,收益歸屬內(nèi)容提供方,若內(nèi)容存在侵權(quán),請(qǐng)進(jìn)行舉報(bào)或認(rèn)領(lǐng)
文檔簡(jiǎn)介
Hadoop socket 測(cè)試 分類(lèi) hadoop 2011 11 01 14 35 89 人閱讀 評(píng)論 0 收藏 舉報(bào) 概要 hadoop 上以 streaming 方式運(yùn)行 map 任務(wù) map 任務(wù)為 socke client 端 和在外部系統(tǒng) 運(yùn)行的 server 交互 代碼 server cpp view plaincopy to clipboardprint 1 include 2 include 3 include 4 include 5 include 6 include 7 include 8 include 9 include 10 include 11 include 12 define SERVPORT 9899 服務(wù)器監(jiān)聽(tīng)端口號(hào) 13 define BACKLOG 1000 最大同時(shí)連接請(qǐng)求數(shù) 14 define MAXDATASIZE 100 每次最大數(shù)據(jù)傳輸量 15 16 using namespace std 17 18 int main 19 20 int sock fd client fd sock fd 監(jiān)聽(tīng) socket client fd 數(shù)據(jù)傳輸 socket 21 int sin size 22 char buf MAXDATASIZE 23 struct sockaddr in my addr 本機(jī)地址信息 24 struct sockaddr in remote addr 客戶(hù)端地址信息 25 26 if sock fd socket AF INET SOCK STREAM 0 1 27 28 perror socket 創(chuàng)建出錯(cuò) 29 exit 1 30 31 my addr sin family AF INET 32 my addr sin port htons SERVPORT 33 my addr sin addr s addr INADDR ANY 34 bzero 35 36 if bind sock fd struct sockaddr 39 exit 1 40 41 42 if listen sock fd BACKLOG 1 43 44 perror listen 出錯(cuò) 45 exit 1 46 47 48 while 1 49 50 sin size sizeof struct sockaddr in 51 if client fd accept sock fd struct sockaddr 54 continue 55 56 printf received a connection from s n inet ntoa remote addr sin addr 57 if fork 58 59 子進(jìn)程代碼段 60 if send client fd Hello you are connected n 26 0 1 61 62 perror send 出錯(cuò) 63 64 65 int recvbytes 0 66 if recvbytes recv client fd buf MAXDATASIZE 0 1 67 68 perror recv 出錯(cuò) 69 exit 1 70 71 72 cout buf endl 73 close client fd 74 exit 0 75 76 close client fd 77 78 include include include include include include client cpp view plaincopy to clipboardprint 1 include 2 include 3 include 4 include 5 include 6 include 7 include 8 include 9 include 10 include 11 define SERVPORT 9899 12 define MAXDATASIZE 100 每次最大數(shù)據(jù)傳輸量 13 using namespace std 14 15 int main int argc char argv 16 17 int sock fd recvbytes 18 char buf MAXDATASIZE 19 struct hostent host 20 struct sockaddr in serv addr 21 22 讀取輸入 23 string input 24 while cin input 25 26 cout input endl 27 28 29 if argch addr 49 bzero 50 51 連接 52 if connect sock fd struct sockaddr 55 exit 1 56 57 58 接受數(shù)據(jù) 59 if recvbytes recv sock fd buf MAXDATASIZE 0 1 60 61 perror recv 出錯(cuò) 62 exit 1 63 64 65 發(fā)送數(shù)據(jù) 66 if send sock fd hello server 13 0 1 67 68 perror send 出錯(cuò) 69 70 buf recvbytes 0 71 printf Received s buf 72 close sock fd 73 return 0 74 include include include include include include 編譯程序 g o client client cpp g o server server cpp 測(cè)試 測(cè)試機(jī)上運(yùn)行 server server hadoop 上運(yùn)行任務(wù) hadoop streaming input user test txt output user result mapper client domain reducer cat file client jobconf mapred reduce tasks 1 jobconf mapred map tasks 5 jobconf mapre job name socket test input 內(nèi)容 user test txt 為 1324 jobconf mapred reduce tasks 1 jobconf mapred map tasks 5 mapper 任務(wù) 5 個(gè) reduce 任務(wù) 1 個(gè) server 輸出 received a connection from 10 hello server received a connection from 10 hello server received a connection from 10 hello server received a connection from 10 hello server received a connection from 10 hello server 運(yùn)行結(jié)果 hadoop fs cat user result part 00000 1324 Received
溫馨提示
- 1. 本站所有資源如無(wú)特殊說(shuō)明,都需要本地電腦安裝OFFICE2007和PDF閱讀器。圖紙軟件為CAD,CAXA,PROE,UG,SolidWorks等.壓縮文件請(qǐng)下載最新的WinRAR軟件解壓。
- 2. 本站的文檔不包含任何第三方提供的附件圖紙等,如果需要附件,請(qǐng)聯(lián)系上傳者。文件的所有權(quán)益歸上傳用戶(hù)所有。
- 3. 本站RAR壓縮包中若帶圖紙,網(wǎng)頁(yè)內(nèi)容里面會(huì)有圖紙預(yù)覽,若沒(méi)有圖紙預(yù)覽就沒(méi)有圖紙。
- 4. 未經(jīng)權(quán)益所有人同意不得將文件中的內(nèi)容挪作商業(yè)或盈利用途。
- 5. 人人文庫(kù)網(wǎng)僅提供信息存儲(chǔ)空間,僅對(duì)用戶(hù)上傳內(nèi)容的表現(xiàn)方式做保護(hù)處理,對(duì)用戶(hù)上傳分享的文檔內(nèi)容本身不做任何修改或編輯,并不能對(duì)任何下載內(nèi)容負(fù)責(zé)。
- 6. 下載文件中如有侵權(quán)或不適當(dāng)內(nèi)容,請(qǐng)與我們聯(lián)系,我們立即糾正。
- 7. 本站不保證下載資源的準(zhǔn)確性、安全性和完整性, 同時(shí)也不承擔(dān)用戶(hù)因使用這些下載資源對(duì)自己和他人造成任何形式的傷害或損失。
最新文檔
- 品牌核心價(jià)值的建立試題及答案
- 監(jiān)獄法及試題答案
- 如何在紡織考試中進(jìn)行高效記憶試題及答案
- 廣告設(shè)計(jì)師商業(yè)價(jià)值評(píng)估試題及答案
- 知識(shí)點(diǎn)梳理紡織設(shè)計(jì)師試題及答案
- 公司應(yīng)聘測(cè)試題及答案
- 助理廣告師考試2024年潛力挖掘試題及答案
- 2024年中國(guó)紡織行業(yè)的生態(tài)轉(zhuǎn)型試題及答案
- 2024年設(shè)計(jì)師考試作品創(chuàng)作流程概述試題及答案
- 2024年紡織品設(shè)計(jì)中的市場(chǎng)反饋考題及答案
- 2025年四川綿陽(yáng)交通發(fā)展集團(tuán)有限責(zé)任公司招聘筆試參考題庫(kù)附帶答案詳解
- 成本控制在質(zhì)量管理中的策略試題及答案
- 起重吊裝作業(yè)安全管理培訓(xùn)
- 2025屆河北省石家莊第一中學(xué)高三下學(xué)期二模地理試題及答案
- 2025年山東省應(yīng)急管理普法知識(shí)競(jìng)賽參考試題庫(kù)大全-下(多選、判斷題)
- PSP問(wèn)題解決流程分析
- 6.5 國(guó)家司法機(jī)關(guān) 課件-2024-2025學(xué)年統(tǒng)編版道德與法治八年級(jí)下冊(cè)
- 語(yǔ)文-華大新高考聯(lián)盟2025屆高三3月教學(xué)質(zhì)量測(cè)評(píng)試題+答案
- 低空經(jīng)濟(jì)行業(yè)分析報(bào)告
- 2025年安徽省C20教育聯(lián)盟中考三模語(yǔ)文試題(含答案)
- 計(jì)算機(jī)畢設(shè)管理系統(tǒng)答辯
評(píng)論
0/150
提交評(píng)論