*/
@Test
public void testThriftSend() throws IOException, InterruptedException {
EventSource txt = new NoNlASCIISynthSource(25, 100);
txt.open();
MemorySinkSource mem = new MemorySinkSource();
mem.open();
EventUtil.dumpAll(txt, mem);
txt.close();
FlumeConfiguration conf = FlumeConfiguration.get();
final ThriftEventSource tes = new ThriftEventSource(
conf.getCollectorPort() + 1); // this is a slight
// tweak to avoid port conflicts
tes.open();
final CounterSink cnt = new CounterSink("count");
cnt.open();
Thread t = new Thread("drain") {
public void run() {
try {
EventUtil.dumpAll(tes, cnt);
} catch (IOException e) {
} catch (InterruptedException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}
};
t.start(); // drain the sink.
// mem -> ThriftEventSink
ThriftEventSink snk = new ThriftEventSink("0.0.0.0", conf
.getCollectorPort() + 1);
snk.open();
EventUtil.dumpAll(mem, snk);
mem.close();
snk.close();
// a little delay to drain events at ThriftEventSource queue
try {
Thread.sleep(1000);