public EventInformation build(long timestamp, String componentName, String streamId, Set<String> targetComponents, StreamlineEvent event) { String sourceComponentName = EventCorrelationInjector.getSourceComponentName(event); if (!componentName.equals(sourceComponentName)) { throw new IllegalStateException("component name in event correlation is different from provided component name"); } return new EventInformation(timestamp, componentName, streamId, targetComponents, event.getId(), EventCorrelationInjector.getRootIds(event), EventCorrelationInjector.getParentIds(event), event); } }
private void processAndEmit(StreamlineEvent event, Map<String, Tuple> curGroup) throws ProcessingException { List<Result> results = ruleProcessorRuntime.process(eventWithWindowId(event)); for (Result result : results) { for (StreamlineEvent e : result.events) { // TODO: updateHeaders can be handled at ruleProcessorRuntime.process stage passing context info. // anchor parent events if such information is available if (EventCorrelationInjector.containsParentIds(e)) { Set<String> parentIds = EventCorrelationInjector.getParentIds(e); List<Tuple> parents = parentIds.stream().map(pid -> { if (!curGroup.containsKey(pid)) { throw new IllegalStateException("parents should be in grouped tuples"); } return curGroup.get(pid); }).collect(Collectors.toList()); collector.emit(result.stream, parents, new Values(updateHeaders(e, parents))); } else { // put all events in current group if there's no information collector.emit(result.stream, curGroup.values(), new Values(updateHeaders(e, curGroup.values()))); } } } }
parentIds = EventCorrelationInjector.getParentIds(slEvent); } else { parentIds = Collections.emptySet();