use of com.walmartlabs.concord.server.sdk.metrics.WithTimer in project concord by walmartlabs.
the class OneOpsEventResource method event.
@POST
@Path("/oneops")
@Consumes(MediaType.APPLICATION_JSON)
@WithTimer
public Response event(Map<String, Object> event) {
if (executor.isDisabled(EVENT_SOURCE)) {
log.warn("event ['{}'] disabled", EVENT_SOURCE);
return Response.ok().build();
}
if (event == null || event.isEmpty()) {
return Response.status(Status.BAD_REQUEST).build();
}
if (cfg.isLogEvents()) {
auditLog.add(AuditObject.EXTERNAL_EVENT, AuditAction.ACCESS).field("source", EVENT_SOURCE).field("eventId", String.valueOf(event.get("cmsId"))).field("payload", event).log();
}
List<OneOpsTriggerProcessor.Result> results = new ArrayList<>();
processors.forEach(p -> p.process(event, results));
for (OneOpsTriggerProcessor.Result result : results) {
Event e = Event.builder().id(String.valueOf(event.get("cmsId"))).name(EVENT_SOURCE).attributes(result.event()).initiator(memo(new EventInitiatorSupplier("author", userManager, result.event()))).build();
List<PartialProcessKey> processKeys = executor.execute(e, initiatorResolver, result.triggers());
log.info("event ['{}'] -> done, {} processes started", e.id(), processKeys.size());
}
return Response.ok().build();
}
use of com.walmartlabs.concord.server.sdk.metrics.WithTimer in project concord by walmartlabs.
the class EventMarkerDao method get.
@WithTimer
public EventMarker get(String processorName) {
EventProcessorMarker m = Tables.EVENT_PROCESSOR_MARKER.as("m");
Long currentEventSeq = txResult(tx -> tx.select(m.EVENT_SEQ).from(m).where(m.PROCESSOR_NAME.eq(processorName)).fetchOne(m.EVENT_SEQ));
Long maxEventSeq = txResult(tx -> tx.select(max(PROCESS_EVENTS.EVENT_SEQ)).from(PROCESS_EVENTS).fetchOne(Record1::value1));
return EventMarker.builder().eventSeq(currentEventSeq != null ? currentEventSeq : -1).maxEventSeq(maxEventSeq != null ? maxEventSeq : -1).build();
}
use of com.walmartlabs.concord.server.sdk.metrics.WithTimer in project concord by walmartlabs.
the class EventMarkerDao method update.
@WithTimer
public void update(DSLContext tx, String processorName, long eventSeq) {
EventProcessorMarker m = Tables.EVENT_PROCESSOR_MARKER.as("m");
tx.insertInto(m).columns(m.PROCESSOR_NAME, m.EVENT_SEQ).values(value(processorName), value(eventSeq)).onDuplicateKeyUpdate().set(m.EVENT_SEQ, eventSeq).where(m.PROCESSOR_NAME.eq(processorName)).execute();
}
use of com.walmartlabs.concord.server.sdk.metrics.WithTimer in project concord by walmartlabs.
the class SsoRealm method doGetAuthenticationInfo.
@Override
@WithTimer
protected AuthenticationInfo doGetAuthenticationInfo(AuthenticationToken token) throws AuthenticationException {
SsoToken t = (SsoToken) token;
if (t.getUsername() == null) {
return null;
}
UserEntry u = userManager.get(t.getUsername(), t.getDomain(), UserType.LDAP).orElse(null);
if (u == null) {
u = userManager.create(t.getUsername(), t.getDomain(), t.getDisplayName(), t.getMail(), UserType.SSO, null);
}
// we consider the account active if the authentication was successful
userManager.enable(u.getId());
auditLog.add(AuditObject.SYSTEM, AuditAction.ACCESS).userId(u.getId()).field("username", u.getName()).field("userDomain", u.getDomain()).field("realm", REALM_NAME).log();
UserPrincipal userPrincipal = new UserPrincipal(REALM_NAME, u);
LdapPrincipal ldapPrincipal = new LdapPrincipal(t.getUsername(), t.getDomain(), t.getNameInNamespace(), t.getUserPrincipalName(), t.getDisplayName(), t.getMail(), t.getGroups(), Collections.singletonMap("mail", t.getMail()));
return new SimpleAccount(Arrays.asList(userPrincipal, t, ldapPrincipal), t.getCredentials(), getName());
}
Aggregations