diff --git a/nifi-framework-api/src/main/java/org/apache/nifi/provenance/lineage/ComputeLineageSubmission.java b/nifi-framework-api/src/main/java/org/apache/nifi/provenance/lineage/ComputeLineageSubmission.java index 8a1152359e..773f9ae700 100644 --- a/nifi-framework-api/src/main/java/org/apache/nifi/provenance/lineage/ComputeLineageSubmission.java +++ b/nifi-framework-api/src/main/java/org/apache/nifi/provenance/lineage/ComputeLineageSubmission.java @@ -60,10 +60,19 @@ public interface ComputeLineageSubmission { LineageComputationType getLineageComputationType(); /** - * @return If the Lineage Computation Type of this submission is + * If the Lineage Computation Type of this submission is * {@link LineageComputationType.EXPAND_CHILDREN} or - * {@link LineageComputationType.EXPAND_PARENTS}, indicates the ID event - * that is to be expanded; otherwise, returns null + * {@link LineageComputationType.EXPAND_PARENTS}, indicates + * the event ID that is to be expanded. + * + * If the Lineage Computation Type of this submission is + * {@link LineageComputationType.FLOWFILE_LINEAGE} and the + * original submission was based off an event id, indicates + * that event ID. + * + * Otherwise returns null. + * + * @return the event id if applicable */ Long getExpandedEventId(); diff --git a/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-client-dto/src/main/java/org/apache/nifi/web/api/dto/provenance/lineage/LineageRequestDTO.java b/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-client-dto/src/main/java/org/apache/nifi/web/api/dto/provenance/lineage/LineageRequestDTO.java index 5a59a7c180..5473efd34d 100644 --- a/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-client-dto/src/main/java/org/apache/nifi/web/api/dto/provenance/lineage/LineageRequestDTO.java +++ b/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-client-dto/src/main/java/org/apache/nifi/web/api/dto/provenance/lineage/LineageRequestDTO.java @@ -47,7 +47,8 @@ public class LineageRequestDTO { * @return event id that was used to generate this lineage */ @ApiModelProperty( - value = "" + value = "The event id that was used to generate this lineage, if applicable. The event id is allowed for any type of lineageRequestType. If the lineageRequestType is FLOWFILE and the " + + "flowfile uuid is also included in the request, the event id will be ignored." ) public Long getEventId() { return eventId; @@ -90,7 +91,7 @@ public class LineageRequestDTO { * @return uuid that was used to generate this lineage */ @ApiModelProperty( - value = "The uuid that was used to generate the lineage." + value = "The flowfile uuid that was used to generate the lineage. The flowfile uuid is only allowed when the lineageRequestType is FLOWFILE and will take precedence over event id." ) public String getUuid() { return uuid; diff --git a/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-api/src/main/java/org/apache/nifi/web/api/ProvenanceResource.java b/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-api/src/main/java/org/apache/nifi/web/api/ProvenanceResource.java index e5b6cc2615..c17ad8512e 100644 --- a/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-api/src/main/java/org/apache/nifi/web/api/ProvenanceResource.java +++ b/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-api/src/main/java/org/apache/nifi/web/api/ProvenanceResource.java @@ -485,7 +485,7 @@ public class ProvenanceResource extends ApplicationResource { } break; case FLOWFILE: - // ensure the uuid has been specified + // ensure the uuid or event id has been specified if (requestDto.getUuid() == null && requestDto.getEventId() == null) { throw new IllegalArgumentException("The flowfile uuid or event id must be specified when the event type is FLOWFILE."); } diff --git a/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-api/src/main/java/org/apache/nifi/web/api/dto/DtoFactory.java b/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-api/src/main/java/org/apache/nifi/web/api/dto/DtoFactory.java index 4b59de9a15..74123b0db0 100644 --- a/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-api/src/main/java/org/apache/nifi/web/api/dto/DtoFactory.java +++ b/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-api/src/main/java/org/apache/nifi/web/api/dto/DtoFactory.java @@ -2432,6 +2432,7 @@ public final class DtoFactory { if (uuids.size() == 1) { requestDto.setUuid(uuids.iterator().next()); } + requestDto.setEventId(computeLineageSubmission.getExpandedEventId()); requestDto.setLineageRequestType(LineageRequestType.FLOWFILE); break; } diff --git a/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-api/src/main/java/org/apache/nifi/web/controller/ControllerFacade.java b/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-api/src/main/java/org/apache/nifi/web/controller/ControllerFacade.java index 527a994a61..420022ff4d 100644 --- a/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-api/src/main/java/org/apache/nifi/web/controller/ControllerFacade.java +++ b/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-api/src/main/java/org/apache/nifi/web/controller/ControllerFacade.java @@ -1105,12 +1105,12 @@ public class ControllerFacade implements Authorizable { final ProvenanceRepository provenanceRepository = flowController.getProvenanceRepository(); final ComputeLineageSubmission result; - // submit the event if (LineageRequestType.FLOWFILE.equals(requestDto.getLineageRequestType())) { - // submit uuid - if (requestDto.getEventId() == null) { + if (requestDto.getUuid() != null) { + // submit uuid if it is specified result = provenanceRepository.submitLineageComputation(requestDto.getUuid(), NiFiUserUtils.getNiFiUser()); } else { + // submit the event if the flowfile uuid needs to be looked up result = provenanceRepository.submitLineageComputation(requestDto.getEventId(), NiFiUserUtils.getNiFiUser()); } } else { diff --git a/nifi-nar-bundles/nifi-provenance-repository-bundle/nifi-volatile-provenance-repository/src/main/java/org/apache/nifi/provenance/VolatileProvenanceRepository.java b/nifi-nar-bundles/nifi-provenance-repository-bundle/nifi-volatile-provenance-repository/src/main/java/org/apache/nifi/provenance/VolatileProvenanceRepository.java index c3fbf426ea..c8511befde 100644 --- a/nifi-nar-bundles/nifi-provenance-repository-bundle/nifi-volatile-provenance-repository/src/main/java/org/apache/nifi/provenance/VolatileProvenanceRepository.java +++ b/nifi-nar-bundles/nifi-provenance-repository-bundle/nifi-volatile-provenance-repository/src/main/java/org/apache/nifi/provenance/VolatileProvenanceRepository.java @@ -16,25 +16,6 @@ */ package org.apache.nifi.provenance; -import java.io.IOException; -import java.util.ArrayList; -import java.util.Collection; -import java.util.Collections; -import java.util.Date; -import java.util.Iterator; -import java.util.List; -import java.util.Map; -import java.util.concurrent.ConcurrentHashMap; -import java.util.concurrent.ConcurrentMap; -import java.util.concurrent.ExecutorService; -import java.util.concurrent.Executors; -import java.util.concurrent.ScheduledExecutorService; -import java.util.concurrent.ThreadFactory; -import java.util.concurrent.TimeUnit; -import java.util.concurrent.atomic.AtomicBoolean; -import java.util.concurrent.atomic.AtomicInteger; -import java.util.concurrent.atomic.AtomicLong; -import java.util.regex.Pattern; import org.apache.nifi.authorization.AccessDeniedException; import org.apache.nifi.authorization.AuthorizationResult; import org.apache.nifi.authorization.AuthorizationResult.Result; @@ -61,6 +42,26 @@ import org.apache.nifi.util.RingBuffer.ForEachEvaluator; import org.apache.nifi.util.RingBuffer.IterationDirection; import org.apache.nifi.web.ResourceNotFoundException; +import java.io.IOException; +import java.util.ArrayList; +import java.util.Collection; +import java.util.Collections; +import java.util.Date; +import java.util.Iterator; +import java.util.List; +import java.util.Map; +import java.util.concurrent.ConcurrentHashMap; +import java.util.concurrent.ConcurrentMap; +import java.util.concurrent.ExecutorService; +import java.util.concurrent.Executors; +import java.util.concurrent.ScheduledExecutorService; +import java.util.concurrent.ThreadFactory; +import java.util.concurrent.TimeUnit; +import java.util.concurrent.atomic.AtomicBoolean; +import java.util.concurrent.atomic.AtomicInteger; +import java.util.concurrent.atomic.AtomicLong; +import java.util.regex.Pattern; + public class VolatileProvenanceRepository implements ProvenanceRepository { // properties @@ -502,7 +503,7 @@ public class VolatileProvenanceRepository implements ProvenanceRepository { return result; } - return submitLineageComputation(event.getFlowFileUuid(), user); + return submitLineageComputation(Collections.singleton(event.getFlowFileUuid()), user, LineageComputationType.FLOWFILE_LINEAGE, eventId); } @Override