// Start the agent first.
String agentSink = "{ delay(100) => < "
+ "{ flakeyAppend(.05) => rpcSink(\"localhost\",12345) } ?"
+ " {diskFailover => { insistentAppend => { stubbornAppend => { insistentOpen "
+ "=> { lazyOpen => {flakeyAppend(.05) => rpcSink(\"localhost\",12346) } } } } } }> } ";
LogicalNode agent = setupAgent(count, agentSink);
// Purposely sleep a little so that the agent is collecting to disk, then
// start collectors
Clock.sleep(2000);
LogicalNode coll = setupColl(12345, "coll", "count");
LogicalNode coll2 = setupColl(12346, "coll2", "count2");
// wait until the counts add up properly
AccumulatorSink ctr = (AccumulatorSink) ReportManager.get().getReportable(
"count");
AccumulatorSink ctr2 = (AccumulatorSink) ReportManager.get().getReportable(
"count2");
loopUntilCount(count, coll, coll2);
// close off the collector
coll.close();
coll2.close();
// dump info for debugging
Map<String, ReportEvent> rpts = new HashMap<String, ReportEvent>();
agent.getReports(rpts);
for (Entry<String, ReportEvent> e : rpts.entrySet()) {
LOG.info(e.getKey() + " : " + e.getValue());
}
// check the end states
assertEquals(count, ctr.getCount() + ctr2.getCount());
assertTrue(ctr.getCount() > 0);
assertTrue(ctr2.getCount() > 0);
// the collector can be in ERROR or IDLE state because of the randomness.
NodeState stateColl = coll.getStatus().state;
LOG.info("coll exited in state: " + stateColl);
assertTrue(stateColl.equals(NodeState.IDLE)
|| stateColl.equals(NodeState.ERROR));
NodeState stateColl2 = coll2.getStatus().state;
LOG.info("coll2 exited in state: " + stateColl2);
assertTrue(stateColl2.equals(NodeState.IDLE)
|| stateColl2.equals(NodeState.ERROR));
}