I am trying to get map-tasks counters and reduce-tasks counters separately
I think comparing the final job counter should suffice. Job counter encompasses all the maps and reduce counters. Is there any specific reason why you are matching them separately?
May be we could just change parseHistoryFromFs to accept multiple listeners
I dont see any need for a separate listener, atleast in this jira. I think we should simply recover the counter wherever the counter is expected (like TASK_FINISH) and add it to the global job counter. The only change required will be
Counters jobCounter = new Counters();
Counters newCounter = Counters.fromEscapedCompactString(task.get(Keys.COUNTERS));
Introducing new code just for this is probably not worth it. I think we should reuse the available listener. I agree that we should support multiple listeners but it makes sense when the listeners are having separate, well defined functionalities. in this case one would be a subpart of other, logically.