Search in sources :

Example 1 with ProcessLog

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);
}
Also used : HttpUtils(com.walmartlabs.concord.server.HttpUtils) ProcessKey(com.walmartlabs.concord.server.sdk.ProcessKey) ProcessLog(com.walmartlabs.concord.server.process.logs.ProcessLogsDao.ProcessLog) WithTimer(com.walmartlabs.concord.server.sdk.metrics.WithTimer) ApiOperation(io.swagger.annotations.ApiOperation)

Example 2 with ProcessLog

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);
}
Also used : HttpUtils(com.walmartlabs.concord.server.HttpUtils) PartialProcessKey(com.walmartlabs.concord.server.sdk.PartialProcessKey) ProcessKey(com.walmartlabs.concord.server.sdk.ProcessKey) ProcessLog(com.walmartlabs.concord.server.process.logs.ProcessLogsDao.ProcessLog) WithTimer(com.walmartlabs.concord.server.sdk.metrics.WithTimer) ApiOperation(io.swagger.annotations.ApiOperation)

Example 3 with ProcessLog

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());
}
Also used : HttpUtils(com.walmartlabs.concord.server.HttpUtils) Resource(org.sonatype.siesta.Resource) ProcessLogAccessManager(com.walmartlabs.concord.server.process.logs.ProcessLogAccessManager) ApiParam(io.swagger.annotations.ApiParam) ProcessKey(com.walmartlabs.concord.server.sdk.ProcessKey) ProcessKeyCache(com.walmartlabs.concord.server.process.queue.ProcessKeyCache) Singleton(javax.inject.Singleton) Inject(javax.inject.Inject) ApiOperation(io.swagger.annotations.ApiOperation) OperationResult(com.walmartlabs.concord.server.OperationResult) MediaType(javax.ws.rs.core.MediaType) WithTimer(com.walmartlabs.concord.server.sdk.metrics.WithTimer) Api(io.swagger.annotations.Api) Named(javax.inject.Named) ProcessLog(com.walmartlabs.concord.server.process.logs.ProcessLogsDao.ProcessLog) ProcessConfiguration(com.walmartlabs.concord.server.cfg.ProcessConfiguration) ProcessLogManager(com.walmartlabs.concord.server.process.logs.ProcessLogManager) ProcessLogChunk(com.walmartlabs.concord.server.process.logs.ProcessLogsDao.ProcessLogChunk) IOUtils(com.walmartlabs.concord.common.IOUtils) StreamingOutput(javax.ws.rs.core.StreamingOutput) IOException(java.io.IOException) UUID(java.util.UUID) List(java.util.List) javax.ws.rs(javax.ws.rs) Response(javax.ws.rs.core.Response) ValidationErrorsException(org.sonatype.siesta.ValidationErrorsException) ConcordApplicationException(com.walmartlabs.concord.server.sdk.ConcordApplicationException) Authorization(io.swagger.annotations.Authorization) InputStream(java.io.InputStream) ProcessLogChunk(com.walmartlabs.concord.server.process.logs.ProcessLogsDao.ProcessLogChunk) StreamingOutput(javax.ws.rs.core.StreamingOutput)

Aggregations

HttpUtils (com.walmartlabs.concord.server.HttpUtils)3 ProcessLog (com.walmartlabs.concord.server.process.logs.ProcessLogsDao.ProcessLog)3 ProcessKey (com.walmartlabs.concord.server.sdk.ProcessKey)3 WithTimer (com.walmartlabs.concord.server.sdk.metrics.WithTimer)3 ApiOperation (io.swagger.annotations.ApiOperation)3 IOUtils (com.walmartlabs.concord.common.IOUtils)1 OperationResult (com.walmartlabs.concord.server.OperationResult)1 ProcessConfiguration (com.walmartlabs.concord.server.cfg.ProcessConfiguration)1 ProcessLogAccessManager (com.walmartlabs.concord.server.process.logs.ProcessLogAccessManager)1 ProcessLogManager (com.walmartlabs.concord.server.process.logs.ProcessLogManager)1 ProcessLogChunk (com.walmartlabs.concord.server.process.logs.ProcessLogsDao.ProcessLogChunk)1 ProcessKeyCache (com.walmartlabs.concord.server.process.queue.ProcessKeyCache)1 ConcordApplicationException (com.walmartlabs.concord.server.sdk.ConcordApplicationException)1 PartialProcessKey (com.walmartlabs.concord.server.sdk.PartialProcessKey)1 Api (io.swagger.annotations.Api)1 ApiParam (io.swagger.annotations.ApiParam)1 Authorization (io.swagger.annotations.Authorization)1 IOException (java.io.IOException)1 InputStream (java.io.InputStream)1 List (java.util.List)1