[ 
https://issues.apache.org/jira/browse/MINIFI-408?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=16251878#comment-16251878
 ] 

ASF GitHub Bot commented on MINIFI-408:
---------------------------------------

Github user apiri commented on a diff in the pull request:

    https://github.com/apache/nifi-minifi/pull/99#discussion_r150919043
  
    --- Diff: 
minifi-nar-bundles/minifi-framework-bundle/minifi-framework/minifi-runtime/src/main/java/org/apache/nifi/minifi/MiNiFi.java
 ---
    @@ -241,4 +268,203 @@ public static void main(String[] args) {
                 logger.error("Failure to launch MiNiFi due to " + t, t);
             }
         }
    +
    +    /* Handle Flow bundle enrichment */
    +    protected static void enrichFlowWithBundleInformation(FlowParser 
flowParser, NiFiProperties niFiProperties) throws FlowEnrichmentException {
    +        final Path flowPath = 
niFiProperties.getFlowConfigurationFile().toPath();
    +        logger.debug("Enriching generated {} with bundling information", 
flowPath.toAbsolutePath());
    +
    +        try {
    +            final Document flowDocument = 
flowParser.parse(flowPath.toAbsolutePath().toFile());
    +
    +            if (flowDocument == null) {
    +                throw new FlowEnrichmentException("Unable to successfully 
parse the specified flow at " + flowPath.toAbsolutePath());
    +            }
    +
    +            final Map<String, EnrichingElementAdapter> 
componentDependsUponMap = new HashMap<>();
    +            // Aggregate all dependency mappings of all component types 
that need to have a bundle evaluated
    +            for (String typeElementName : 
Arrays.asList(PROCESSOR_TAG_NAME, CONTROLLER_SERVICE_TAG_NAME, 
REPORTING_TASK_TAG_NAME)) {
    +                final NodeList componentNodeList = 
flowDocument.getElementsByTagName(typeElementName);
    +                mapComponents(componentNodeList).forEach((id, metadata) -> 
componentDependsUponMap.merge(id, metadata, (destination, source) -> {
    +                    
destination.addDependencyIds(source.getDependencyIds());
    +                    return destination;
    +                }));
    +            }
    +
    +            for (Map.Entry<String, EnrichingElementAdapter> componentEntry 
: componentDependsUponMap.entrySet()) {
    +
    +                // If this particular component has already had bundle 
information applied, skip it
    +                EnrichingElementAdapter componentToEnrich = 
componentEntry.getValue();
    +                if (componentToEnrich.getBundleElement() != null) {
    +                    continue;
    +                }
    +
    +                final EnrichingElementAdapter elementToEnrich = 
componentToEnrich;
    +                final String bundleClassLookup = 
elementToEnrich.getComponentClass();
    +                final List<Bundle> bundles = 
ExtensionManager.getBundles(bundleClassLookup);
    +                BundleCoordinate enrichingBundle = null;
    +                // If there is only one supporting bundle, choose it, 
otherwise defer to the other item
    +                if (bundles.size() == 1) {
    +                    enrichingBundle = 
bundles.get(0).getBundleDetails().getCoordinate();
    +                } else if (bundles.size() > 1) {
    +
    --- End diff --
    
    There most certainly is.  I think I lost a commit in my branch juggling.  
Let me try to dig it out.


> Improve handling of bundle versioning in NARs with other NARs as dependencies
> -----------------------------------------------------------------------------
>
>                 Key: MINIFI-408
>                 URL: https://issues.apache.org/jira/browse/MINIFI-408
>             Project: Apache NiFi MiNiFi
>          Issue Type: Bug
>          Components: Core Framework
>    Affects Versions: 0.2.0
>            Reporter: Aldrin Piri
>            Assignee: Aldrin Piri
>            Priority: Blocker
>
> Parts of this have cropped up in a few tickets affecting CNFEs and inability 
> to load processors.  This is typically exacerbated by the inclusion of NiFi 
> processors which also depend on NiFi Standard Services API NAR (typically for 
> SSL Context Service).  This can lead to problems when MiNiFi is started as 
> the transformed flow is effectively a <1.2 version which does not have the 
> bundling information established.  Accordingly, in the case above where I 
> bring a separate processor NAR with its associated versioned, services NAR, 
> there are two instances which leads to a ghost implementation.  For NiFI, 
> this is resolved in the UI to select the desired version but we have no such 
> facility in MiNiFi.  



--
This message was sent by Atlassian JIRA
(v6.4.14#64029)

Reply via email to