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;
}
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();
}
}
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) {
}
}
}
Aggregations