我有控制n个作业链的JobControl。如何在使用JobControl开始MapReduce作业之前执行操作
for (int i = 0; i < iterations; i++) {
Job eStep = EStepJob.createJob(config);
Job mStep = MStepJob.createJob(config);
emChain.add(new ControlledJob(eStep, getDeps(emChain)));
emChain.add(new ControlledJob(mStep, getDeps(emChain)));
}
jobControl.addJobCollection(emChain);
我想仅在每个作业开始之前清理输出目录; 但是在作业初始化时不能清理目录。 我目前的解决方案是将清除代码放入映射阶段,这大大减缓了执行速度。
public void map(LongWritable key, Text value, Context context)
throws IOException, InterruptedException {
FileSystem fs = FileSystem.get(context.getConfiguration());
if (fs.exists(new Path(context.getConfiguration().get(
AR_PROBS_OUTPUT)))) {
fs.delete(
new Path(context.getConfiguration()
.get(AR_PROBS_OUTPUT)), true);
}
有没有更适合的方法?