}
@Test
public void testConsistentHashAvailMan() throws FlumeSpecException,
IOException, InterruptedException {
FailoverChainManager am = new ConsistentHashFailoverChainManager(3);
for (String c : collectors) {
am.addCollector(c);
}
String agent1 = am.getFailChainSinkSpec("agent1",
"{lazyOpen => counter(\"%s\")}");
LOG.info(agent1);
assertEquals(
"failChain(\"{lazyOpen => counter(\\\"%s\\\")}\",\"collector 2\",\"collector 3\",\"collector 1\")",
agent1);
CompositeSink snk1 = new CompositeSink(new Context(), agent1);
snk1.open();
snk1.close();
String agent2 = am.getFailChainSinkSpec("agent2",
"{lazyOpen => counter(\"%s\")}");
LOG.info(agent2);
assertEquals(
"failChain(\"{lazyOpen => counter(\\\"%s\\\")}\",\"collector 1\",\"collector 4\",\"collector 5\")",
agent2);
CompositeSink snk2 = new CompositeSink(new Context(), agent2);
snk2.open();
snk2.close();
String agent3 = am.getFailChainSinkSpec("agent3",
"{lazyOpen => counter(\"%s\")}");
LOG.info(agent3);
assertEquals(
"failChain(\"{lazyOpen => counter(\\\"%s\\\")}\",\"collector 1\",\"collector 2\",\"collector 5\")",
agent3);