public void run() {
try {
File f1 = FileUtil.mktempdir();
CounterSink cnt1 = new CounterSink("count." + idx);
AckChecksumChecker<EventSink> chk = new AckChecksumChecker<EventSink>(
cnt1);
NaiveFileWALManager wman1 = new NaiveFileWALManager(f1);
EventSink snk = new NaiveFileWALDeco(new Context(), chk, wman1,
new TimeTrigger(1000000), new AckListener.Empty(), 100);
ReportManager.get().add(cnt1);
// make each parallel instance send a slightly different number of
// messages.
EventSource src = new NoNlASCIISynthSource(events + idx, 100);
src.open();
snk.open();
started.countDown();
EventUtil.dumpAll(src, snk);
src.close();
snk.close();
FileUtil.rmr(f1);
} catch (Exception e) {
LOG.error(e.toString(), e);
} finally {
done.countDown();
}
}
}.start();
}
started.await();
boolean ok = done.await(timeout, TimeUnit.MILLISECONDS);
assertTrue("Test timed out", ok);
for (int i = 0; i < threads; i++) {
CounterSink cnt = (CounterSink) ReportManager.get().getReportable(
"count." + i);
// check for the slightly different counts based on thread.
int exp = events + i;
LOG.info("expected " + exp + " but got " + cnt.getCount());
assertEquals(exp, (int) cnt.getCount());
}
}