use of org.graylog.events.processor.EventProcessor in project graylog2-server by Graylog2.
the class EventBacklogService method getMessagesForEvent.
public ImmutableList<MessageSummary> getMessagesForEvent(EventDto eventDto, long backlogSize) throws NotFoundException {
if (backlogSize <= 0) {
return ImmutableList.of();
}
final EventProcessor.Factory factory = eventProcessorFactories.get(eventDto.eventDefinitionType());
if (factory == null) {
throw new NotFoundException("Couldn't find event processor factory for type " + eventDto.eventDefinitionType());
}
final EventDefinition eventDefinition = eventDefinitionService.get(eventDto.eventDefinitionId()).orElseThrow(() -> new NotFoundException("Could not find event definintion <" + eventDto.eventDefinitionId() + ">"));
final EventProcessor eventProcessor = factory.create(eventDefinition);
final ImmutableList.Builder<MessageSummary> backlogBuilder = ImmutableList.builder();
try {
eventProcessor.sourceMessagesForEvent(Event.fromDto(eventDto), backlogBuilder::addAll, backlogSize);
} catch (EventProcessorException e) {
// TODO return this error, so it can be included in the notification message?
LOG.error("Failed to query backlog messages for Event {}", eventDto.id(), e);
}
return backlogBuilder.build();
}
Aggregations