Search in sources :

Example 21 with WithTimer

use of com.walmartlabs.concord.server.sdk.metrics.WithTimer in project concord by walmartlabs.

the class ProcessResource method get.

/**
 * Returns a process instance details.
 *
 * @deprecated use {@link ProcessResourceV2#get(UUID, Set)}
 */
@GET
@ApiOperation("Get a process' details")
@javax.ws.rs.Path("/{id}")
@Produces(MediaType.APPLICATION_JSON)
@WithTimer
@Deprecated
public ProcessEntry get(@ApiParam @PathParam("id") UUID instanceId) {
    PartialProcessKey processKey = PartialProcessKey.from(instanceId);
    ProcessEntry e = processQueueManager.get(processKey);
    if (e == null) {
        log.warn("get ['{}'] -> not found", instanceId);
        throw new ConcordApplicationException("Process instance not found", Status.NOT_FOUND);
    }
    return e;
}
Also used : PartialProcessKey(com.walmartlabs.concord.server.sdk.PartialProcessKey) ConcordApplicationException(com.walmartlabs.concord.server.sdk.ConcordApplicationException) WithTimer(com.walmartlabs.concord.server.sdk.metrics.WithTimer) ApiOperation(io.swagger.annotations.ApiOperation)

Example 22 with WithTimer

use of com.walmartlabs.concord.server.sdk.metrics.WithTimer in project concord by walmartlabs.

the class ProcessResource method updateStatus.

/**
 * Updates a process' status
 *
 * @param instanceId
 * @param status
 */
@POST
@ApiOperation("Update process status")
@javax.ws.rs.Path("{id}/status")
@Consumes(MediaType.TEXT_PLAIN)
@WithTimer
public void updateStatus(@ApiParam @PathParam("id") UUID instanceId, @ApiParam(required = true) @QueryParam("agentId") String agentId, @ApiParam(required = true) ProcessStatus status) {
    ProcessKey processKey = assertProcessKey(instanceId);
    processManager.updateStatus(processKey, agentId, status);
}
Also used : PartialProcessKey(com.walmartlabs.concord.server.sdk.PartialProcessKey) ProcessKey(com.walmartlabs.concord.server.sdk.ProcessKey) WithTimer(com.walmartlabs.concord.server.sdk.metrics.WithTimer) ApiOperation(io.swagger.annotations.ApiOperation)

Example 23 with WithTimer

use of com.walmartlabs.concord.server.sdk.metrics.WithTimer in project concord by walmartlabs.

the class ProcessCheckpointResource method restore.

@POST
@ApiOperation(value = "Restore process from checkpoint")
@javax.ws.rs.Path("{id}/checkpoint/restore")
@Consumes(MediaType.APPLICATION_JSON)
@Produces(MediaType.APPLICATION_JSON)
@WithTimer
@Validate
public ResumeProcessResponse restore(@ApiParam @PathParam("id") UUID instanceId, @ApiParam @Valid RestoreCheckpointRequest request) {
    UUID checkpointId = request.getId();
    // TODO replace with ProcessKeyCache
    ProcessEntry entry = processManager.assertProcess(instanceId);
    ProcessKey processKey = new ProcessKey(entry.instanceId(), entry.createdAt());
    processManager.restoreFromCheckpoint(processKey, checkpointId);
    return new ResumeProcessResponse();
}
Also used : ProcessEntry(com.walmartlabs.concord.server.process.ProcessEntry) ProcessKey(com.walmartlabs.concord.server.sdk.ProcessKey) UUID(java.util.UUID) ResumeProcessResponse(com.walmartlabs.concord.server.process.ResumeProcessResponse) Validate(org.sonatype.siesta.Validate) WithTimer(com.walmartlabs.concord.server.sdk.metrics.WithTimer) ApiOperation(io.swagger.annotations.ApiOperation)

Example 24 with WithTimer

use of com.walmartlabs.concord.server.sdk.metrics.WithTimer in project concord by walmartlabs.

the class ProcessCheckpointResource method list.

@GET
@ApiOperation(value = "List the process checkpoints", responseContainer = "list", response = ProcessCheckpointEntry.class)
@javax.ws.rs.Path("{id}/checkpoint")
@Produces(MediaType.APPLICATION_JSON)
@WithTimer
public List<ProcessCheckpointEntry> list(@ApiParam @PathParam("id") UUID instanceId) {
    ProcessEntry entry = processManager.assertProcess(instanceId);
    ProcessKey processKey = new ProcessKey(entry.instanceId(), entry.createdAt());
    checkpointManager.assertProcessAccess(entry);
    return checkpointManager.list(processKey);
}
Also used : ProcessEntry(com.walmartlabs.concord.server.process.ProcessEntry) ProcessKey(com.walmartlabs.concord.server.sdk.ProcessKey) WithTimer(com.walmartlabs.concord.server.sdk.metrics.WithTimer) ApiOperation(io.swagger.annotations.ApiOperation)

Example 25 with WithTimer

use of com.walmartlabs.concord.server.sdk.metrics.WithTimer in project concord by walmartlabs.

the class ProcessEventResource method list.

/**
 * List process events.
 */
@GET
@ApiOperation(value = "List process events", responseContainer = "list", response = ProcessEventEntry.class)
@Path("/{processInstanceId}/event")
@Produces(MediaType.APPLICATION_JSON)
@WithTimer
public List<ProcessEventEntry> list(@ApiParam @PathParam("processInstanceId") UUID processInstanceId, @ApiParam @QueryParam("type") String eventType, @ApiParam @QueryParam("after") OffsetDateTimeParam after, @ApiParam @QueryParam("fromId") Long fromId, @ApiParam @QueryParam("eventCorrelationId") UUID eventCorrelationId, @ApiParam @QueryParam("eventPhase") EventPhase eventPhase, @ApiParam @QueryParam("includeAll") @DefaultValue("false") boolean includeAll, @ApiParam @QueryParam("limit") @DefaultValue("-1") int limit) {
    ProcessKey processKey = assertProcessKey(processInstanceId);
    if (includeAll) {
        // verify that the user can access potentially sensitive data
        assertAccessRights(processKey);
    }
    ProcessEventFilter f = ProcessEventFilter.builder().processKey(processKey).after(unwrap(after)).eventType(eventType).eventCorrelationId(eventCorrelationId).eventPhase(eventPhase).limit(limit).fromId(fromId).build();
    List<ProcessEventEntry> l = eventManager.list(f);
    if (!includeAll) {
        l = filterOutSensitiveData(l);
    }
    return l;
}
Also used : ProcessKey(com.walmartlabs.concord.server.sdk.ProcessKey) PartialProcessKey(com.walmartlabs.concord.server.sdk.PartialProcessKey) WithTimer(com.walmartlabs.concord.server.sdk.metrics.WithTimer) ApiOperation(io.swagger.annotations.ApiOperation)

Aggregations

WithTimer (com.walmartlabs.concord.server.sdk.metrics.WithTimer)64 ApiOperation (io.swagger.annotations.ApiOperation)32 ProcessKey (com.walmartlabs.concord.server.sdk.ProcessKey)26 PartialProcessKey (com.walmartlabs.concord.server.sdk.PartialProcessKey)24 ConcordApplicationException (com.walmartlabs.concord.server.sdk.ConcordApplicationException)22 UserPrincipal (com.walmartlabs.concord.server.security.UserPrincipal)16 UnauthorizedException (org.apache.shiro.authz.UnauthorizedException)10 UUID (java.util.UUID)9 ProcessEntry (com.walmartlabs.concord.server.process.ProcessEntry)7 EntryPoint (com.walmartlabs.concord.server.process.PayloadManager.EntryPoint)6 Inject (javax.inject.Inject)5 Named (javax.inject.Named)5 Payload (com.walmartlabs.concord.server.process.Payload)4 Path (java.nio.file.Path)4 ValidationErrorsException (org.sonatype.siesta.ValidationErrorsException)4 ObjectMapper (com.fasterxml.jackson.databind.ObjectMapper)3 HttpUtils (com.walmartlabs.concord.server.HttpUtils)3 ProcessFilter (com.walmartlabs.concord.server.process.queue.ProcessFilter)3 UserEntry (com.walmartlabs.concord.server.user.UserEntry)3 IOException (java.io.IOException)3