enum COUNTERS {C1; C2;}
class DriverCode
{
Configuration conf = new Configuration();
//the Mapper increases C1
Job job1 = new Job(conf, "Job1");
job1.setJarByClass(MyJar.class);
job1.setMapperClass(MyMapper1.class);
...
//read out C1
long c1 = job.getCounters().findCounter(COUNTERS.C1).getValue();
//set it for the new job
conf.setLong("c1",c1);
Job job2 = new Job(conf, "Job2");
//and now you can access this configuration object in your second job
job2.setJarByClass(MyJar.class);
job2.setMapperClass(MyMapper2.class);
...
}
1条答案
按热度按时间bogh5gae1#
不,在同一份工作中这是不可能的。但是,您可以有一个没有缩减器的作业,收集任何要计算的计数器信息,然后启动第二个作业,在该作业中,您将这些计数值添加到作业配置对象中,然后第二个作业的缩减器可以访问这些值。
编辑:
下面是一个代码示例: