* mem -> ThriftEventSink -> ThriftEventSource -> NullSink
**/
@Test
public void testThriftSendMulti() throws IOException, InterruptedException {
Benchmark b = new Benchmark("nullsink");
b.mark("begin");
TextFileSource txt = new TextFileSource(HADOOP_DATA[0]);
txt.open();
MemorySinkSource mem = new MemorySinkSource();
mem.open();
EventUtil.dumpAll(txt, mem);
txt.close();
b.mark("disk_loaded");
FlumeConfiguration conf = FlumeConfiguration.get();
final ThriftEventSource tes = new ThriftEventSource(conf.getCollectorPort());
tes.open();
// need to drain the sink otherwise its queue will fill up with events!
Thread drain = new Thread("drain") {
public void run() {
try {
EventUtil.dumpAll(tes, new NullSink());
} catch (IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}
};
drain.start(); // drain the sink.
b.mark("receiver_started");
final ThriftEventSink snk = new ThriftEventSink("0.0.0.0", conf
.getCollectorPort());
Thread t = new Thread() {
public void run() {
try {
snk.open();
} catch (IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}
};
t.start();
b.mark("sink_started");
EventUtil.dumpAll(mem, snk);
b.mark("thrift sink to thrift source done");
Thread.sleep(1000);
tes.close();
snk.close();
t.interrupt();
drain.interrupt();
b.done();
}