Repository: nifi Updated Branches: refs/heads/master 603f713a4 -> 824712bff
NIFI-3901: - Addressing response code of POST /provenance/lineage. - Ensuring cluster node details are set accordingly. This closes #1803. Signed-off-by: Aldrin Piri <[email protected]> Project: http://git-wip-us.apache.org/repos/asf/nifi/repo Commit: http://git-wip-us.apache.org/repos/asf/nifi/commit/824712bf Tree: http://git-wip-us.apache.org/repos/asf/nifi/tree/824712bf Diff: http://git-wip-us.apache.org/repos/asf/nifi/diff/824712bf Branch: refs/heads/master Commit: 824712bffe3195ad4fb4a004c6c8f19daeb12170 Parents: 603f713 Author: Matt Gilman <[email protected]> Authored: Mon May 15 16:44:26 2017 -0400 Committer: Aldrin Piri <[email protected]> Committed: Tue May 16 12:36:27 2017 -0400 ---------------------------------------------------------------------- .../nifi/web/api/ProvenanceEventResource.java | 8 ++++++++ .../apache/nifi/web/api/ProvenanceResource.java | 19 +++++++++++++------ 2 files changed, 21 insertions(+), 6 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/nifi/blob/824712bf/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-api/src/main/java/org/apache/nifi/web/api/ProvenanceEventResource.java ---------------------------------------------------------------------- diff --git a/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-api/src/main/java/org/apache/nifi/web/api/ProvenanceEventResource.java b/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-api/src/main/java/org/apache/nifi/web/api/ProvenanceEventResource.java index 8b1ebf5..3da1fce 100644 --- a/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-api/src/main/java/org/apache/nifi/web/api/ProvenanceEventResource.java +++ b/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-api/src/main/java/org/apache/nifi/web/api/ProvenanceEventResource.java @@ -361,6 +361,14 @@ public class ProvenanceEventResource extends ApplicationResource { // submit the provenance replay request final ProvenanceEventDTO event = serviceFacade.submitReplay(replayRequestEntity.getEventId()); + event.setClusterNodeId(replayRequestEntity.getClusterNodeId()); + + // populate the cluster node address + final ClusterCoordinator coordinator = getClusterCoordinator(); + if (coordinator != null) { + final NodeIdentifier nodeId = coordinator.getNodeIdentifier(replayRequestEntity.getClusterNodeId()); + event.setClusterNodeAddress(nodeId.getApiAddress() + ":" + nodeId.getApiPort()); + } // create a response entity final ProvenanceEventEntity entity = new ProvenanceEventEntity(); http://git-wip-us.apache.org/repos/asf/nifi/blob/824712bf/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-api/src/main/java/org/apache/nifi/web/api/ProvenanceResource.java ---------------------------------------------------------------------- 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 30c1896..10663be 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 @@ -38,6 +38,7 @@ import org.apache.nifi.web.api.dto.provenance.ProvenanceDTO; import org.apache.nifi.web.api.dto.provenance.ProvenanceOptionsDTO; import org.apache.nifi.web.api.dto.provenance.lineage.LineageDTO; import org.apache.nifi.web.api.dto.provenance.lineage.LineageRequestDTO; +import org.apache.nifi.web.api.dto.provenance.lineage.LineageResultsDTO; import org.apache.nifi.web.api.entity.ComponentEntity; import org.apache.nifi.web.api.entity.LineageEntity; import org.apache.nifi.web.api.entity.ProvenanceEntity; @@ -86,8 +87,16 @@ public class ProvenanceResource extends ApplicationResource { /** * Populates the uri for the specified lineage. */ - private LineageDTO populateRemainingLineageContent(LineageDTO lineage) { + private LineageDTO populateRemainingLineageContent(LineageDTO lineage, String clusterNodeId) { lineage.setUri(generateResourceUri("provenance", "lineage", lineage.getId())); + + // set the cluster node id + lineage.getRequest().setClusterNodeId(clusterNodeId); + final LineageResultsDTO results = lineage.getResults(); + if (results != null && results.getNodes() != null) { + results.getNodes().forEach(node -> node.setClusterNodeIdentifier(clusterNodeId)); + } + return lineage; } @@ -504,15 +513,14 @@ public class ProvenanceResource extends ApplicationResource { // get the provenance event final LineageDTO dto = serviceFacade.submitLineage(lineageDTO); - dto.getRequest().setClusterNodeId(lineageDTO.getRequest().getClusterNodeId()); - populateRemainingLineageContent(dto); + populateRemainingLineageContent(dto, lineageDTO.getRequest().getClusterNodeId()); // create a response entity final LineageEntity entity = new LineageEntity(); entity.setLineage(dto); // generate the response - return clusterContext(generateOkResponse(entity)).build(); + return clusterContext(generateCreatedResponse(URI.create(dto.getUri()), entity)).build(); } ); } @@ -566,8 +574,7 @@ public class ProvenanceResource extends ApplicationResource { // get the lineage final LineageDTO dto = serviceFacade.getLineage(id); - dto.getRequest().setClusterNodeId(clusterNodeId); - populateRemainingLineageContent(dto); + populateRemainingLineageContent(dto, clusterNodeId); // create the response entity final LineageEntity entity = new LineageEntity();
