FanOutSink extends EventSink.Base { @Override public ReportEvent getMetrics() { ReportEvent rpt = super.getMetrics(); rpt.setLongMetric(R_SUBSINKS, sinks.size()); return rpt; } FanOutSink();  FanOutSink(Collection<? extends S> l);  FanOutSink(S... ss); void add(S r); void addAll(Collection<? extends S> c); void drop(S r); @Override void close(); @Override void open(); @Override synchronized void append(Event e); @Override String getName(); @Override ReportEvent getMetrics(); @Override Map<String, Reportable> getSubMetrics(); @Deprecated @Override void getReports(String namePrefix, Map<String, ReportEvent> reports); final static String R_SUBSINKS; }
@Test public void testGetFanOutMetrics() throws JSONException, FlumeSpecException { ReportTestUtils.setupSinkFactory(); EventSink snk = FlumeBuilder.buildSink(new ReportTestingContext(), "[ one, two, three]"); ReportEvent rpt = snk.getMetrics(); LOG.info(ReportUtil.toJSONObject(rpt).toString()); assertEquals(3, rpt.getLongMetric(FanOutSink.R_SUBSINKS).longValue()); assertNull(rpt.getStringMetric("Fanout[0].name")); assertNull(rpt.getStringMetric("Fanout[1].name")); assertNull(rpt.getStringMetric("Fanout[2].name")); ReportEvent all = ReportUtil.getFlattenedReport(snk); LOG.info(ReportUtil.toJSONObject(all).toString()); assertEquals(3, rpt.getLongMetric(FanOutSink.R_SUBSINKS).longValue()); assertEquals("One", all.getStringMetric("Fanout[0].name")); assertEquals("Two", all.getStringMetric("Fanout[1].name")); assertEquals("Three", all.getStringMetric("Fanout[2].name")); }