AgentFailChainSink extends EventSink.Base { public static String genDfoChain(String... chain) { String primaries = genBestEffortChain(chain); String body = "< " + primaries + " ? diskFailover insistentAppend stubbornAppend insistentOpen " + primaries + " >"; LOG.info("Setting dfo failover chain to " + body); return body; } AgentFailChainSink(Context context, RELIABILITY rel, String... hosts); @Override void open(); @Override void close(); @Override void append(Event e); @Override ReportEvent getMetrics(); @Override Map<String, Reportable> getSubMetrics(); @Deprecated @Override void getReports(String namePrefix, Map<String, ReportEvent> reports); static String genBestEffortChain(String... chain); static String genE2EChain(String... chain); static String genDfoChain(String... chain); static List<String> thriftifyArgs(int defaultPort, List<String> list); static SinkBuilder e2eBuilder(); static SinkBuilder dfoBuilder(); static SinkBuilder beBuilder(); @Override String getName();  }
@Test public void testDFOFailchain() throws FlumeSpecException, JSONException { ReportManager.get().clear(); String spec = AgentFailChainSink.genDfoChain("counter(\"foo1\")", "counter(\"foo2\")", "counter(\"foo3\")"); LOG.info("disk failover failchain: " + spec); String node = NetUtils.localhost(); EventSink snk = FlumeBuilder.buildSink(new LogicalNodeContext(node, node), spec); ReportEvent rpt = ReportUtil.getFlattenedReport(snk); LOG.info("testDFOFailchain report {}", ReportUtil.toJSONObject(rpt) .toString()); assertEquals( "foo1", rpt.getStringMetric("backup.DiskFailover.LazyOpenDecorator." + "InsistentAppend.StubbornAppend.InsistentOpen." + "FailoverChainSink.primary.LazyOpenDecorator.StubbornAppend.foo1.name")); assertEquals( "foo2", rpt.getStringMetric("backup.DiskFailover.LazyOpenDecorator." + "InsistentAppend.StubbornAppend.InsistentOpen." + "FailoverChainSink.backup.BackoffFailover.primary.LazyOpenDecorator." + "StubbornAppend.foo2.name")); assertEquals( "foo3", rpt.getStringMetric("backup.DiskFailover.LazyOpenDecorator." + "InsistentAppend.StubbornAppend.InsistentOpen." + "FailoverChainSink.backup.BackoffFailover.backup.LazyOpenDecorator." + "StubbornAppend.foo3.name")); }