use of com.walmartlabs.concord.server.sdk.metrics.WithTimer in project concord by walmartlabs.
the class EnqueueingProcessor method process.
@Override
@WithTimer
public Payload process(Chain chain, Payload payload) {
boolean enqueued = queueManager.enqueue(payload);
if (!enqueued) {
// (e.g. "exclusive" processes can be rejected before reaching the ENQUEUED status)
return payload;
}
ProcessKey processKey = payload.getProcessKey();
Map<String, Object> requirements = PayloadUtils.getRequirements(payload);
OffsetDateTime startAt = PayloadUtils.getStartAt(payload);
if (startAt == null) {
logManager.info(processKey, "Enqueued. Waiting for an agent (requirements={})...", requirements);
} else {
logManager.info(processKey, "Enqueued. Starting at {} (requirements={})...", startAt, requirements);
}
return chain.process(payload);
}
use of com.walmartlabs.concord.server.sdk.metrics.WithTimer in project concord by walmartlabs.
the class ExclusiveGroupProcessor method process.
@Override
@WithTimer
public Payload process(Chain chain, Payload payload) {
ExclusiveMode exclusive = PayloadUtils.getExclusive(payload);
if (exclusive == null) {
return chain.process(payload);
}
UUID projectId = payload.getHeader(Payload.PROJECT_ID);
if (projectId == null) {
return chain.process(payload);
}
ModeProcessor processor = processors.get(exclusive.mode());
if (processor == null) {
return chain.process(payload);
}
logManager.info(payload.getProcessKey(), "Process' exclusive group: {}", exclusive.group());
boolean canContinue = processor.process(payload, exclusive);
if (canContinue) {
return chain.process(payload);
}
return payload;
}
use of com.walmartlabs.concord.server.sdk.metrics.WithTimer 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.sdk.metrics.WithTimer 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.sdk.metrics.WithTimer 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);
}
Aggregations