*/
@Test
public void testManyThreadsThriftSend() throws IOException,
InterruptedException {
final int threads = 100;
final FlumeConfiguration conf = FlumeConfiguration.get();
// this is a slight tweak to avoid port conflicts
final ThriftEventSource tes = new ThriftEventSource(
conf.getCollectorPort() + 1);
tes.open();
final CounterSink cnt = new CounterSink("count");
cnt.open();
Thread t = new Thread("drain") {
public void run() {
try {
EventUtil.dumpAll(tes, cnt);
} catch (Exception e) {
}
}
};
t.start(); // drain the sink.
// fork off threads threads and have them start all the same time.
final CountDownLatch sendStarted = new CountDownLatch(threads);
final CountDownLatch sendDone = new CountDownLatch(threads);
final AtomicLong sendByteSum = new AtomicLong(0);
for (int i = 0; i < threads; i++) {
final int id = i;
Thread th = new Thread() {
public void run() {
try {
// TODO (jon) this may have different sizes due to the host it is
// running on . Needs to be fixed.
EventSource txt = new NoNlASCIISynthSource(25, 100);
txt.open();
MemorySinkSource mem = new MemorySinkSource();
mem.open();
EventUtil.dumpAll(txt, mem);
txt.close();
// mem -> ThriftEventSink
ThriftEventSink snk = new ThriftEventSink("0.0.0.0", conf
.getCollectorPort() + 1);
snk.open();
sendStarted.countDown();
sendStarted.await();