close
Warning:
Can't synchronize with repository "(default)" (Unsupported version control system "svn": libnettle.so.4: failed to map segment from shared object: Cannot allocate memory). Look in the Trac log for more information.
- Timestamp:
-
Jul 21, 2011, 5:38:05 PM (15 years ago)
- Author:
-
waue
- Comment:
-
--
Legend:
- Unmodified
- Added
- Removed
- Modified
-
|
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 | | public static void main(String[] args) throws IOException, |
| 113 | | InterruptedException, ClassNotFoundException { |
| | 112 | public static void main(String[] args) throws IOException, |
| | 113 | InterruptedException, ClassNotFoundException { |
| 114 | 114 | |
| 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(); // 請輸入正確的類別 |
| 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 | | // 設定map的輸出型態 |
| 124 | | job.setMapOutputKeyClass(Text.class); |
| 125 | | job.setMapOutputValueClass(Text.class); |
| 126 | | // 設定reduce的輸出型態 |
| 127 | | job.setOutputKeyClass(Text.class); |
| 128 | | job.setOutputValueClass(Text.class); |
| | 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 | | FileInputFormat.addInputPath(job, new Path("/user/hadoop/input")); |
| | 130 | FileInputFormat.addInputPath(job, new Path("/user/hadoop/input")); |
| 131 | 131 | |
| 132 | | FileOutputFormat.setOutputPath(job, new Path("/user/hadoop/output-hh2")); |
| | 132 | FileOutputFormat.setOutputPath(job, new Path("/user/hadoop/output-hh2")); |
| 133 | 133 | |
| 134 | | // 呼叫checkAndDelete函式,檢查是否存在該資料夾,若有則刪除之 |
| 135 | | CheckAndDelete.checkAndDelete("/user/hadoop/output-hh2", conf); |
| | 134 | // 呼叫checkAndDelete函式,檢查是否存在該資料夾,若有則刪除之 |
| | 135 | CheckAndDelete.checkAndDelete("/user/hadoop/output-hh2", conf); |
| 136 | 136 | |
| 137 | | boolean status = job.waitForCompletion(true); |
| | 137 | boolean status = job.waitForCompletion(true); |
| 138 | 138 | |
| 139 | | if (status) { |
| 140 | | System.err.println("Integrate Alert Job Finished !"); |
| | 139 | if (status) { |
| | 140 | System.err.println("Integrate Alert Job Finished !"); |
| 141 | 141 | |
| 142 | | } else { |
| 143 | | System.err.println("Integrate Alert Job Failed !"); |
| 144 | | System.exit(1); |
| 145 | | } |
| 146 | | } |
| | 142 | } else { |
| | 143 | System.err.println("Integrate Alert Job Failed !"); |
| | 144 | System.exit(1); |
| | 145 | } |
| | 146 | } |
| 147 | 147 | } |
| 148 | 148 | |