void runAggregateTestStats(int n)
{
try
{
DbusEventsStatisticsCollector aggregateEventStatsCollectors =
new AggregatedDbusEventsStatisticsCollector(0, "eventsInbound", true, true, null);
//collection of n+1 stats collectors;
StatsCollectors<DbusEventsStatisticsCollector> eventStatsCollectors =
new StatsCollectors<DbusEventsStatisticsCollector>(aggregateEventStatsCollectors);
//add new individual stats collectors
int maxEventsInWindow=10;
StatsWriter[] nStatsWriters = createStatsWriters(n, maxEventsInWindow);
for (StatsWriter sw : nStatsWriters)
{
eventStatsCollectors.addStatsCollector(sw.getStatsName(), sw.getEventsStatsCollector());
}
//aggregator thread; 250 ms poll time
GlobalStatsCalc agg = new GlobalStatsCalc(10);
agg.registerStatsCollector(eventStatsCollectors);
Thread aggThread = new Thread(agg);
aggThread.start();
//start writers
for (StatsWriter sw : nStatsWriters)
{
sw.start();
}
//Let the writers start
Thread.sleep(1000);
long startTimeMs = System.currentTimeMillis();
long durationInMs = 5*1000; //5s
DbusEventsTotalStats globalStats = aggregateEventStatsCollectors.getTotalStats();
long prevValue = 0, prevSize =0;
while (System.currentTimeMillis() < (startTimeMs+durationInMs))
{
//constraint checks;