* these values are passed via configuration file to PORank, by using the unique
* operation identifier
*/
private void saveCounters(Job job, String operationID) {
Counters counters;
Group groupCounters;
Long previousValue = 0L;
Long previousSum = 0L;
ArrayList<Pair<String,Long>> counterPairs;
try {
counters = HadoopShims.getCounters(job);
String groupName = getGroupName(counters.getGroupNames());
// In case that the counter group was not find, we need to find
// out why. Only acceptable state is that the relation has been
// empty.
if (groupName == null) {
Counter outputRecords =
counters.getGroup(MRPigStatsUtil.TASK_COUNTER_GROUP)
.getCounterForName(MRPigStatsUtil.MAP_OUTPUT_RECORDS);
if(outputRecords.getCounter() == 0) {
globalCounters.put(operationID, new ArrayList<Pair<String, Long>>());
return;
} else {
throw new RuntimeException("Did not found RANK counter group for operationId: " + operationID);
}
}
groupCounters = counters.getGroup(groupName);
Iterator<Counter> it = groupCounters.iterator();
HashMap<Integer,Long> counterList = new HashMap<Integer, Long>();
while(it.hasNext()) {
try{
Counter c = it.next();