use of com.sequenceiq.cloudbreak.structuredevent.event.StructuredEventType in project cloudbreak by hortonworks.
the class CDPStructuredEventDBService method getPagedEventsOfResources.
@Override
public <T extends CDPStructuredEvent> Page<T> getPagedEventsOfResources(List<StructuredEventType> eventTypes, List<String> resourceCrns, Pageable pageable) {
LOGGER.debug("Gathering pageable events for types: '{}' and resource CRNs: '{}'", eventTypes, resourceCrns);
List<StructuredEventType> types = getAllEventTypeIfEmpty(eventTypes);
try {
Page<CDPStructuredEventEntity> events = pagingStructuredEventRepository.findByEventTypeInAndResourceCrnIn(types, resourceCrns, pageable);
return (Page<T>) Optional.ofNullable(events).orElse(Page.empty()).map(event -> cdpStructuredEventEntityToCDPStructuredEventConverter.convert(event));
} catch (Exception ex) {
String msg = String.format("Failed get pageable events for types: '%s' and resource CRNs: '%s'", types, resourceCrns);
LOGGER.warn(msg, ex);
throw new CloudbreakServiceException(msg, ex);
}
}
use of com.sequenceiq.cloudbreak.structuredevent.event.StructuredEventType in project cloudbreak by hortonworks.
the class CDPAsyncAuditStructuredEventSender method create.
@Override
public void create(CDPStructuredEvent structuredEvent) {
StructuredEventType eventType = structuredEvent.getOperation().getEventType();
CDPEventDataExtractor<? extends CDPStructuredEvent> eventDataExtractor = eventDataExtractorMap.get(eventType.name().toLowerCase() + "CDPEventDataExtractor");
if (eventDataExtractor == null) {
LOGGER.debug("Event data converter does not exist for event type of {}", eventType);
return;
}
boolean shouldAudit = eventDataExtractor.shouldAudit(structuredEvent);
if (shouldAudit) {
sendAsyncEvent(AUDIT_EVENT_LOG_MESSAGE, eventFactory.createEvent(structuredEvent));
LOGGER.debug("Audit Event is fired for this structured event: {}", structuredEvent);
} else {
LOGGER.debug("Audit Event is disabled for this structured event: {}", structuredEvent);
}
}
use of com.sequenceiq.cloudbreak.structuredevent.event.StructuredEventType in project cloudbreak by hortonworks.
the class CDPStructuredEventDBService method getEventsOfResource.
@Override
public <T extends CDPStructuredEvent> List<T> getEventsOfResource(List<StructuredEventType> eventTypes, String resourceCrn) {
LOGGER.debug("Gathering events for type: '{}' and resource CRN: '{}'", eventTypes, resourceCrn);
List<StructuredEventType> types = getAllEventTypeIfEmpty(eventTypes);
try {
List<CDPStructuredEventEntity> events = structuredEventRepository.findByEventTypeInAndResourceCrn(types, resourceCrn);
return (List<T>) Optional.ofNullable(events).orElse(new ArrayList<>()).stream().map(event -> cdpStructuredEventEntityToCDPStructuredEventConverter.convert(event)).collect(Collectors.toList());
} catch (Exception ex) {
String msg = String.format("Failed get events for types: '%s' and resource CRN: '%s'", types, resourceCrn);
LOGGER.warn(msg, ex);
throw new CloudbreakServiceException(msg, ex);
}
}
use of com.sequenceiq.cloudbreak.structuredevent.event.StructuredEventType in project cloudbreak by hortonworks.
the class CDPStructuredEventDBService method getEventsOfResources.
@Override
public <T extends CDPStructuredEvent> List<T> getEventsOfResources(List<StructuredEventType> eventTypes, List<String> resourceCrns) {
LOGGER.debug("Gathering events for type: '{}' and resource CRN's: '{}'", eventTypes, resourceCrns);
List<StructuredEventType> types = getAllEventTypeIfEmpty(eventTypes);
try {
List<CDPStructuredEventEntity> events = structuredEventRepository.findByEventTypeInAndResourceCrnIn(types, resourceCrns);
return (List<T>) Optional.ofNullable(events).orElse(new ArrayList<>()).stream().map(event -> cdpStructuredEventEntityToCDPStructuredEventConverter.convert(event)).collect(Collectors.toList());
} catch (Exception ex) {
String msg = String.format("Failed get events for types: '%s' and resource CRNs: '%s'", types, resourceCrns);
LOGGER.warn(msg, ex);
throw new CloudbreakServiceException(msg, ex);
}
}
use of com.sequenceiq.cloudbreak.structuredevent.event.StructuredEventType in project cloudbreak by hortonworks.
the class CDPStructuredEventDBService method getPagedEventsOfResource.
@Override
public <T extends CDPStructuredEvent> Page<T> getPagedEventsOfResource(List<StructuredEventType> eventTypes, String resourceCrn, Pageable pageable) {
LOGGER.debug("Gathering pageable events for types: '{}' and resource CRN: '{}'", eventTypes, resourceCrn);
List<StructuredEventType> types = getAllEventTypeIfEmpty(eventTypes);
try {
Page<CDPStructuredEventEntity> events = pagingStructuredEventRepository.findByEventTypeInAndResourceCrn(types, resourceCrn, pageable);
return (Page<T>) Optional.ofNullable(events).orElse(Page.empty()).map(event -> cdpStructuredEventEntityToCDPStructuredEventConverter.convert(event));
} catch (Exception ex) {
String msg = String.format("Failed get pageable events for types: '%s' and resource CRN: '%s'", types, resourceCrn);
LOGGER.warn(msg, ex);
throw new CloudbreakServiceException(msg, ex);
}
}
Aggregations