public static Counters incrTaskCounters( Counters counters, Collection<Task> tasks) { for (Task task : tasks) { counters.incrAllCounters(task.getCounters()); } return counters; }
public static Counters incrTaskCounters( Counters counters, Collection<Task> tasks) { for (Task task : tasks) { counters.incrAllCounters(task.getCounters()); } return counters; }
public static Counters incrTaskCounters( Counters counters, Collection<Task> tasks) { for (Task task : tasks) { counters.incrAllCounters(task.getCounters()); } return counters; }
@Private public void constructFinalFullcounters() { this.fullCounters = new Counters(); this.finalMapCounters = new Counters(); this.finalReduceCounters = new Counters(); this.fullCounters.incrAllCounters(jobCounters); for (Task t : this.tasks.values()) { Counters counters = t.getCounters(); switch (t.getType()) { case MAP: this.finalMapCounters.incrAllCounters(counters); break; case REDUCE: this.finalReduceCounters.incrAllCounters(counters); break; default: throw new IllegalStateException("Task type neither map nor reduce: " + t.getType()); } this.fullCounters.incrAllCounters(counters); } }
@Private public void constructFinalFullcounters() { this.fullCounters = new Counters(); this.finalMapCounters = new Counters(); this.finalReduceCounters = new Counters(); this.fullCounters.incrAllCounters(jobCounters); for (Task t : this.tasks.values()) { Counters counters = t.getCounters(); switch (t.getType()) { case MAP: this.finalMapCounters.incrAllCounters(counters); break; case REDUCE: this.finalReduceCounters.incrAllCounters(counters); break; default: throw new IllegalStateException("Task type neither map nor reduce: " + t.getType()); } this.fullCounters.incrAllCounters(counters); } }
@Private public void constructFinalFullcounters() { this.fullCounters = new Counters(); this.finalMapCounters = new Counters(); this.finalReduceCounters = new Counters(); this.fullCounters.incrAllCounters(jobCounters); for (Task t : this.tasks.values()) { Counters counters = t.getCounters(); switch (t.getType()) { case MAP: this.finalMapCounters.incrAllCounters(counters); break; case REDUCE: this.finalReduceCounters.incrAllCounters(counters); break; default: throw new IllegalStateException("Task type neither map nor reduce: " + t.getType()); } this.fullCounters.incrAllCounters(counters); } }
@Override public Counters getAllCounters() { readLock.lock(); try { JobStateInternal state = getInternalState(); if (state == JobStateInternal.ERROR || state == JobStateInternal.FAILED || state == JobStateInternal.KILLED || state == JobStateInternal.SUCCEEDED) { this.mayBeConstructFinalFullCounters(); return fullCounters; } Counters counters = new Counters(); counters.incrAllCounters(jobCounters); return incrTaskCounters(counters, tasks.values()); } finally { readLock.unlock(); } }
@Override public Counters getAllCounters() { readLock.lock(); try { JobStateInternal state = getInternalState(); if (state == JobStateInternal.ERROR || state == JobStateInternal.FAILED || state == JobStateInternal.KILLED || state == JobStateInternal.SUCCEEDED) { this.mayBeConstructFinalFullCounters(); return fullCounters; } Counters counters = new Counters(); counters.incrAllCounters(jobCounters); return incrTaskCounters(counters, tasks.values()); } finally { readLock.unlock(); } }
@Override public Counters getAllCounters() { readLock.lock(); try { JobStateInternal state = getInternalState(); if (state == JobStateInternal.ERROR || state == JobStateInternal.FAILED || state == JobStateInternal.KILLED || state == JobStateInternal.SUCCEEDED) { this.mayBeConstructFinalFullCounters(); return fullCounters; } Counters counters = new Counters(); counters.incrAllCounters(jobCounters); return incrTaskCounters(counters, tasks.values()); } finally { readLock.unlock(); } }
map.incrAllCounters(counters); break; case REDUCE: reduce.incrAllCounters(counters); break; total.incrAllCounters(counters);
map.incrAllCounters(counters); break; case REDUCE: reduce.incrAllCounters(counters); break; total.incrAllCounters(counters);
map.incrAllCounters(counters); break; case REDUCE: reduce.incrAllCounters(counters); break; total.incrAllCounters(counters);
case MAP: map.incrAllCounters(counters); break; case REDUCE: reduce.incrAllCounters(counters); break; total.incrAllCounters(counters);
case MAP: map.incrAllCounters(counters); break; case REDUCE: reduce.incrAllCounters(counters); break; total.incrAllCounters(counters);
case MAP: map.incrAllCounters(counters); break; case REDUCE: reduce.incrAllCounters(counters); break; total.incrAllCounters(counters);
counters.incrAllCounters(workingCounter); } catch (IOException e) {
@Test public void testCountersIncrement() { Counters fCounters = new Counters(); Counter fCounter = fCounters.findCounter(FRAMEWORK_COUNTER); fCounter.setValue(100); Counter gCounter = fCounters.findCounter("test", "foo"); gCounter.setValue(200); Counters counters = new Counters(); counters.incrAllCounters(fCounters); Counter counter; for (CounterGroup cg : fCounters) { CounterGroup group = counters.getGroup(cg.getName()); if (group.getName().equals("test")) { counter = counters.findCounter("test", "foo"); assertEquals(200, counter.getValue()); } else { counter = counters.findCounter(FRAMEWORK_COUNTER); assertEquals(100, counter.getValue()); } } }