wiki:NCHCCloudCourse100928_4_EXM7

Version 4 (modified by waue, 10 years ago) (diff)

--

Hadoop 進階課程
範例練習

上一關 < 最後一關

說明

YourMenu
說明: 
  將之前的功能整合起來

測試方法:
  將此程式運作在hadoop 0.20 平台上,執行:
  ---------------------------
  hadoop jar YourMenu.jar <功能>
  ---------------------------

注意:
1. 此程式需與之前的範例一起打包成一個YourExam.jar檔

YourMenu.java

package org.nchc.hadoop;

import org.apache.hadoop.util.ProgramDriver;

public class YourMenu {


  public static void main(String argv[]) {
    int exitCode = -1;
    ProgramDriver pgd = new ProgramDriver();
    if (argv.length < 1) {
      System.out.print("******************************************\n"
          + "歡迎使用 YourMenu 的運算功能 \n" + "指令: \n"
          + "  Hadoop jar YourExam.jar <功能> \n" + "功能:\n"
          + "  HelloHadoop:  秀出Hadoop的<Key,Value>為何 \n"
          + "  HelloHadoopV2:  秀出Hadoop的<Key,Value> 進階版 \n"
          + "  HelloHadoopV3:  秀出Hadoop的<Key,Value> 進化版 \n"
          + "  WordCount:  計算輸入資料夾內分別在每個檔案的字數統計 \n"
          + "  WordCountV2:  WordCount 進階版 \n"
          + "  WordIndex:  索引每個字與其所有出現的所在列 \n"
          + "******************************************\n");
    } else {

      try {
        pgd.addClass("HelloHadoop", HelloHadoop.class, " Hadoop hello world");
        pgd.addClass("HelloHadoopV2", HelloHadoopV2.class, " Hadoop hello world V2");
        pgd.addClass("HelloHadoopV3", HelloHadoopV3.class, " Hadoop hello world V3");
        pgd.addClass("WordCount", WordCount.class, " word count.");
        pgd.addClass("WordCountV2", WordCountV2.class, " word count V2.");
        pgd.addClass("WordIndex", WordIndex.class, "invert each word in line");
        pgd.driver(argv);
        // Success
        exitCode = 0;
        System.exit(exitCode);
      } catch (Throwable e) {
        e.printStackTrace();
      }
    }

  }
}