use of com.walmartlabs.concord.server.process.logs.ProcessLogsDao.ProcessLog in project concord by walmartlabs.
the class ProcessLogResourceV2 method data.
/**
* Retrieves a log segment' data.
*/
@GET
@ApiOperation(value = "Retrieve the log")
@Path("/{id}/log/segment/{segmentId}/data")
@Produces(MediaType.APPLICATION_OCTET_STREAM)
@WithTimer
public Response data(@ApiParam @PathParam("id") UUID instanceId, @ApiParam @PathParam("segmentId") long segmentId, @HeaderParam("range") String rangeHeader) {
ProcessKey processKey = logAccessManager.assertLogAccess(instanceId);
HttpUtils.Range range = HttpUtils.parseRangeHeaderValue(rangeHeader);
ProcessLog l = logManager.segmentData(processKey, segmentId, range.start(), range.end());
return toResponse(instanceId, segmentId, l, range);
}
use of com.walmartlabs.concord.server.process.logs.ProcessLogsDao.ProcessLog in project concord by walmartlabs.
the class ProcessResource method getLog.
/**
* Retrieves a process' log.
*
* @param instanceId
* @param rangeHeader
* @return
* @see ProcessLogResourceV2
* @deprecated in favor of the /api/v2/process/{id}/log* endpoints
*/
@GET
@ApiOperation(value = "Retrieve the log")
@javax.ws.rs.Path("/{id}/log")
@Produces(MediaType.APPLICATION_OCTET_STREAM)
@WithTimer
@Deprecated
public Response getLog(@ApiParam @PathParam("id") UUID instanceId, @HeaderParam("range") String rangeHeader) {
// check the permissions, logs can contain sensitive data
ProcessKey processKey = logAccessManager.assertLogAccess(instanceId);
HttpUtils.Range range = HttpUtils.parseRangeHeaderValue(rangeHeader);
ProcessLog l = logManager.get(processKey, range.start(), range.end());
return ProcessLogResourceV2.toResponse(instanceId, 0, l, range);
}
use of com.walmartlabs.concord.server.process.logs.ProcessLogsDao.ProcessLog 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