setupCollectorAgentConfigs();
// update the configurations
trans.updateAll();
FlumeConfigData transData0 = trans.getConfig("bar");
assertEquals("null", transData0.getSourceConfig());
String lh = NetUtils.localhost();
String first = "< { lazyOpen => fail( \"logicalSink( \\\"foo\\\" )\" ) } ? "
+ "< { lazyOpen => fail( \"logicalSink( \\\"foo3\\\" )\" ) } ? "
+ "< { lazyOpen => fail( \"logicalSink( \\\"foo2\\\" )\" ) } ? null > > >";
assertEquals(first, transData0.getSinkConfig());
// update one at a time and check config
statman.updateHeartbeatStatus(NetUtils.localhost(), "physnode", "foo",
NodeState.HELLO, Clock.unixTime());
trans.updateAll(); // TODO remove
String second = "< { lazyOpen => rpcSink( \""
+ lh
+ "\", 35853 ) } ? "
+ "< { lazyOpen => fail( \"logicalSink( \\\"foo3\\\" )\" ) } ? "
+ "< { lazyOpen => fail( \"logicalSink( \\\"foo2\\\" )\" ) } ? null > > >";
FlumeConfigData transData = trans.getConfig("bar");
assertEquals("null", transData.getSourceConfig());
assertEquals(second, transData.getSinkConfig());
FlumeConfigData transCollData = trans.getConfig("foo");
assertEquals("rpcSource( 35853 )", transCollData.getSourceConfig());
assertEquals("null", transCollData.getSinkConfig());
// update one at a time and check config
statman.updateHeartbeatStatus(NetUtils.localhost(), "physnode", "foo2",
NodeState.HELLO, Clock.unixTime());
trans.updateAll();
String third = "< { lazyOpen => rpcSink( \"" + lh + "\", 35853 ) } ? "
+ "< { lazyOpen => fail( \"logicalSink( \\\"foo3\\\" )\" ) } ? "
+ "< { lazyOpen => rpcSink( \"" + lh + "\", 35854 ) } ? null > > >";
transData = trans.getConfig("bar");
assertEquals("null", transData.getSourceConfig());
assertEquals(third, transData.getSinkConfig());
String translated = "< { lazyOpen => rpcSink( \"" + lh + "\", 35853 ) } ? "
+ "< { lazyOpen => rpcSink( \"" + lh + "\", 35855 ) } ? "
+ "< { lazyOpen => rpcSink( \"" + lh + "\", 35854 ) } ? null > > >";
transCollData = trans.getConfig("foo");
assertEquals("rpcSource( 35853 )", transCollData.getSourceConfig());
assertEquals("null", transCollData.getSinkConfig());
statman.updateHeartbeatStatus(NetUtils.localhost(), "physnode", "foo3",
NodeState.HELLO, Clock.unixTime());
trans.updateAll();
LOG.info("Full Translation: " + trans);
LOG.info("logical Translation: " + logical);
LOG.info("failover Translation: " + failover);
transData = trans.getConfig("bar");
assertEquals("null", transData.getSourceConfig());
assertEquals(translated, transData.getSinkConfig());
transCollData = trans.getConfig("foo");
assertEquals("rpcSource( 35853 )", transCollData.getSourceConfig());
assertEquals("null", transCollData.getSinkConfig());
// intermediate data
FlumeConfigData failData = failover.getConfig("bar");
assertEquals("null", failData.getSourceConfig());
String failTranslated = "< { lazyOpen => logicalSink( \"foo\" ) } ? "
+ "< { lazyOpen => logicalSink( \"foo3\" ) } ? "
+ "< { lazyOpen => logicalSink( \"foo2\" ) } ? null > > >";
assertEquals(failTranslated, failData.getSinkConfig());
}