.flatMap(msg -> ((HookNotification.EntityCreateRequest) msg).getEntities().stream()) .collect(groupingBy(ref -> TYPE_NIFI_FLOW_PATH.equals(ref.typeName))); newEntities.addAll(newFlowPaths); if (!newEntities.isEmpty()) { notifier.accept(Collections.singletonList(new HookNotification.EntityCreateRequest(NIFI_USER, newEntities)));
.flatMap(msg -> ((HookNotification.EntityCreateRequest) msg).getEntities().stream()) .collect(groupingBy(ref -> TYPE_NIFI_FLOW_PATH.equals(ref.typeName))); newEntities.addAll(newFlowPaths); if (!newEntities.isEmpty()) { notifier.accept(Collections.singletonList(new HookNotification.EntityCreateRequest(NIFI_USER, newEntities)));
@SuppressWarnings("unchecked") protected boolean addDataSetRefs(Set<Referenceable> refsToAdd, Referenceable nifiFlowPath, String targetAttribute) { if (refsToAdd != null && !refsToAdd.isEmpty()) { // If nifiFlowPath already has a given dataSetRef, then it needs not to be created. final Function<Referenceable, String> toTypedQualifiedName = ref -> toTypedQualifiedName(ref.getTypeName(), toStr(ref.get(ATTR_QUALIFIED_NAME))); final Collection<Referenceable> refs = Optional.ofNullable((Collection<Referenceable>) nifiFlowPath.get(targetAttribute)).orElseGet(ArrayList::new); final Set<String> existingRefTypedQualifiedNames = refs.stream().map(toTypedQualifiedName).collect(Collectors.toSet()); refsToAdd.stream().filter(ref -> !existingRefTypedQualifiedNames.contains(toTypedQualifiedName.apply(ref))) .forEach(ref -> { if (ref.getId().isUnassigned()) { // Create new entity. logger.debug("Found a new DataSet reference from {} to {}, sending an EntityCreateRequest", new Object[]{toTypedQualifiedName.apply(nifiFlowPath), toTypedQualifiedName.apply(ref)}); final HookNotification.EntityCreateRequest createDataSet = new HookNotification.EntityCreateRequest(NIFI_USER, ref); lineageContext.addMessage(createDataSet); } refs.add(ref); }); if (refs.size() > existingRefTypedQualifiedNames.size()) { // Something has been added. nifiFlowPath.set(targetAttribute, refs); return true; } } return false; }
private void fireAndForget(FalconEvent event) throws FalconException, URISyntaxException { LOG.info("Entered Atlas hook for Falcon hook operation {}", event.getOperation()); List<HookNotification> messages = new ArrayList<>(); Operation op = getOperation(event.getOperation()); String user = getUser(event.getUser()); LOG.info("fireAndForget user:{}", user); switch (op) { case ADD: messages.add(new EntityCreateRequest(user, createEntities(event, user))); break; } notifyEntities(messages, null); }
protected void createEntity(Referenceable ... entities) { final HookNotification.EntityCreateRequest msg = new HookNotification.EntityCreateRequest(NIFI_USER, entities); lineageContext.addMessage(msg); }
@SuppressWarnings("unchecked") protected boolean addDataSetRefs(Set<Referenceable> refsToAdd, Referenceable nifiFlowPath, String targetAttribute) { if (refsToAdd != null && !refsToAdd.isEmpty()) { // If nifiFlowPath already has a given dataSetRef, then it needs not to be created. final Function<Referenceable, String> toTypedQualifiedName = ref -> toTypedQualifiedName(ref.getTypeName(), toStr(ref.get(ATTR_QUALIFIED_NAME))); final Collection<Referenceable> refs = Optional.ofNullable((Collection<Referenceable>) nifiFlowPath.get(targetAttribute)).orElseGet(ArrayList::new); final Set<String> existingRefTypedQualifiedNames = refs.stream().map(toTypedQualifiedName).collect(Collectors.toSet()); refsToAdd.stream().filter(ref -> !existingRefTypedQualifiedNames.contains(toTypedQualifiedName.apply(ref))) .forEach(ref -> { if (ref.getId().isUnassigned()) { // Create new entity. logger.debug("Found a new DataSet reference from {} to {}, sending an EntityCreateRequest", new Object[]{toTypedQualifiedName.apply(nifiFlowPath), toTypedQualifiedName.apply(ref)}); final HookNotification.EntityCreateRequest createDataSet = new HookNotification.EntityCreateRequest(NIFI_USER, ref); lineageContext.addMessage(createDataSet); } refs.add(ref); }); if (refs.size() > existingRefTypedQualifiedNames.size()) { // Something has been added. nifiFlowPath.set(targetAttribute, refs); return true; } } return false; }
protected void createEntity(Referenceable ... entities) { final HookNotification.EntityCreateRequest msg = new HookNotification.EntityCreateRequest(NIFI_USER, entities); lineageContext.addMessage(msg); }