use of com.walmartlabs.concord.server.sdk.metrics.WithTimer in project concord by walmartlabs.
the class ProcessResource method kill.
/**
* Forcefully stops a process.
*
* @param instanceId
*/
@DELETE
@ApiOperation("Forcefully stops a process")
@javax.ws.rs.Path("/{id}")
@WithTimer
public void kill(@ApiParam @PathParam("id") UUID instanceId) {
ProcessKey processKey = assertProcessKey(instanceId);
processManager.kill(processKey);
}
use of com.walmartlabs.concord.server.sdk.metrics.WithTimer in project concord by walmartlabs.
the class ProcessResource method listAttachments.
/**
* Lists process attachments.
*
* @param instanceId
* @return
*/
@GET
@ApiOperation(value = "List attachments", responseContainer = "list", response = String.class)
@javax.ws.rs.Path("/{id}/attachment")
@Produces(MediaType.APPLICATION_JSON)
@WithTimer
public List<String> listAttachments(@ApiParam @PathParam("id") UUID instanceId) {
ProcessEntry processEntry = processManager.assertProcess(instanceId);
assertProcessAccess(processEntry, "attachments");
PartialProcessKey processKey = new ProcessKey(processEntry.instanceId(), processEntry.createdAt());
String resource = Constants.Files.JOB_ATTACHMENTS_DIR_NAME + "/";
List<String> l = stateManager.list(processKey, resource);
return l.stream().map(s -> s.substring(resource.length())).collect(Collectors.toList());
}
use of com.walmartlabs.concord.server.sdk.metrics.WithTimer in project concord by walmartlabs.
the class ProcessResourceV2 method get.
/**
* Returns a process instance's details.
*/
@GET
@ApiOperation("Get a process' details")
@Path("/{id}")
@Produces(MediaType.APPLICATION_JSON)
@WithTimer
public ProcessEntry get(@ApiParam @PathParam("id") UUID instanceId, @ApiParam @QueryParam("include") Set<ProcessDataInclude> includes) {
PartialProcessKey processKey = PartialProcessKey.from(instanceId);
ProcessEntry e = processQueueManager.get(processKey, includes);
if (e == null) {
log.warn("get ['{}'] -> not found", instanceId);
throw new ConcordApplicationException("Process instance not found", Status.NOT_FOUND);
}
if (e.projectId() != null) {
projectAccessManager.assertAccess(e.orgId(), e.projectId(), null, ResourceAccessLevel.READER, false);
}
return e;
}
use of com.walmartlabs.concord.server.sdk.metrics.WithTimer in project concord by walmartlabs.
the class PayloadManager method createPayload.
@WithTimer
public Payload createPayload(MultipartInput input, HttpServletRequest request) throws IOException {
PartialProcessKey processKey = PartialProcessKey.create();
UUID parentInstanceId = MultipartUtils.getUuid(input, Constants.Multipart.PARENT_INSTANCE_ID);
UUID orgId = getOrg(input);
UUID projectId = getProject(input, orgId);
UUID repoId = getRepo(input, projectId);
if (repoId != null && projectId == null) {
// allow starting processes by specifying repository IDs without project IDs or names
projectId = repositoryDao.getProjectId(repoId);
}
String entryPoint = MultipartUtils.getString(input, Constants.Multipart.ENTRY_POINT);
UserPrincipal initiator = UserPrincipal.assertCurrent();
String[] out = getOutExpressions(input);
Map<String, Object> meta = MultipartUtils.getMap(input, Constants.Multipart.META);
if (meta == null) {
meta = Collections.emptyMap();
}
return PayloadBuilder.start(processKey).parentInstanceId(parentInstanceId).with(input).organization(orgId).project(projectId).repository(repoId).entryPoint(entryPoint).outExpressions(out).initiator(initiator.getId(), initiator.getUsername()).meta(meta).request(request).build();
}
use of com.walmartlabs.concord.server.sdk.metrics.WithTimer in project concord by walmartlabs.
the class ProcessCheckpointV2Resource method processCheckpoint.
@GET
@ApiOperation(value = "Process checkpoint")
@javax.ws.rs.Path("{id}/checkpoint")
@Consumes(MediaType.APPLICATION_JSON)
@Produces(MediaType.APPLICATION_JSON)
@WithTimer
public GenericCheckpointResponse processCheckpoint(@ApiParam @PathParam("id") UUID instanceId, @ApiParam @QueryParam("name") String checkpointName, @ApiParam @QueryParam("action") String action) {
ProcessEntry entry = processManager.assertProcess(instanceId);
ProcessKey processKey = new ProcessKey(entry.instanceId(), entry.createdAt());
switch(action) {
case RESTORE_PROCESS_ACTION:
{
return restore(processKey, checkpointName);
}
default:
{
throw new ConcordApplicationException("Invalid action type: " + action);
}
}
}
Aggregations