Search in sources :

Example 1 with LoggingEvent

use of io.cdap.cdap.logging.serialize.LoggingEvent in project cdap by caskdata.

the class LogLocation method readToEndSyncPosition.

/**
 *  Read current block in Avro file from current block sync marker to next block sync marker
 */
private List<LogEvent> readToEndSyncPosition(DataFileReader<GenericRecord> dataFileReader, Filter logFilter, long fromTimeMs, long endSyncPosition) throws IOException {
    List<LogEvent> logSegment = new ArrayList<>();
    long currentSyncPosition = dataFileReader.previousSync();
    // or read until endSyncPosition has been reached
    while (dataFileReader.hasNext() && (endSyncPosition == -1 || (currentSyncPosition < endSyncPosition))) {
        ILoggingEvent loggingEvent = new LoggingEvent(dataFileReader.next());
        loggingEvent.prepareForDeferredProcessing();
        // Stop when reached fromTimeMs
        if (loggingEvent.getTimeStamp() > fromTimeMs) {
            break;
        }
        if (logFilter.match(loggingEvent)) {
            logSegment.add(new LogEvent(loggingEvent, new LogOffset(LogOffset.INVALID_KAFKA_OFFSET, loggingEvent.getTimeStamp())));
        }
        currentSyncPosition = dataFileReader.previousSync();
    }
    return logSegment;
}
Also used : LoggingEvent(io.cdap.cdap.logging.serialize.LoggingEvent) ILoggingEvent(ch.qos.logback.classic.spi.ILoggingEvent) LogEvent(io.cdap.cdap.logging.read.LogEvent) LogOffset(io.cdap.cdap.logging.read.LogOffset) ArrayList(java.util.ArrayList) ILoggingEvent(ch.qos.logback.classic.spi.ILoggingEvent)

Aggregations

ILoggingEvent (ch.qos.logback.classic.spi.ILoggingEvent)1 LogEvent (io.cdap.cdap.logging.read.LogEvent)1 LogOffset (io.cdap.cdap.logging.read.LogOffset)1 LoggingEvent (io.cdap.cdap.logging.serialize.LoggingEvent)1 ArrayList (java.util.ArrayList)1