use of co.cask.cdap.logging.serialize.LoggingEventSerializer in project cdap by caskdata.
the class KafkaLogProcessorPipelineTest method publishLog.
private void publishLog(String topic, Iterable<ILoggingEvent> events, LoggingContext context) {
KafkaPublisher.Preparer preparer = KAFKA_TESTER.getKafkaClient().getPublisher(KafkaPublisher.Ack.LEADER_RECEIVED, Compression.NONE).prepare(topic);
LoggingEventSerializer serializer = new LoggingEventSerializer();
for (ILoggingEvent event : events) {
preparer.add(ByteBuffer.wrap(serializer.toBytes(new LogMessage(event, context))), context.getLogPartition());
}
preparer.send();
}
use of co.cask.cdap.logging.serialize.LoggingEventSerializer in project cdap by caskdata.
the class KafkaOffsetResolverTest method publishLog.
private void publishLog(String topic, Iterable<ILoggingEvent> events, LoggingContext context) {
KafkaPublisher.Preparer preparer = KAFKA_TESTER.getKafkaClient().getPublisher(KafkaPublisher.Ack.LEADER_RECEIVED, Compression.NONE).prepare(topic);
LoggingEventSerializer serializer = new LoggingEventSerializer();
for (ILoggingEvent event : events) {
preparer.add(ByteBuffer.wrap(serializer.toBytes(event)), context.getLogPartition());
}
preparer.send();
}
use of co.cask.cdap.logging.serialize.LoggingEventSerializer in project cdap by caskdata.
the class DistributedLogFrameworkTest method publishLog.
/**
* Publishes multiple log events.
*/
private void publishLog(String topic, LoggingContext context, Iterable<ILoggingEvent> events) {
KafkaPublisher.Preparer preparer = KAFKA_TESTER.getKafkaClient().getPublisher(KafkaPublisher.Ack.LEADER_RECEIVED, Compression.NONE).prepare(topic);
LoggingEventSerializer serializer = new LoggingEventSerializer();
for (ILoggingEvent event : events) {
preparer.add(ByteBuffer.wrap(serializer.toBytes(new LogMessage(event, context))), context.getLogPartition());
}
preparer.send();
}
use of co.cask.cdap.logging.serialize.LoggingEventSerializer in project cdap by caskdata.
the class TestKafkaLogging method convertFetchedMessage.
private Map.Entry<Integer, String> convertFetchedMessage(FetchedMessage message) throws IOException {
LoggingEventSerializer serializer = new LoggingEventSerializer();
ILoggingEvent iLoggingEvent = serializer.fromBytes(message.getPayload());
LoggingContext loggingContext = LoggingContextHelper.getLoggingContext(iLoggingEvent.getMDCPropertyMap());
String key = loggingContext.getLogPartition();
// Temporary map for pretty format
Map<String, String> tempMap = new HashMap<>();
tempMap.put("Timestamp", Long.toString(iLoggingEvent.getTimeStamp()));
return Maps.immutableEntry(message.getTopicPartition().getPartition(), key);
}
Aggregations