NIFI-3350 optimized documentation extraction to reduce startup time Signed-off-by: James Wing <jvw...@gmail.com>
This closes #1416. Project: http://git-wip-us.apache.org/repos/asf/nifi/repo Commit: http://git-wip-us.apache.org/repos/asf/nifi/commit/3a094818 Tree: http://git-wip-us.apache.org/repos/asf/nifi/tree/3a094818 Diff: http://git-wip-us.apache.org/repos/asf/nifi/diff/3a094818 Branch: refs/heads/support/nifi-0.7.x Commit: 3a0948188e3095bc0b38c54daea0dd219a3b11fa Parents: 6ccc729 Author: Mike Moser <mose...@apache.org> Authored: Fri Jan 13 22:17:36 2017 +0000 Committer: James Wing <jvw...@gmail.com> Committed: Mon Jan 23 21:20:24 2017 -0800 ---------------------------------------------------------------------- .../main/java/org/apache/nifi/nar/NarUnpacker.java | 16 +++++++++++++--- 1 file changed, 13 insertions(+), 3 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/nifi/blob/3a094818/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-nar-utils/src/main/java/org/apache/nifi/nar/NarUnpacker.java ---------------------------------------------------------------------- diff --git a/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-nar-utils/src/main/java/org/apache/nifi/nar/NarUnpacker.java b/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-nar-utils/src/main/java/org/apache/nifi/nar/NarUnpacker.java index ee8b454..1203118 100644 --- a/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-nar-utils/src/main/java/org/apache/nifi/nar/NarUnpacker.java +++ b/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-nar-utils/src/main/java/org/apache/nifi/nar/NarUnpacker.java @@ -90,7 +90,7 @@ public final class NarUnpacker { if (!narFiles.isEmpty()) { final long startTime = System.nanoTime(); - logger.info("Expanding " + narFiles.size() + " NAR files with all processors... It can take few minutes."); + logger.info("Expanding " + narFiles.size() + " NAR files with all processors..."); for (File narFile : narFiles) { logger.debug("Expanding NAR file: " + narFile.getAbsolutePath()); @@ -262,7 +262,9 @@ public final class NarUnpacker { private static void unpackDocumentation(final File jar, final File docsDirectory, final ExtensionMapping extensionMapping) throws IOException { // determine the components that may have documentation - determineDocumentedNiFiComponents(jar, extensionMapping); + if (!determineDocumentedNiFiComponents(jar, extensionMapping)) { + return; + } // look for all documentation related to each component try (final JarFile jarFile = new JarFile(jar)) { @@ -301,7 +303,10 @@ public final class NarUnpacker { } } - private static void determineDocumentedNiFiComponents(final File jar, + /* + * Returns true if this jar file contains a NiFi component + */ + private static boolean determineDocumentedNiFiComponents(final File jar, final ExtensionMapping extensionMapping) throws IOException { try (final JarFile jarFile = new JarFile(jar)) { final JarEntry processorEntry = jarFile @@ -311,12 +316,17 @@ public final class NarUnpacker { final JarEntry controllerServiceEntry = jarFile .getJarEntry("META-INF/services/org.apache.nifi.controller.ControllerService"); + if (processorEntry==null && reportingTaskEntry==null && controllerServiceEntry==null) { + return false; + } + extensionMapping.addAllProcessors(determineDocumentedNiFiComponents(jarFile, processorEntry)); extensionMapping.addAllReportingTasks(determineDocumentedNiFiComponents(jarFile, reportingTaskEntry)); extensionMapping.addAllControllerServices(determineDocumentedNiFiComponents(jarFile, controllerServiceEntry)); + return true; } }