11.07.2015 Views

MapReduce 架構下的平行化局部診斷設計與模擬 - 第二十九屆組合 ...

MapReduce 架構下的平行化局部診斷設計與模擬 - 第二十九屆組合 ...

MapReduce 架構下的平行化局部診斷設計與模擬 - 第二十九屆組合 ...

SHOW MORE
SHOW LESS
  • No tags were found...

You also want an ePaper? Increase the reach of your titles

YUMPU automatically turns print PDFs into web optimized ePapers that Google loves.

The 29th Workshop on Combinatorial Mathematics and Computation Theory( 檔 案 3) 存 放 各 map 節 點 處 理 範 圍 須 知 , 檔 案 3的 每 一 行 各 自 記 錄 一 個 map 須 處 理 的 點 範 圍 及圖 形 的 最 大 分 支 度 和 圖 形 總 點 數 。 在 執 行<strong>MapReduce</strong> 程 式 之 前 , 需 先 將 這 3 個 檔 案 存 放至 HDFS, 然 後 在 執 行 <strong>MapReduce</strong> 程 式 時 , 我們 先 讓 Hadoop 以 內 建 的 TextInputFormat 函 式來 讀 取 檔 案 3 的 內 容 , 每 讀 一 行 即 形 成 一 組 鍵值 組 對 (key-value pair) 並 做 為 一 個 map 的 輸 入 ,map 的 工 作 如 下 。演 算 法 map (key, value)輸 入 : 鍵 值 組 對 ,key 是 讀 取 位 置 ,value 是 檔 案 3 的 一 行 資 料 , 該 行 資 料 包 含 此 map必 須 處 理 的 點 範 圍 、 圖 形 總 點 數 、 圖 形 最 大 分支 度 等 等 資 訊輸 出 : 鍵 值 組 對 ,key 是 0,value 是壞 點 編 號1. 分 析 value, 取 得 起 點 編 號 start、 終 點 編 號end、 總 點 數 number、 最 大 分 支 度 MaxDegree;2. 從 HDFS 讀 取 檔 案 1, 將 全 部 圖 形 結 構 內 容存 入 link[number][MaxDegree];3. 從 HDFS 讀 取 檔 案 2, 將 全 部 症 狀 內 容 存 入syndrome[number][MaxDegree];4. for i = start to end do匹 配 演 算 法 (i);counter1 = 症 狀 為 (0,0) 的 分 支 數 量 ;counter2 = 症 狀 為 (0, ) 的 分 支 數 量 ;5. if counter1 < counter2,thenFaultyNodes += i + ”,” ; //i 為 壞 點6. End if7. End for8. 設 key 為 0,value 為 FaultyNodes;9. 輸 出 鍵 值 組 對 ;10. 結 束步 驟 1~3 為 前 置 作 業 , 取 得 圖 形 的 相 關 資訊 , 步 驟 4~7 是 為 每 一 點 建 構 T 1 並 判 斷 點 的 好壞 , 最 後 設 定 所 有 map 輸 出 的 key 一 律 為 0, 因此 所 有 map 輸 出 的 鍵 值 組 對 會 因 key 相 同 而 被Hadoop 的 combiner 合 併 成 一 個 一 鍵 多 值 的 鍵 值組 對 , 由 於 只 有 一 組 鍵 值 組 對 , 因此 只 會 建 立 一 個 reduce 並 挑 一 個 節 點 執 行 它 ,reduce 的 工 作 如 下 。演 算 法 reduce (key, values)輸 入 : 鍵 值 組 對 ,key 是 0,values 是每 個 map 輸 出 的 壞 點 編 號 所 形 成 的 群 組輸 出 : 鍵 值 組 對 ,key 是 空 值 ,value是 全 部 的 壞 點 編 號1. for Text val : values doAllFaultyNodes += val.toString();2. end for3. 設 key 為 空 值 ,value 為 AllFaultyNodes;4. 輸 出 鍵 值 組 對 ;5. 結 束Reduce 的 工 作 相 當 單 純 , 它 將 所 有 壞 點 編號 合 併 成 一 條 字 串 , 做 為 輸 出 的 鍵 值 組 對 的value,key 則 設 為 空 值 , 最 後 Hadoop 會 將 此 鍵值 組 對 存 入 HDFS 之 中 , 圖 4 為 本 設 計 的 流 程架 構 圖 。圖 4. 局 部 診 斷 演 算 法 的 <strong>MapReduce</strong> 運 作 流 程290

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!