[Java] 找朋友 →→→→→进入此内容的聊天室

来自 , 2019-12-04, 写在 Java, 查看 130 次.
URL http://www.code666.cn/view/8edd7215
  1. package com.laoxiao.mr;
  2.  
  3. import java.io.IOException;
  4.  
  5. import org.apache.hadoop.conf.Configuration;
  6. import org.apache.hadoop.fs.FileSystem;
  7. import org.apache.hadoop.fs.Path;
  8. import org.apache.hadoop.io.IntWritable;
  9. import org.apache.hadoop.mapreduce.Job;
  10. import org.apache.hadoop.mapreduce.lib.input.FileInputFormat;
  11. import org.apache.hadoop.mapreduce.lib.input.KeyValueTextInputFormat;
  12. import org.apache.hadoop.mapreduce.lib.output.FileOutputFormat;
  13.  
  14. public class RunTest {
  15.  
  16.         public static void main(String[] args) {
  17.  
  18.                 Configuration config = new Configuration();
  19.                 config.set("fs.defaultFS", "hdfs://node9:9000");
  20.                 config.set("yarn.resourcemanager.hostname", "node9");
  21.                
  22.                 try {
  23.                         FileSystem fs =FileSystem.get(config);
  24.                         Job job =Job.getInstance(config);
  25.                        
  26.                         job.setMapperClass(FriendsMapper.class);
  27.                         job.setReducerClass(FriendReduer.class);
  28.                        
  29.                         job.setMapOutputKeyClass(Friend.class);
  30.                         job.setMapOutputValueClass(IntWritable.class);
  31.                        
  32.                         //璁剧疆map task 杈撳叆鏁版嵁鐨勬牸寮�
  33.                         job.setInputFormatClass(KeyValueTextInputFormat.class);
  34.                        
  35.                         FileInputFormat.addInputPath(job, new Path("/input/data"));
  36.                        
  37.                         Path outpath =new Path("/output/friends");
  38.                         if(fs.exists(outpath)){
  39.                                 fs.delete(outpath, true);
  40.                         }
  41.                        
  42.                         FileOutputFormat.setOutputPath(job, outpath);
  43.                        
  44.                        
  45.                         boolean f= job.waitForCompletion(true);
  46.                         if(f){
  47.                                 System.out.println("mr 鎴愬姛鎵ц!");
  48.                         }
  49.                        
  50.                 } catch (Exception e) {
  51.                         e.printStackTrace();
  52.                 }
  53.         }
  54.  
  55.        
  56.        
  57. }
  58.  

回复 "找朋友"

这儿你可以回复上面这条便签

captcha