use of io.cdap.cdap.logging.read.Callback in project cdap by caskdata.
the class AbstractLogHttpHandler method doPrev.
protected void doPrev(LogReader logReader, HttpResponder responder, LoggingContext loggingContext, int maxEvents, String fromOffsetStr, boolean escape, String filterStr, @Nullable RunRecordDetail runRecord, String format, List<String> fieldsToSuppress) {
try {
Filter filter = FilterParser.parse(filterStr);
Callback logCallback = getNextOrPrevLogsCallback(format, responder, fieldsToSuppress, escape);
LogOffset logOffset = FormattedTextLogEvent.parseLogOffset(fromOffsetStr);
ReadRange readRange = ReadRange.createToRange(logOffset);
readRange = adjustReadRange(readRange, runRecord, true);
try {
logReader.getLogPrev(loggingContext, readRange, maxEvents, filter, logCallback);
} catch (Exception ex) {
LOG.debug("Exception while reading logs for logging context {}", loggingContext, ex);
} finally {
logCallback.close();
}
} catch (SecurityException e) {
responder.sendStatus(HttpResponseStatus.UNAUTHORIZED);
} catch (IllegalArgumentException e) {
responder.sendString(HttpResponseStatus.BAD_REQUEST, e.getMessage());
}
}
use of io.cdap.cdap.logging.read.Callback in project cdap by caskdata.
the class AbstractLogHttpHandler method doNext.
protected void doNext(LogReader logReader, HttpResponder responder, LoggingContext loggingContext, int maxEvents, String fromOffsetStr, boolean escape, String filterStr, @Nullable RunRecordDetail runRecord, String format, List<String> fieldsToSuppress) {
try {
Filter filter = FilterParser.parse(filterStr);
Callback logCallback = getNextOrPrevLogsCallback(format, responder, fieldsToSuppress, escape);
LogOffset logOffset = FormattedTextLogEvent.parseLogOffset(fromOffsetStr);
ReadRange readRange = ReadRange.createFromRange(logOffset);
readRange = adjustReadRange(readRange, runRecord, true);
try {
logReader.getLogNext(loggingContext, readRange, maxEvents, filter, logCallback);
} catch (Exception ex) {
LOG.debug("Exception while reading logs for logging context {}", loggingContext, ex);
} finally {
logCallback.close();
}
} catch (SecurityException e) {
responder.sendStatus(HttpResponseStatus.UNAUTHORIZED);
} catch (IllegalArgumentException e) {
responder.sendString(HttpResponseStatus.BAD_REQUEST, e.getMessage());
}
}