use of org.apache.nifi.provenance.ProvenanceEventBuilder in project nifi by apache.
the class StandardProcessSession method registerForkEvent.
private void registerForkEvent(final FlowFile parent, final FlowFile child) {
ProvenanceEventBuilder eventBuilder = forkEventBuilders.get(parent);
if (eventBuilder == null) {
eventBuilder = context.getProvenanceRepository().eventBuilder();
eventBuilder.setEventType(ProvenanceEventType.FORK);
eventBuilder.setFlowFileEntryDate(parent.getEntryDate());
eventBuilder.setLineageStartDate(parent.getLineageStartDate());
eventBuilder.setFlowFileUUID(parent.getAttribute(CoreAttributes.UUID.key()));
eventBuilder.setComponentId(context.getConnectable().getIdentifier());
final Connectable connectable = context.getConnectable();
final String processorType = connectable.getComponentType();
eventBuilder.setComponentType(processorType);
eventBuilder.addParentFlowFile(parent);
updateEventContentClaims(eventBuilder, parent, records.get(parent));
forkEventBuilders.put(parent, eventBuilder);
}
eventBuilder.addChildFlowFile(child);
}
use of org.apache.nifi.provenance.ProvenanceEventBuilder in project nifi by apache.
the class StandardProvenanceReporter method generateJoinEvent.
/**
* Generates a Fork event for the given child and parents but does not register the event. This is useful so that a ProcessSession has the ability to de-dupe events, since one or more events may
* be created by the session itself, as well as by the Processor
*
* @param parents parents
* @param child child
* @return record
*/
ProvenanceEventRecord generateJoinEvent(final Collection<FlowFile> parents, final FlowFile child) {
final ProvenanceEventBuilder eventBuilder = build(child, ProvenanceEventType.JOIN);
eventBuilder.addChildFlowFile(child);
for (final FlowFile parent : parents) {
eventBuilder.addParentFlowFile(parent);
}
return eventBuilder.build();
}
use of org.apache.nifi.provenance.ProvenanceEventBuilder in project nifi by apache.
the class StandardProvenanceReporter method clone.
void clone(final FlowFile parent, final FlowFile child, final boolean verifyFlowFile) {
if (verifyFlowFile) {
verifyFlowFileKnown(child);
}
try {
final ProvenanceEventBuilder eventBuilder = build(parent, ProvenanceEventType.CLONE);
eventBuilder.addChildFlowFile(child);
eventBuilder.addParentFlowFile(parent);
events.add(eventBuilder.build());
} catch (final Exception e) {
logger.error("Failed to generate Provenance Event due to " + e);
if (logger.isDebugEnabled()) {
logger.error("", e);
}
}
}
use of org.apache.nifi.provenance.ProvenanceEventBuilder in project nifi by apache.
the class StandardFlowFileQueue method createDropEvent.
private ProvenanceEventRecord createDropEvent(final FlowFileRecord flowFile, final String requestor) {
final ProvenanceEventBuilder builder = provRepository.eventBuilder();
builder.fromFlowFile(flowFile);
builder.setEventType(ProvenanceEventType.DROP);
builder.setLineageStartDate(flowFile.getLineageStartDate());
builder.setComponentId(getIdentifier());
builder.setComponentType("Connection");
builder.setAttributes(flowFile.getAttributes(), Collections.<String, String>emptyMap());
builder.setDetails("FlowFile Queue emptied by " + requestor);
builder.setSourceQueueIdentifier(getIdentifier());
final ContentClaim contentClaim = flowFile.getContentClaim();
if (contentClaim != null) {
final ResourceClaim resourceClaim = contentClaim.getResourceClaim();
builder.setPreviousContentClaim(resourceClaim.getContainer(), resourceClaim.getSection(), resourceClaim.getId(), contentClaim.getOffset(), flowFile.getSize());
}
return builder.build();
}
use of org.apache.nifi.provenance.ProvenanceEventBuilder in project nifi by apache.
the class MockProvenanceReporter method clone.
@Override
public void clone(final FlowFile parent, final FlowFile child) {
verifyFlowFileKnown(child);
try {
final ProvenanceEventBuilder eventBuilder = build(parent, ProvenanceEventType.CLONE);
eventBuilder.addChildFlowFile(child);
eventBuilder.addParentFlowFile(parent);
events.add(eventBuilder.build());
} catch (final Exception e) {
logger.error("Failed to generate Provenance Event due to " + e);
if (logger.isDebugEnabled()) {
logger.error("", e);
}
}
}
Aggregations