我需要从我的减速器中的映射器访问计数器。这可能吗?如果是这样怎么办?从减速器访问映射器的计数器
举个例子:我 映射是:
public class CounterMapper extends Mapper<Text,Text,Text,Text> {
static enum TestCounters { TEST }
@Override
protected void map(Text key, Text value, Context context)
throws IOException, InterruptedException {
context.getCounter(TestCounters.TEST).increment(1);
context.write(key, value);
}
}
我的减速器是
public class CounterReducer extends Reducer<Text,Text,Text,LongWritable> {
@Override
protected void reduce(Text key, Iterable<Text> values, Context context)
throws IOException, InterruptedException {
Counter counter = context.getCounter(CounterMapper.TestCounters.TEST);
long counterValue = counter.getValue();
context.write(key, new LongWritable(counterValue));
}
}
的对价始终是0 我是不是做错了什么或者是这是不可能的?
JobTracker将跟踪计数器。 – 2011-03-28 04:26:07