private void testMaxCountersLimits(final Counters counters) { for (int i = 0; i < org.apache.hadoop.mapred.Counters.MAX_COUNTER_LIMIT; ++i) { counters.findCounter("test", "test" + i); } setExpected(counters); shouldThrow(CountersExceededException.class, new Runnable() { public void run() { counters.findCounter("test", "bad"); } }); checkExpected(counters); }
private void testMaxGroupsLimits(final Counters counters) { for (int i = 0; i < org.apache.hadoop.mapred.Counters.MAX_GROUP_LIMIT; ++i) { // assuming COUNTERS_MAX > GROUPS_MAX counters.findCounter("test" + i, "test"); } setExpected(counters); shouldThrow(CountersExceededException.class, new Runnable() { public void run() { counters.findCounter("bad", "test"); } }); checkExpected(counters); }
private void shouldThrow(Class<? extends Exception> ecls, Runnable runnable) { try { runnable.run(); } catch (CountersExceededException e) { return; } Assert.fail("Should've thrown " + ecls.getSimpleName()); }
/** * Returns map phase counters by summing over all map tasks in progress. * This method returns true if counters are within limit or false. */ public synchronized boolean getMapCounters(Counters counters) { try { counters = incrementTaskCounters(counters, maps); } catch(CountersExceededException ce) { LOG.info("Counters Exceeded for Job: " + jobId, ce); return false; } return true; }
/** * Returns map phase counters by summing over all map tasks in progress. * This method returns true if counters are within limits and false otherwise. */ public synchronized boolean getReduceCounters(Counters counters) { try { counters = incrementTaskCounters(counters, reduces); } catch(CountersExceededException ce) { LOG.info("Counters Exceeded for Job: " + jobId, ce); return false; } return true; }
/** * Returns the total job counters, by adding together the job, * the map and the reduce counters. This method returns true if * counters are within limits and false otherwise. */ public synchronized boolean getCounters(Counters result) { try { result.incrAllCounters(getJobCounters()); incrementTaskCounters(result, maps); incrementTaskCounters(result, reduces); } catch(CountersExceededException ce) { LOG.info("Counters Exceeded for Job: " + jobId, ce); return false; } return true; }