Search in sources :

Example 1 with StandardAnalysisContext

use of org.apache.nifi.atlas.provenance.StandardAnalysisContext in project nifi by apache.

the class ReportLineageToAtlas method consumeNiFiProvenanceEvents.

private void consumeNiFiProvenanceEvents(ReportingContext context, NiFiFlow nifiFlow) {
    final EventAccess eventAccess = context.getEventAccess();
    final AnalysisContext analysisContext = new StandardAnalysisContext(nifiFlow, clusterResolvers, // FIXME: This class cast shouldn't be necessary to query lineage. Possible refactor target in next major update.
    (ProvenanceRepository) eventAccess.getProvenanceRepository());
    consumer.consumeEvents(context, (componentMapHolder, events) -> {
        for (ProvenanceEventRecord event : events) {
            try {
                lineageStrategy.processEvent(analysisContext, nifiFlow, event);
            } catch (Exception e) {
                // If something went wrong, log it and continue with other records.
                getLogger().error("Skipping failed analyzing event {} due to {}.", new Object[] { event, e, e });
            }
        }
        nifiAtlasHook.commitMessages();
    });
}
Also used : EventAccess(org.apache.nifi.reporting.EventAccess) ProvenanceEventRecord(org.apache.nifi.provenance.ProvenanceEventRecord) AnalysisContext(org.apache.nifi.atlas.provenance.AnalysisContext) StandardAnalysisContext(org.apache.nifi.atlas.provenance.StandardAnalysisContext) AtlasServiceException(org.apache.atlas.AtlasServiceException) ProcessException(org.apache.nifi.processor.exception.ProcessException) MalformedURLException(java.net.MalformedURLException) IOException(java.io.IOException) StandardAnalysisContext(org.apache.nifi.atlas.provenance.StandardAnalysisContext)

Aggregations

IOException (java.io.IOException)1 MalformedURLException (java.net.MalformedURLException)1 AtlasServiceException (org.apache.atlas.AtlasServiceException)1 AnalysisContext (org.apache.nifi.atlas.provenance.AnalysisContext)1 StandardAnalysisContext (org.apache.nifi.atlas.provenance.StandardAnalysisContext)1 ProcessException (org.apache.nifi.processor.exception.ProcessException)1 ProvenanceEventRecord (org.apache.nifi.provenance.ProvenanceEventRecord)1 EventAccess (org.apache.nifi.reporting.EventAccess)1