use of com.walmartlabs.concord.server.sdk.metrics.WithTimer in project concord by walmartlabs.
the class ProcessEventResource method batchEvent.
/**
* Register multiple events for the specified process.
*/
@POST
@ApiOperation(value = "Register multiple events for the specified process", authorizations = { @Authorization("session_key"), @Authorization("api_key") })
@Path("/{processInstanceId}/eventBatch")
@Consumes(MediaType.APPLICATION_JSON)
@WithTimer
public void batchEvent(@ApiParam @PathParam("processInstanceId") UUID processInstanceId, @ApiParam List<ProcessEventRequest> data) {
ProcessKey processKey = assertProcessKey(processInstanceId);
List<NewProcessEvent> events = data.stream().map(req -> NewProcessEvent.builder().processKey(processKey).eventType(req.getEventType()).eventDate(req.getEventDate()).data(req.getData()).build()).collect(Collectors.toList());
eventManager.event(events);
}
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 input
* @param parentInstanceId
* @param sync
* @return
*/
@POST
@ApiOperation("Start a new process using multipart request data")
@Consumes(MediaType.MULTIPART_FORM_DATA)
@Produces(MediaType.APPLICATION_JSON)
@WithTimer
public StartProcessResponse start(@ApiParam MultipartInput input, @ApiParam @Deprecated @QueryParam("parentId") UUID parentInstanceId, @ApiParam @Deprecated @DefaultValue("false") @QueryParam("sync") boolean sync, @ApiParam @Deprecated @QueryParam("out") String[] out, @Context HttpServletRequest request) {
boolean sync2 = MultipartUtils.getBoolean(input, Constants.Multipart.SYNC, false);
if (sync || sync2) {
throw syncIsForbidden();
}
Payload payload;
try {
payload = payloadManager.createPayload(input, request);
// TODO remove after deprecating the old endpoints
payload = PayloadBuilder.basedOn(payload).parentInstanceId(parentInstanceId).mergeOutExpressions(out).build();
} 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));
}
use of com.walmartlabs.concord.server.sdk.metrics.WithTimer in project concord by walmartlabs.
the class ProcessResource method appendLog.
/**
* Appends a process' log.
*
* @param instanceId
* @param data
* @see ProcessLogResourceV2
* @deprecated in favor of the /api/v2/process/{id}/log* endpoints
*/
@POST
@javax.ws.rs.Path("{id}/log")
@Consumes(MediaType.APPLICATION_OCTET_STREAM)
@WithTimer
@Deprecated
public void appendLog(@PathParam("id") UUID instanceId, InputStream data) {
ProcessKey processKey = assertProcessKey(instanceId);
try {
byte[] ab = IOUtils.toByteArray(data);
int upper = logManager.log(processKey, ab);
// whenever we accept logs from an external source (e.g. from an Agent) we need to check
// the log size limits
int logSizeLimit = processCfg.getLogSizeLimit();
if (upper >= logSizeLimit) {
logManager.error(processKey, "Maximum log size reached: {}. Process cancelled.", logSizeLimit);
processManager.kill(processKey);
}
} catch (IOException e) {
throw new ConcordApplicationException("Error while appending a log: " + e.getMessage());
}
}
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 provided configuration.
*
* @param entryPoint
* @param req
* @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 provided configuration", hidden = true)
@javax.ws.rs.Path("/{entryPoint}")
@Consumes(MediaType.APPLICATION_JSON)
@Produces(MediaType.APPLICATION_JSON)
@WithTimer(suffix = "_json")
@Deprecated
public StartProcessResponse start(@PathParam("entryPoint") String entryPoint, Map<String, Object> req, @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());
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, req, 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));
}
use of com.walmartlabs.concord.server.sdk.metrics.WithTimer in project concord by walmartlabs.
the class ProcessResource method disable.
/**
* Disable a process.
*
* @param instanceId
* @param disabled
*/
@POST
@ApiOperation("Disable a process")
@javax.ws.rs.Path("/{id}/disable/{disabled}")
@WithTimer
public void disable(@ApiParam @PathParam("id") UUID instanceId, @ApiParam @PathParam("disabled") boolean disabled) {
ProcessKey processKey = assertProcessKey(instanceId);
processManager.disable(processKey, disabled);
}
Aggregations