SlowPeerTracker { public String getJson() { Collection<ReportForJson> validReports = getJsonReports( MAX_NODES_TO_REPORT); try { return WRITER.writeValueAsString(validReports); } catch (JsonProcessingException e) { LOG.debug("Failed to serialize statistics" + e); return null; } } SlowPeerTracker(Configuration conf, Timer timer); void addReport(String slowNode,
                        String reportingNode); Set<String> getReportsForNode(String slowNode); Map<String, SortedSet<String>> getReportsForAllDataNodes(); String getJson(); static final Logger LOG; }
@Test public void testGetJson() throws IOException { tracker.addReport("node1", "node2"); tracker.addReport("node2", "node3"); tracker.addReport("node2", "node1"); tracker.addReport("node4", "node1"); final Set<ReportForJson> reports = getAndDeserializeJson(); assertThat(reports.size(), is(3)); assertTrue(isNodeInReports(reports, "node1")); assertTrue(isNodeInReports(reports, "node2")); assertTrue(isNodeInReports(reports, "node4")); assertFalse(isNodeInReports(reports, "node3")); }