Changes between Version 11 and Version 12 of NCHCCloudCourse100928_4_EXM2
- Timestamp:
- Jul 21, 2011, 5:38:05 PM (13 years ago)
Legend:
- Unmodified
- Added
- Removed
- Modified
-
NCHCCloudCourse100928_4_EXM2
v11 v12 105 105 import org.apache.hadoop.mapreduce.Job; 106 106 import org.apache.hadoop.mapreduce.lib.input.FileInputFormat; 107 import org.apache.hadoop.mapreduce.lib.output.FileOutputFormat; 107 import org.apache.hadoop.mapreduce.lib.output.FileOutputFormat; 108 108 109 109 public class HelloHadoopV2 { 110 110 111 111 112 113 112 public static void main(String[] args) throws IOException, 113 InterruptedException, ClassNotFoundException { 114 114 115 116 117 118 119 job.setMapperClass(); // 請輸入正確的類別 120 job.setCombinerClass(); // 請輸入正確的類別 121 job.setReducerClass(); // 請輸入正確的類別 115 Configuration conf = new Configuration(); 116 Job job = new Job(conf, "Hadoop Hello World 2"); 117 job.setJarByClass(HelloHadoopV2.class); 118 // 設定 map and reduce 以及 Combiner class 119 job.setMapperClass(HelloMapperV2.class); 120 job.setCombinerClass(HelloReducerV2.class); 121 job.setReducerClass(HelloReducerV2.class); 122 122 123 124 125 126 127 128 123 // 設定map的輸出型態 124 job.setMapOutputKeyClass(Text.class); 125 job.setMapOutputValueClass(Text.class); 126 // 設定reduce的輸出型態 127 job.setOutputKeyClass(Text.class); 128 job.setOutputValueClass(Text.class); 129 129 130 130 FileInputFormat.addInputPath(job, new Path("/user/hadoop/input")); 131 131 132 132 FileOutputFormat.setOutputPath(job, new Path("/user/hadoop/output-hh2")); 133 133 134 135 134 // 呼叫checkAndDelete函式,檢查是否存在該資料夾,若有則刪除之 135 CheckAndDelete.checkAndDelete("/user/hadoop/output-hh2", conf); 136 136 137 137 boolean status = job.waitForCompletion(true); 138 138 139 140 139 if (status) { 140 System.err.println("Integrate Alert Job Finished !"); 141 141 142 143 144 145 146 142 } else { 143 System.err.println("Integrate Alert Job Failed !"); 144 System.exit(1); 145 } 146 } 147 147 } 148 148