conf.setUser("testuser");
conf.setJobName("testJob");
conf.setSessionId("testSession");
// setup metrics context factory
ContextFactory factory = ContextFactory.getFactory();
factory.setAttribute("mapred.class",
"org.apache.hadoop.metrics.spi.NoEmitMetricsContext");
TaskTracker tt = new TaskTracker();
tt.setConf(conf);
ShuffleServerMetrics shuffleMetrics = tt.new ShuffleServerMetrics(conf);
// first test with only MsgRegex set but doesn't match
String exceptionMsgRegex = "Broken pipe";
String exceptionStackRegex = null;
IOException ie = new IOException("EOFException");
testServlet.checkException(ie, exceptionMsgRegex, exceptionStackRegex,
shuffleMetrics);
MetricsContext context = factory.getContext("mapred");
shuffleMetrics.doUpdates(context);
Map<String, Collection<OutputRecord>> records = context.getAllRecords();
Collection<OutputRecord> col = records.get("shuffleOutput");
OutputRecord outputRecord = col.iterator().next();
assertEquals(0, outputRecord.getMetric("shuffle_exceptions_caught")