Search in sources :

Example 1 with AvroSource

use of org.apache.flume.source.AvroSource in project logging-log4j2 by apache.

the class FlumeAppenderTest method setUp.

@Before
public void setUp() throws Exception {
    eventSource = new AvroSource();
    channel = new MemoryChannel();
    Configurables.configure(channel, new Context());
    avroLogger = (Logger) LogManager.getLogger("avrologger");
    /*
         * Clear out all other appenders associated with this logger to ensure
         * we're only hitting the Avro appender.
         */
    removeAppenders(avroLogger);
    final Context context = new Context();
    testPort = String.valueOf(AvailablePortFinder.getNextAvailable());
    context.put("port", testPort);
    context.put("bind", "0.0.0.0");
    Configurables.configure(eventSource, context);
    final List<Channel> channels = new ArrayList<>();
    channels.add(channel);
    final ChannelSelector cs = new ReplicatingChannelSelector();
    cs.setChannels(channels);
    eventSource.setChannelProcessor(new ChannelProcessor(cs));
    eventSource.start();
    Assert.assertTrue("Reached start or error", LifecycleController.waitForOneOf(eventSource, LifecycleState.START_OR_ERROR));
    Assert.assertEquals("Server is started", LifecycleState.START, eventSource.getLifecycleState());
}
Also used : ThreadContext(org.apache.logging.log4j.ThreadContext) Context(org.apache.flume.Context) MemoryChannel(org.apache.flume.channel.MemoryChannel) AvroSource(org.apache.flume.source.AvroSource) ReplicatingChannelSelector(org.apache.flume.channel.ReplicatingChannelSelector) MemoryChannel(org.apache.flume.channel.MemoryChannel) Channel(org.apache.flume.Channel) ArrayList(java.util.ArrayList) ReplicatingChannelSelector(org.apache.flume.channel.ReplicatingChannelSelector) ChannelSelector(org.apache.flume.ChannelSelector) ChannelProcessor(org.apache.flume.channel.ChannelProcessor) Before(org.junit.Before)

Aggregations

ArrayList (java.util.ArrayList)1 Channel (org.apache.flume.Channel)1 ChannelSelector (org.apache.flume.ChannelSelector)1 Context (org.apache.flume.Context)1 ChannelProcessor (org.apache.flume.channel.ChannelProcessor)1 MemoryChannel (org.apache.flume.channel.MemoryChannel)1 ReplicatingChannelSelector (org.apache.flume.channel.ReplicatingChannelSelector)1 AvroSource (org.apache.flume.source.AvroSource)1 ThreadContext (org.apache.logging.log4j.ThreadContext)1 Before (org.junit.Before)1