Search in sources :

Example 41 with WithTimer

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

the class ProcessResource method killCascade.

/**
 * Forcefully stops a process and all its children.
 *
 * @param instanceId
 */
@DELETE
@ApiOperation("Forcefully stops a process and its all children")
@javax.ws.rs.Path("/{id}/cascade")
@WithTimer
public void killCascade(@ApiParam @PathParam("id") UUID instanceId) {
    PartialProcessKey processKey = PartialProcessKey.from(instanceId);
    processManager.killCascade(processKey);
}
Also used : PartialProcessKey(com.walmartlabs.concord.server.sdk.PartialProcessKey) WithTimer(com.walmartlabs.concord.server.sdk.metrics.WithTimer) ApiOperation(io.swagger.annotations.ApiOperation)

Example 42 with WithTimer

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

the class ProcessResource method start.

/**
 * Starts a new process instance using the specified entry point and payload archive.
 *
 * @param entryPoint
 * @param in
 * @param parentInstanceId
 * @param sync
 * @return
 * @deprecated use {@link #start(MultipartInput, UUID, boolean, String[], HttpServletRequest)}
 */
@POST
@ApiOperation(value = "Start a new process using the specified entry point and payload archive", hidden = true)
@javax.ws.rs.Path("/{entryPoint}")
@Consumes(MediaType.APPLICATION_OCTET_STREAM)
@Produces(MediaType.APPLICATION_JSON)
@WithTimer(suffix = "_octetstream_and_entrypoint")
@Deprecated
public StartProcessResponse start(@PathParam("entryPoint") String entryPoint, InputStream in, @QueryParam("parentId") UUID parentInstanceId, @Deprecated @DefaultValue("false") @QueryParam("sync") boolean sync, @QueryParam("out") String[] out) {
    if (sync) {
        throw syncIsForbidden();
    }
    // allow empty POST requests
    if (isEmpty(in)) {
        return start(entryPoint, parentInstanceId, sync, out);
    }
    assertPartialKey(parentInstanceId);
    PartialProcessKey processKey = PartialProcessKey.from(UUID.randomUUID());
    UUID orgId = OrganizationManager.DEFAULT_ORG_ID;
    EntryPoint ep = payloadManager.parseEntryPoint(processKey, orgId, entryPoint);
    UserPrincipal userPrincipal = UserPrincipal.assertCurrent();
    Payload payload;
    try {
        payload = payloadManager.createPayload(processKey, parentInstanceId, userPrincipal.getId(), userPrincipal.getUsername(), ep, in, out);
    } catch (IOException e) {
        log.error("start ['{}'] -> error creating a payload: {}", entryPoint, e);
        throw new ConcordApplicationException("Error creating a payload", e);
    }
    return toResponse(processManager.start(payload));
}
Also used : PartialProcessKey(com.walmartlabs.concord.server.sdk.PartialProcessKey) ConcordApplicationException(com.walmartlabs.concord.server.sdk.ConcordApplicationException) EntryPoint(com.walmartlabs.concord.server.process.PayloadManager.EntryPoint) UserPrincipal(com.walmartlabs.concord.server.security.UserPrincipal) WithTimer(com.walmartlabs.concord.server.sdk.metrics.WithTimer) ApiOperation(io.swagger.annotations.ApiOperation)

Example 43 with WithTimer

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

the class ProcessResource method resume.

/**
 * Resumes an existing process.
 */
@POST
@ApiOperation("Resume a process")
@javax.ws.rs.Path("/{id}/resume/{eventName}")
@Consumes(MediaType.APPLICATION_JSON)
@Produces(MediaType.APPLICATION_JSON)
@WithTimer
public ResumeProcessResponse resume(@ApiParam @PathParam("id") UUID instanceId, @ApiParam @PathParam("eventName") @NotNull String eventName, @ApiParam @QueryParam("saveAs") String saveAs, @ApiParam Map<String, Object> req) {
    PartialProcessKey processKey = PartialProcessKey.from(instanceId);
    if (saveAs != null && !saveAs.isEmpty() && req != null) {
        req = ConfigurationUtils.toNested(saveAs, req);
    }
    req = ExpressionUtils.escapeMap(req);
    Payload payload;
    try {
        payload = payloadManager.createResumePayload(processKey, eventName, req);
    } catch (IOException e) {
        log.error("resume ['{}', '{}'] -> error creating a payload: {}", instanceId, eventName, e);
        throw new ConcordApplicationException("Error creating a payload", e);
    }
    processManager.resume(payload);
    return new ResumeProcessResponse();
}
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 44 with WithTimer

use of com.walmartlabs.concord.server.sdk.metrics.WithTimer 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 45 with WithTimer

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

the class ProcessResource method start.

/**
 * Starts a new process instance.
 *
 * @param in
 * @param parentInstanceId
 * @param sync
 * @return
 * @deprecated use {@link #start(MultipartInput, UUID, boolean, String[], HttpServletRequest)}
 */
@POST
@ApiOperation(value = "Start a new process instance using the supplied payload archive", hidden = true)
@Consumes(MediaType.APPLICATION_OCTET_STREAM)
@Produces(MediaType.APPLICATION_JSON)
@WithTimer(suffix = "_octetstream")
@Deprecated
public StartProcessResponse start(InputStream in, @QueryParam("parentId") UUID parentInstanceId, @Deprecated @DefaultValue("false") @QueryParam("sync") boolean sync, @QueryParam("out") String[] out) {
    if (sync) {
        throw syncIsForbidden();
    }
    assertPartialKey(parentInstanceId);
    PartialProcessKey processKey = PartialProcessKey.from(UUID.randomUUID());
    UserPrincipal userPrincipal = UserPrincipal.assertCurrent();
    Payload payload;
    try {
        payload = payloadManager.createPayload(processKey, parentInstanceId, userPrincipal.getId(), userPrincipal.getUsername(), in, out);
    } catch (IOException e) {
        log.error("start -> error creating a payload: {}", e.getMessage());
        throw new ConcordApplicationException("Error creating a payload", e);
    }
    return toResponse(processManager.start(payload));
}
Also used : PartialProcessKey(com.walmartlabs.concord.server.sdk.PartialProcessKey) ConcordApplicationException(com.walmartlabs.concord.server.sdk.ConcordApplicationException) UserPrincipal(com.walmartlabs.concord.server.security.UserPrincipal) 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