7.25 BFS

[ Purpose ]

We implemented a distributed grep system that allows user to run grep on log files that are local to all live machines in the distributed system.

[ User guide ]

    1. run source startUP.sh to start
    1. follow the prompt to run server/client code
    1. to test the logGenerator, run ./test.sh
    1. to create new random logs
    • run go run ./src/github.com/jiayuc/logGenerator/logGenerator.go [known line] [known line count] [total line count]
      • Modify ./src/github.com/jiayuc/info/* if you need to add your own vm ips.
    • Note vmIPs contains ip of all machines in the system; contactList contains ips of all machines that the client will try to request the grep

tip:

- assume vms have static machine name and ip addresses

use the following command to manually pre-determine your ip addresses if needed
"ip route get 8.8.8.8 | awk '{print $NF; exit}'"

[ Design ]

- Basic architecture

Basically, all machines run as servers waiting for incoming client query. We can pick any machine as the querying machine by running client code on it. The client code prompts for user input as the querying pattern and sends the pattern over to servers via TCP. We stored an IPlist containing IPs of all machines in the system, and that’s what client refers to when connecting to all servers. Once a server receives a new querying pattern, it runs grep on its local log file and sends back the search result along with a header containing information such as its machine name and total line counts to the client.

- fault tolerance

While trying to send out search pattern to all servers, the client will print out that it fails to connect to any server that died. But this doesn’t affect the running program getting the correct result from all the remaining machine.

[ Unit test ]

We created a logGenerator that generates random log that containing specific number of given known lines. It takes three parameters: a string as known line to be inserted, an integer indicating the number of times this known line should occur in the output file, and another integer indicating the number of total lines in the output file. The other lines will be randomly generated strings.

For testing logGenerator, we used go testing, a lightweight testing framework for golang. Run the test will verify if the desired output file is created as described in the last paragraph. Internally, it checks if the file is created, and run grep on the file to see if it gets the correct line count.

[ Performance ]

Testing on 7 machine using 60MB log file on each machine.
to do: add more accurate data later

最后編輯于
?著作權(quán)歸作者所有,轉(zhuǎn)載或內(nèi)容合作請(qǐng)聯(lián)系作者
  • 序言:七十年代末,一起剝皮案震驚了整個(gè)濱河市尺上,隨后出現(xiàn)的幾起案子锚赤,更是在濱河造成了極大的恐慌澡屡,老刑警劉巖狰住,帶你破解...
    沈念sama閱讀 219,427評(píng)論 6 508
  • 序言:濱河連續(xù)發(fā)生了三起死亡事件递沪,死亡現(xiàn)場(chǎng)離奇詭異帘腹,居然都是意外死亡嚎研,警方通過查閱死者的電腦和手機(jī),發(fā)現(xiàn)死者居然都...
    沈念sama閱讀 93,551評(píng)論 3 395
  • 文/潘曉璐 我一進(jìn)店門噩斟,熙熙樓的掌柜王于貴愁眉苦臉地迎上來曹锨,“玉大人,你說我怎么就攤上這事剃允∨婕颍” “怎么了齐鲤?”我有些...
    開封第一講書人閱讀 165,747評(píng)論 0 356
  • 文/不壞的土叔 我叫張陵,是天一觀的道長(zhǎng)椒楣。 經(jīng)常有香客問我给郊,道長(zhǎng),這世上最難降的妖魔是什么捧灰? 我笑而不...
    開封第一講書人閱讀 58,939評(píng)論 1 295
  • 正文 為了忘掉前任淆九,我火速辦了婚禮,結(jié)果婚禮上吩屹,老公的妹妹穿的比我還像新娘。我一直安慰自己拧抖,他們只是感情好免绿,可當(dāng)我...
    茶點(diǎn)故事閱讀 67,955評(píng)論 6 392
  • 文/花漫 我一把揭開白布。 她就那樣靜靜地躺著嘲驾,像睡著了一般。 火紅的嫁衣襯著肌膚如雪辽故。 梳的紋絲不亂的頭發(fā)上徒仓,一...
    開封第一講書人閱讀 51,737評(píng)論 1 305
  • 那天誊垢,我揣著相機(jī)與錄音,去河邊找鬼喂走。 笑死,一個(gè)胖子當(dāng)著我的面吹牛芋肠,可吹牛的內(nèi)容都是我干的乎芳。 我是一名探鬼主播帖池,決...
    沈念sama閱讀 40,448評(píng)論 3 420
  • 文/蒼蘭香墨 我猛地睜開眼,長(zhǎng)吁一口氣:“原來是場(chǎng)噩夢(mèng)啊……” “哼睡汹!你這毒婦竟也來了?” 一聲冷哼從身側(cè)響起帮孔,我...
    開封第一講書人閱讀 39,352評(píng)論 0 276
  • 序言:老撾萬榮一對(duì)情侶失蹤雷滋,失蹤者是張志新(化名)和其女友劉穎,沒想到半個(gè)月后晤斩,有當(dāng)?shù)厝嗽跇淞掷锇l(fā)現(xiàn)了一具尸體焕檬,經(jīng)...
    沈念sama閱讀 45,834評(píng)論 1 317
  • 正文 獨(dú)居荒郊野嶺守林人離奇死亡,尸身上長(zhǎng)有42處帶血的膿包…… 初始之章·張勛 以下內(nèi)容為張勛視角 年9月15日...
    茶點(diǎn)故事閱讀 37,992評(píng)論 3 338
  • 正文 我和宋清朗相戀三年澳泵,在試婚紗的時(shí)候發(fā)現(xiàn)自己被綠了实愚。 大學(xué)時(shí)的朋友給我發(fā)了我未婚夫和他白月光在一起吃飯的照片。...
    茶點(diǎn)故事閱讀 40,133評(píng)論 1 351
  • 序言:一個(gè)原本活蹦亂跳的男人離奇死亡兔辅,死狀恐怖腊敲,靈堂內(nèi)的尸體忽然破棺而出,到底是詐尸還是另有隱情维苔,我是刑警寧澤碰辅,帶...
    沈念sama閱讀 35,815評(píng)論 5 346
  • 正文 年R本政府宣布,位于F島的核電站介时,受9級(jí)特大地震影響没宾,放射性物質(zhì)發(fā)生泄漏。R本人自食惡果不足惜沸柔,卻給世界環(huán)境...
    茶點(diǎn)故事閱讀 41,477評(píng)論 3 331
  • 文/蒙蒙 一循衰、第九天 我趴在偏房一處隱蔽的房頂上張望。 院中可真熱鬧褐澎,春花似錦会钝、人聲如沸。這莊子的主人今日做“春日...
    開封第一講書人閱讀 32,022評(píng)論 0 22
  • 文/蒼蘭香墨 我抬頭看了看天上的太陽。三九已至俭正,卻和暖如春胁出,著一層夾襖步出監(jiān)牢的瞬間,已是汗流浹背段审。 一陣腳步聲響...
    開封第一講書人閱讀 33,147評(píng)論 1 272
  • 我被黑心中介騙來泰國打工全蝶, 沒想到剛下飛機(jī)就差點(diǎn)兒被人妖公主榨干…… 1. 我叫王不留,地道東北人寺枉。 一個(gè)月前我還...
    沈念sama閱讀 48,398評(píng)論 3 373
  • 正文 我出身青樓抑淫,卻偏偏與公主長(zhǎng)得像,于是被迫代替她去往敵國和親。 傳聞我的和親對(duì)象是個(gè)殘疾皇子,可洞房花燭夜當(dāng)晚...
    茶點(diǎn)故事閱讀 45,077評(píng)論 2 355

推薦閱讀更多精彩內(nèi)容