Search in sources :

Example 16 with ProvenanceEventBuilder

use of org.apache.nifi.provenance.ProvenanceEventBuilder in project nifi by apache.

the class MockProvenanceReporter method join.

@Override
public void join(final Collection<FlowFile> parents, final FlowFile child, final String details, final long joinDuration) {
    verifyFlowFileKnown(child);
    try {
        final ProvenanceEventBuilder eventBuilder = build(child, ProvenanceEventType.JOIN);
        eventBuilder.addChildFlowFile(child);
        eventBuilder.setDetails(details);
        for (final FlowFile parent : parents) {
            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 : FlowFile(org.apache.nifi.flowfile.FlowFile) FlowFileHandlingException(org.apache.nifi.processor.exception.FlowFileHandlingException) ProvenanceEventBuilder(org.apache.nifi.provenance.ProvenanceEventBuilder)

Example 17 with ProvenanceEventBuilder

use of org.apache.nifi.provenance.ProvenanceEventBuilder in project nifi by apache.

the class MockProvenanceReporter 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)

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