public void testStatsPublisherMultipleUpdates() throws Throwable {
try {
System.out.println("StatsPublisher - multiple updates");
// instantiate stats publisher
StatsPublisher statsPublisher = Utilities.getStatsPublisher((JobConf) conf);
assertNotNull(statsPublisher);
assertTrue(statsPublisher.init(conf));
assertTrue(statsPublisher.connect(conf));
// instantiate stats aggregator
StatsAggregator statsAggregator = StatsFactory.getStatsAggregator();
assertNotNull(statsAggregator);
assertTrue(statsAggregator.connect(conf));
// publish stats
fillStatMap("200", "1000");
assertTrue(statsPublisher.publishStat("file_00000_a", stats));
fillStatMap("300", "2000");
assertTrue(statsPublisher.publishStat("file_00000_b", stats));
fillStatMap("400", "3000");
assertTrue(statsPublisher.publishStat("file_00001_a", stats));
fillStatMap("500", "4000");
assertTrue(statsPublisher.publishStat("file_00001_b", stats));
// update which should not take any effect
fillStatMap("190", "1000");
assertTrue(statsPublisher.publishStat("file_00000_a", stats));
fillStatMap("290", "2000");
assertTrue(statsPublisher.publishStat("file_00000_b", stats));
// update that should take effect
fillStatMap("500", "5000");
assertTrue(statsPublisher.publishStat("file_00001_a", stats));
fillStatMap("600", "6000");
assertTrue(statsPublisher.publishStat("file_00001_b", stats));
// aggregate existing stats
String rows0 = statsAggregator.aggregateStats("file_00000", StatsSetupConst.ROW_COUNT);
assertEquals("500", rows0);
String usize0 = statsAggregator.aggregateStats("file_00000",
StatsSetupConst.RAW_DATA_SIZE);
assertEquals("3000", usize0);
String rows1 = statsAggregator.aggregateStats("file_00001", StatsSetupConst.ROW_COUNT);
assertEquals("1100", rows1);
String usize1 = statsAggregator.aggregateStats("file_00001",
StatsSetupConst.RAW_DATA_SIZE);
assertEquals("11000", usize1);
assertTrue(statsAggregator.cleanUp("file_0000"));
// close connections
assertTrue(statsPublisher.closeConnection());
assertTrue(statsAggregator.closeConnection());
System.out.println("StatsPublisher - multiple updates - OK");
} catch (Throwable e) {
e.printStackTrace();