NIFI-3350 optimized documentation extraction to reduce startup time

Signed-off-by: James Wing <jvwing@gmail.com>

This closes #1416.
This commit is contained in:
Mike Moser 2017-01-13 22:17:36 +00:00 committed by James Wing
parent 79ca30be4a
commit ddda602620
1 changed files with 13 additions and 3 deletions

View File

@ -92,7 +92,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());
@ -264,7 +264,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)) {
@ -303,7 +305,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
@ -313,12 +318,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;
}
}