use of org.apache.flume.SinkRunner in project MSEC by Tencent.
the class TestProfobufSource method testBasic.
@Test
public void testBasic() throws Exception {
Context context = new Context();
context.put("bind", "localhost");
context.put("port", "45673");
context.put("threads", "1");
ProtobufSource source = new ProtobufSource();
source.configure(context);
Map<String, String> channelContext = new HashMap();
channelContext.put("capacity", "1000000");
// for faster tests
channelContext.put("keep-alive", "0");
Channel channel = new MemoryChannel();
Configurables.configure(channel, new Context(channelContext));
Sink sink = new LoggerSink();
sink.setChannel(channel);
sink.start();
DefaultSinkProcessor proc = new DefaultSinkProcessor();
proc.setSinks(Collections.singletonList(sink));
SinkRunner sinkRunner = new SinkRunner(proc);
sinkRunner.start();
ChannelSelector rcs = new ReplicatingChannelSelector();
rcs.setChannels(Collections.singletonList(channel));
ChannelProcessor chp = new ChannelProcessor(rcs);
source.setChannelProcessor(chp);
source.start();
Thread.sleep(5000);
source.stop();
sinkRunner.stop();
sink.stop();
}
Aggregations