Search in sources :

Example 11 with ProvenanceEventBuilder

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);
}
Also used : Connectable(org.apache.nifi.connectable.Connectable) ProvenanceEventBuilder(org.apache.nifi.provenance.ProvenanceEventBuilder)

Example 12 with ProvenanceEventBuilder

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();
}
Also used : FlowFile(org.apache.nifi.flowfile.FlowFile) ProvenanceEventBuilder(org.apache.nifi.provenance.ProvenanceEventBuilder)

Example 13 with ProvenanceEventBuilder

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);
        }
    }
}
Also used : FlowFileHandlingException(org.apache.nifi.processor.exception.FlowFileHandlingException) ProvenanceEventBuilder(org.apache.nifi.provenance.ProvenanceEventBuilder)

Example 14 with ProvenanceEventBuilder

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();
}
Also used : ContentClaim(org.apache.nifi.controller.repository.claim.ContentClaim) ResourceClaim(org.apache.nifi.controller.repository.claim.ResourceClaim) ProvenanceEventBuilder(org.apache.nifi.provenance.ProvenanceEventBuilder)

Example 15 with ProvenanceEventBuilder

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);
        }
    }
}
Also used : FlowFileHandlingException(org.apache.nifi.processor.exception.FlowFileHandlingException) ProvenanceEventBuilder(org.apache.nifi.provenance.ProvenanceEventBuilder)

Aggregations

ProvenanceEventBuilder (org.apache.nifi.provenance.ProvenanceEventBuilder)17 FlowFileHandlingException (org.apache.nifi.processor.exception.FlowFileHandlingException)9 FlowFile (org.apache.nifi.flowfile.FlowFile)8 ProvenanceEventRecord (org.apache.nifi.provenance.ProvenanceEventRecord)4 HashMap (java.util.HashMap)3 ContentClaim (org.apache.nifi.controller.repository.claim.ContentClaim)3 StandardProvenanceEventRecord (org.apache.nifi.provenance.StandardProvenanceEventRecord)3 HashSet (java.util.HashSet)2 Iterator (java.util.Iterator)2 LinkedHashSet (java.util.LinkedHashSet)2 Map (java.util.Map)2 NoSuchElementException (java.util.NoSuchElementException)2 Set (java.util.Set)2 ConcurrentHashMap (java.util.concurrent.ConcurrentHashMap)2 Connectable (org.apache.nifi.connectable.Connectable)2 ProvenanceEventRepository (org.apache.nifi.provenance.ProvenanceEventRepository)2 ProvenanceEventType (org.apache.nifi.provenance.ProvenanceEventType)2 BufferedOutputStream (java.io.BufferedOutputStream)1 ByteArrayInputStream (java.io.ByteArrayInputStream)1 Closeable (java.io.Closeable)1