use of com.walmartlabs.concord.server.sdk.metrics.WithTimer in project concord by walmartlabs.
the class RoleResource method get.
@GET
@ApiOperation("Get a role's details")
@Path("/{roleName}")
@Produces(MediaType.APPLICATION_JSON)
@WithTimer
public RoleEntry get(@ApiParam @PathParam("roleName") String roleName) {
assertAdmin();
UUID id = roleDao.getId(roleName);
if (id == null) {
throw new ConcordApplicationException("Role not found: " + roleName, Status.NOT_FOUND);
}
return roleDao.get(id);
}
use of com.walmartlabs.concord.server.sdk.metrics.WithTimer in project concord by walmartlabs.
the class ProcessStateManager method importPath.
@WithTimer
public void importPath(DSLContext tx, ProcessKey processKey, String path, Path src, BiFunction<Path, BasicFileAttributes, Boolean> filter) {
PolicyEngine policyEngine = assertPolicy(tx, processKey, src, filter);
String prefix = fixPath(path);
List<BatchItem> batch = new ArrayList<>();
try {
Files.walkFileTree(src, new SimpleFileVisitor<Path>() {
@Override
public FileVisitResult visitFile(Path file, BasicFileAttributes attrs) throws IOException {
if (!filter.apply(file, attrs)) {
return FileVisitResult.CONTINUE;
}
Path p = src.relativize(file);
// the caller shouldn't attempt to import anything but regular files
if (!Files.isRegularFile(file, LinkOption.NOFOLLOW_LINKS)) {
throw new IllegalStateException("Can't import non-regular files into the process state: " + p + " This is most likely a bug.");
}
String n = p.toString();
if (prefix != null) {
n = prefix + n;
}
Set<PosixFilePermission> permissions = Files.getPosixFilePermissions(file);
int unixMode = Posix.unixMode(permissions);
boolean needsEncryption = secureFiles.contains(n);
tx.deleteFrom(PROCESS_STATE).where(PROCESS_STATE.INSTANCE_ID.eq(processKey.getInstanceId()).and(PROCESS_STATE.INSTANCE_CREATED_AT.eq(processKey.getCreatedAt())).and(PROCESS_STATE.ITEM_PATH.eq(n))).execute();
batch.add(new BatchItem(n, file, unixMode, needsEncryption));
if (batch.size() >= INSERT_BATCH_SIZE) {
insert(tx, processKey.getInstanceId(), processKey.getCreatedAt(), batch);
batch.clear();
}
return FileVisitResult.CONTINUE;
}
});
if (!batch.isEmpty()) {
insert(tx, processKey.getInstanceId(), processKey.getCreatedAt(), batch);
}
} catch (IOException e) {
throw new RuntimeException(e);
}
assertPolicy(tx, processKey, policyEngine);
}
use of com.walmartlabs.concord.server.sdk.metrics.WithTimer in project concord by walmartlabs.
the class ProcessWaitWatchdog method resumeProcess.
@WithTimer
void resumeProcess(ProcessKey key, Set<String> events) {
Payload payload;
try {
payload = payloadManager.createResumePayload(key, events, null);
} catch (IOException e) {
throw new RuntimeException("Error creating a payload", e);
}
processManager.resume(payload);
log.info("resumeProcess ['{}', '{}'] -> done", key, events);
}
use of com.walmartlabs.concord.server.sdk.metrics.WithTimer in project concord by walmartlabs.
the class ApiKeyRealm method doGetAuthenticationInfo.
@Override
@WithTimer
protected AuthenticationInfo doGetAuthenticationInfo(AuthenticationToken token) throws AuthenticationException {
ApiKey t = (ApiKey) token;
UserEntry u = userManager.get(t.getUserId()).orElse(null);
if (u == null) {
return null;
}
if (u.isDisabled()) {
throw new AuthenticationException("User account '" + u.getName() + "' is disabled");
}
auditLog.add(AuditObject.SYSTEM, AuditAction.ACCESS).userId(u.getId()).field("realm", REALM_NAME).field("apiKeyId", t.getKeyId()).log();
UserPrincipal p = new UserPrincipal(REALM_NAME, u);
return new SimpleAccount(Arrays.asList(p, t), t.getKey(), getName());
}
use of com.walmartlabs.concord.server.sdk.metrics.WithTimer in project concord by walmartlabs.
the class ProcessLogResourceV2 method updateSegment.
/**
* Update a process log segment.
*/
@POST
@ApiOperation(value = "Update process log segment")
@Path("{id}/log/segment/{segmentId}")
@Consumes(MediaType.APPLICATION_JSON)
@Produces(MediaType.APPLICATION_JSON)
@WithTimer
public LogSegmentOperationResponse updateSegment(@ApiParam @PathParam("id") UUID instanceId, @ApiParam @PathParam("segmentId") long segmentId, @ApiParam LogSegmentUpdateRequest request) {
ProcessKey processKey = logAccessManager.assertLogAccess(instanceId);
logManager.updateSegment(processKey, segmentId, request.status(), request.warnings(), request.errors());
return new LogSegmentOperationResponse(segmentId, OperationResult.UPDATED);
}
Aggregations