Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

NIFI-14215 - nifi-client - retrieve input/output content via provenance data #9676

Merged
merged 1 commit into from
Feb 8, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@
import org.apache.nifi.web.api.entity.ReplayLastEventResponseEntity;

import java.io.IOException;
import java.io.InputStream;

public interface ProvenanceClient {
ProvenanceEntity submitProvenanceQuery(ProvenanceEntity provenanceQuery) throws NiFiClientException, IOException;
Expand All @@ -40,6 +41,10 @@ public interface ProvenanceClient {

LatestProvenanceEventsEntity getLatestEvents(String processorId) throws NiFiClientException, IOException;

InputStream getInputFlowFileContent(String provenanceEventId, String nodeId) throws NiFiClientException, IOException;

InputStream getOutputFlowFileContent(String provenanceEventId, String nodeId) throws NiFiClientException, IOException;

enum ReplayEventNodes {
PRIMARY,
ALL;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@
import org.apache.nifi.web.api.entity.ReplayLastEventResponseEntity;

import java.io.IOException;
import java.io.InputStream;
import java.util.Objects;

public class JerseyProvenanceClient extends AbstractJerseyClient implements ProvenanceClient {
Expand Down Expand Up @@ -149,4 +150,42 @@ public LatestProvenanceEventsEntity getLatestEvents(final String processorId) th
return getRequestBuilder(target).get(LatestProvenanceEventsEntity.class);
});
}

@Override
public InputStream getInputFlowFileContent(final String provenanceEventId, final String nodeId) throws NiFiClientException, IOException {
if (StringUtils.isBlank(provenanceEventId)) {
throw new IllegalArgumentException("Provenance Event ID must be specified");
}

return executeAction("Error retrieving Input FlowFile Content from provenance event", () -> {
WebTarget target = provenanceEventsTarget
.path("/{id}/content/input")
.resolveTemplate("id", provenanceEventId);

if (nodeId != null) {
target = target.queryParam("clusterNodeId", nodeId);
}

return getRequestBuilder(target).get(InputStream.class);
});
}

@Override
public InputStream getOutputFlowFileContent(String provenanceEventId, final String nodeId) throws NiFiClientException, IOException {
if (StringUtils.isBlank(provenanceEventId)) {
throw new IllegalArgumentException("Provenance Event ID must be specified");
}

return executeAction("Error retrieving Output FlowFile Content from provenance event", () -> {
WebTarget target = provenanceEventsTarget
.path("/{id}/content/output")
.resolveTemplate("id", provenanceEventId);

if (nodeId != null) {
target = target.queryParam("clusterNodeId", nodeId);
}

return getRequestBuilder(target).get(InputStream.class);
});
}
}