mapreduce俩个依赖关系的JOB实现


   public static void main(String[] args) throws IOException{


    Configuration conf1 = new Configuration();
//第一个job的配置
Job job1 = new Job(conf1);
  job1.setJarByClass(LiFangMinHash.class);
  job1.setNumReduceTasks(25);
  job1.setMapperClass(maphadoop1.class);
  job1.setReducerClass(reducehadoop1.class);
  job1.setOutputFormatClass(TextOutputFormat.class);
  job1.setOutputKeyClass(Text.class);
  job1.setOutputValueClass(Text.class);
  ControlledJob ctrljob1=new  ControlledJob(conf1); 
ctrljob1.setJob(job1);
FileInputFormat.addInputPath(job1, new Path(args[0]));
  FileOutputFormat.setOutputPath(job1, new Path(args[1]));
 
  Configuration conf2 = new Configuration();
Job job2=new Job(conf2); 
   job2.setJarByClass(LiFangMinHash.class);
job2.setNumReduceTasks(25);
job2.setMapperClass(maphadoop2.class);
job2.setReducerClass(reducehadoop2.class);
job2.setOutputFormatClass(TextOutputFormat.class);
job2.setOutputKeyClass(Text.class);
job2.setOutputValueClass(Text.class);
ControlledJob ctrljob2=new  ControlledJob(conf2); 
ctrljob2.setJob(job2); 

ctrljob2.addDependingJob(ctrljob1);

FileInputFormat.addInputPath(job2, new Path(args[1]));
FileOutputFormat.setOutputPath(job2,new Path(args[2]));



JobControl jobCtrl=new JobControl("myctrl");
jobCtrl.addJob(ctrljob1); 
jobCtrl.addJob(ctrljob2); 
jobCtrl.run();

while(true){ 


if(jobCtrl.allFinished()){//如果作业成功完成,就打印成功作业的信息 
System.out.println(jobCtrl.getSuccessfulJobList()); 
jobCtrl.stop(); 
break; 
}
}
}
}
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值