我需要從我的減速器中的映射器訪問計數器。這可能嗎?如果是這樣怎麼辦?從減速器訪問映射器的計數器
舉個例子:我 映射是:
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