use of com.walmartlabs.concord.server.process.ProcessEntry in project concord by walmartlabs.
the class ProcessLocksResource method unlock.
/**
* Releases the lock.
*/
@POST
@ApiOperation("Releases the lock")
@Path("/{processInstanceId}/unlock/{lockName}")
@WithTimer
public void unlock(@PathParam("processInstanceId") UUID instanceId, @PathParam("lockName") String lockName, @QueryParam("scope") @DefaultValue("PROJECT") ProcessLockScope scope) {
ProcessEntry e = assertProcess(instanceId);
dao.delete(e.instanceId(), e.orgId(), e.projectId(), scope, lockName);
}
use of com.walmartlabs.concord.server.process.ProcessEntry in project concord by walmartlabs.
the class ProcessLocksResource method tryLock.
/**
* Acquires the lock if it is available and returns the LockResult.acquired = true.
* If the lock is not available then this method will return the LockResult.acquired = false.
*/
@POST
@ApiOperation("Try lock")
@Path("/{processInstanceId}/lock/{lockName}")
@Produces(MediaType.APPLICATION_JSON)
@WithTimer
public LockResult tryLock(@PathParam("processInstanceId") UUID instanceId, @PathParam("lockName") String lockName, @QueryParam("scope") @DefaultValue("PROJECT") ProcessLockScope scope) {
ProcessEntry e = assertProcess(instanceId);
LockEntry lock = dao.tryLock(new ProcessKey(e.instanceId(), e.createdAt()), e.orgId(), e.projectId(), scope, lockName);
boolean acquired = lock.instanceId().equals(instanceId);
return LockResult.builder().acquired(acquired).info(lock).build();
}
use of com.walmartlabs.concord.server.process.ProcessEntry in project concord by walmartlabs.
the class ForkRepositoryInfoProcessor method process.
@Override
@WithTimer
public Payload process(Chain chain, Payload payload) {
UUID parentInstanceId = payload.getHeader(Payload.PARENT_INSTANCE_ID);
ProcessEntry parent = queueManager.get(PartialProcessKey.from(parentInstanceId));
if (parent == null) {
throw new ProcessException(payload.getProcessKey(), "Parent process '" + parentInstanceId + "' not found");
}
RepositoryProcessor.CommitInfo ci = new RepositoryProcessor.CommitInfo(parent.commitId(), parent.commitBranch(), null, parent.commitMsg());
RepositoryProcessor.RepositoryInfo i = new RepositoryProcessor.RepositoryInfo(parent.repoId(), parent.repoName(), parent.repoUrl(), parent.repoPath(), parent.commitBranch(), parent.commitId(), ci);
payload = payload.putHeader(REPOSITORY_INFO_KEY, i);
return chain.process(payload);
}
use of com.walmartlabs.concord.server.process.ProcessEntry 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();
}
use of com.walmartlabs.concord.server.process.ProcessEntry in project concord by walmartlabs.
the class ProcessCheckpointResource method uploadCheckpoint.
@POST
@javax.ws.rs.Path("{id}/checkpoint")
@Consumes(MediaType.MULTIPART_FORM_DATA)
public void uploadCheckpoint(@PathParam("id") UUID instanceId, @ApiParam MultipartInput input) {
// TODO replace with ProcessKeyCache
ProcessEntry entry = processManager.assertProcess(instanceId);
ProcessKey processKey = new ProcessKey(entry.instanceId(), entry.createdAt());
UUID checkpointId = MultipartUtils.assertUuid(input, "id");
UUID correlationId = MultipartUtils.assertUuid(input, "correlationId");
String checkpointName = MultipartUtils.assertString(input, "name");
try (InputStream data = MultipartUtils.assertStream(input, "data");
TemporaryPath tmpIn = IOUtils.tempFile("checkpoint", ".zip")) {
Files.copy(data, tmpIn.path(), StandardCopyOption.REPLACE_EXISTING);
checkpointManager.importCheckpoint(processKey, checkpointId, correlationId, checkpointName, tmpIn.path());
} catch (ValidationErrorsException e) {
throw new ConcordApplicationException(e.getMessage(), Response.Status.BAD_REQUEST);
} catch (IOException e) {
log.error("uploadCheckpoint ['{}'] -> error", processKey, e);
throw new ConcordApplicationException("upload error: " + e.getMessage());
}
log.info("uploadCheckpoint ['{}'] -> done", processKey);
}
Aggregations