How to access Hadoop counters values via API?

前端 未结 2 1803
广开言路
广开言路 2021-01-21 19:12

In Hadoop we can increment counter in map/reduce task, it looks like this:

...
context.getCounter(MyCountersEnum.SomeCounter).increment(1);
...
<
2条回答
  •  半阙折子戏
    2021-01-21 19:39

    I just found the answer here.

    You need a job object to access the counters:

    Counters counters = job.getCounters();
    Counter counter = counters.findCounter(MyCountersEnum.SomeCounter);
    System.out.println(counter.getDisplayName() + ": " + counter.getValue());
    

提交回复
热议问题