Search in sources :

Example 1 with ProcessLogChunk

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());
}
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

IOUtils (com.walmartlabs.concord.common.IOUtils)1 HttpUtils (com.walmartlabs.concord.server.HttpUtils)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 ProcessLog (com.walmartlabs.concord.server.process.logs.ProcessLogsDao.ProcessLog)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 ProcessKey (com.walmartlabs.concord.server.sdk.ProcessKey)1 WithTimer (com.walmartlabs.concord.server.sdk.metrics.WithTimer)1 Api (io.swagger.annotations.Api)1 ApiOperation (io.swagger.annotations.ApiOperation)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 UUID (java.util.UUID)1