package com.cloudera.flume;
import java.io.IOException;
import org.junit.Test;
import com.cloudera.flume.conf.FlumeConfiguration;
import com.cloudera.flume.core.EventUtil;
import com.cloudera.flume.handlers.debug.MemorySinkSource;
import com.cloudera.flume.handlers.debug.NullSink;
import com.cloudera.flume.handlers.debug.TextFileSource;
import com.cloudera.flume.handlers.thrift.ThriftEventSink;
import com.cloudera.flume.handlers.thrift.ThriftEventSource;
import com.cloudera.util.Benchmark;
@Test
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();
Thread drain = new Thread("drain") {
try {
EventUtil.dumpAll(tes, new NullSink());
} catch (IOException e) {
e.printStackTrace();
}
}
};
drain.start();
b.mark("receiver_started");
final ThriftEventSink snk = new ThriftEventSink("0.0.0.0", conf
.getCollectorPort());
snk.open();
b.mark("sink_started");
EventUtil.dumpAll(mem, snk);
b.mark("thrift sink to thrift source done");
tes.close();
snk.close();
drain.interrupt();
b.done();
}
@Test
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();
Thread drain = new Thread("drain") {
try {
EventUtil.dumpAll(tes, new NullSink());
} catch (IOException e) {
e.printStackTrace();
}
}
};
drain.start();
b.mark("receiver_started");
final ThriftEventSink snk = new ThriftEventSink("0.0.0.0", conf
.getCollectorPort());
Thread t = new Thread() {
try {
snk.open();
} catch (IOException e) {
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();
}
@Test
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();
Thread drain = new Thread("drain") {
try {
EventUtil.dumpAll(tes, new NullSink());
} catch (IOException e) {
e.printStackTrace();
}
}
};
drain.start();
b.mark("receiver_started");
final ThriftEventSink snk = new ThriftEventSink("0.0.0.0", conf
.getCollectorPort());
snk.open();
b.mark("sink_started");
EventUtil.dumpAll(mem, snk);
b.mark("thrift sink to thrift source done");
tes.close();
snk.close();
drain.interrupt();
b.done();
}
}