final CountDownLatch done = new CountDownLatch(threads);
final NaiveFileWALManager wal = new NaiveFileWALManager(dir);
wal.open();
Context ctx = new ReportTestingContext();
EventSink cntsnk = new CompositeSink(ctx, "counter(\"total\")");
// use the same wal, but different counter.
final EventSink snk = new NaiveFileWALDeco(ctx, cntsnk, wal,
new TimeTrigger(new ProcessTagger(), 1000000), new AckListener.Empty(),
1000000);
snk.open();
for (int i = 0; i < threads; i++) {
new Thread() {
@Override
public void run() {
start.countDown();
try {
EventSource src = new NoNlASCIISynthSource(count, 100);
start.await();
src.open();
EventUtil.dumpAll(src, snk);
src.close();
} catch (Exception e) {
LOG.error("failure", e);
// fail("e");
} finally {
done.countDown();
}
}
}.start();
}
boolean ok = done.await(30, TimeUnit.SECONDS);
assertTrue("Test timed out!", ok);
Thread.sleep(1000);
snk.close();
CounterSink cnt = (CounterSink) ReportManager.get().getReportable("total");
long ci = cnt.getCount();
LOG.info("count : " + ci);
assertEquals((count * threads) + 2, ci);