use of com.walmartlabs.concord.server.process.logs.ProcessLogsDao.ProcessLogChunk in project concord by walmartlabs.
the class ProcessLogResourceV2 method toResponse.
public static Response toResponse(UUID instanceId, long segmentId, ProcessLog l, HttpUtils.Range range) {
List<ProcessLogChunk> data = l.getChunks();
if (data.isEmpty()) {
int actualStart = range.start() != null ? range.start() : 0;
int actualEnd = range.end() != null ? range.end() : actualStart;
return downloadableFile(instanceId, segmentId, null, actualStart, actualEnd, l.getSize());
}
ProcessLogChunk firstChunk = data.get(0);
int actualStart = firstChunk.getStart();
ProcessLogChunk lastChunk = data.get(data.size() - 1);
int actualEnd = lastChunk.getStart() + lastChunk.getData().length;
StreamingOutput out = output -> {
for (ProcessLogChunk e : data) {
output.write(e.getData());
}
};
return downloadableFile(instanceId, segmentId, out, actualStart, actualEnd, l.getSize());
}
Aggregations