Search in sources :

Example 1 with SimpleEvent

use of org.apache.flume.event.SimpleEvent in project cdap-ingest by caskdata.

the class MockStreamSink method getMockChannel.

private Channel getMockChannel() {
    Channel channel = Mockito.mock(Channel.class);
    Transaction transaction = Mockito.mock(Transaction.class);
    Mockito.doNothing().when(transaction).begin();
    Mockito.doNothing().when(transaction).commit();
    Mockito.doNothing().when(transaction).close();
    Mockito.doNothing().when(transaction).rollback();
    Mockito.when(channel.getTransaction()).thenReturn(transaction);
    Mockito.when(channel.take()).thenReturn(new SimpleEvent());
    return channel;
}
Also used : SimpleEvent(org.apache.flume.event.SimpleEvent) Transaction(org.apache.flume.Transaction) Channel(org.apache.flume.Channel)

Example 2 with SimpleEvent

use of org.apache.flume.event.SimpleEvent in project chassis by Kixeye.

the class FlumeLogAppender method append.

@Override
protected void append(ILoggingEvent logEvent) {
    SimpleEvent flumeEvent = new SimpleEvent();
    Map<String, String> headers = new HashMap<>();
    headers.put("timestamp", "" + logEvent.getTimeStamp());
    headers.put("level", logEvent.getLevel().levelStr);
    headers.put("threadName", logEvent.getThreadName());
    headers.put("loggerName", logEvent.getLoggerName());
    headers.put("product", product);
    headers.put("hostname", NetworkingUtils.getIpAddress());
    flumeEvent.setHeaders(headers);
    flumeEvent.setBody(logEvent.getFormattedMessage().getBytes(Charsets.UTF_8));
    try {
        agent.put(flumeEvent);
    } catch (Exception e) {
        e.printStackTrace();
    }
}
Also used : SimpleEvent(org.apache.flume.event.SimpleEvent) HashMap(java.util.HashMap)

Example 3 with SimpleEvent

use of org.apache.flume.event.SimpleEvent in project cdap-ingest by caskdata.

the class CdapFlumeIT method writeEvents.

private void writeEvents(EmbeddedAgent agent, int startNumber, int endNumber) {
    for (int i = startNumber; i < endNumber; i++) {
        Event event = new SimpleEvent();
        event.setBody((EVENT_STR + i).getBytes());
        try {
            agent.put(event);
        } catch (EventDeliveryException ignored) {
        }
    }
}
Also used : SimpleEvent(org.apache.flume.event.SimpleEvent) EventDeliveryException(org.apache.flume.EventDeliveryException) Event(org.apache.flume.Event) SimpleEvent(org.apache.flume.event.SimpleEvent)

Aggregations

SimpleEvent (org.apache.flume.event.SimpleEvent)3 HashMap (java.util.HashMap)1 Channel (org.apache.flume.Channel)1 Event (org.apache.flume.Event)1 EventDeliveryException (org.apache.flume.EventDeliveryException)1 Transaction (org.apache.flume.Transaction)1