mirror of https://github.com/apache/nifi.git
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:
parent
79ca30be4a
commit
ddda602620
|
@ -92,7 +92,7 @@ public final class NarUnpacker {
|
||||||
|
|
||||||
if (!narFiles.isEmpty()) {
|
if (!narFiles.isEmpty()) {
|
||||||
final long startTime = System.nanoTime();
|
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) {
|
for (File narFile : narFiles) {
|
||||||
logger.debug("Expanding NAR file: " + narFile.getAbsolutePath());
|
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,
|
private static void unpackDocumentation(final File jar, final File docsDirectory,
|
||||||
final ExtensionMapping extensionMapping) throws IOException {
|
final ExtensionMapping extensionMapping) throws IOException {
|
||||||
// determine the components that may have documentation
|
// determine the components that may have documentation
|
||||||
determineDocumentedNiFiComponents(jar, extensionMapping);
|
if (!determineDocumentedNiFiComponents(jar, extensionMapping)) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
// look for all documentation related to each component
|
// look for all documentation related to each component
|
||||||
try (final JarFile jarFile = new JarFile(jar)) {
|
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 {
|
final ExtensionMapping extensionMapping) throws IOException {
|
||||||
try (final JarFile jarFile = new JarFile(jar)) {
|
try (final JarFile jarFile = new JarFile(jar)) {
|
||||||
final JarEntry processorEntry = jarFile
|
final JarEntry processorEntry = jarFile
|
||||||
|
@ -313,12 +318,17 @@ public final class NarUnpacker {
|
||||||
final JarEntry controllerServiceEntry = jarFile
|
final JarEntry controllerServiceEntry = jarFile
|
||||||
.getJarEntry("META-INF/services/org.apache.nifi.controller.ControllerService");
|
.getJarEntry("META-INF/services/org.apache.nifi.controller.ControllerService");
|
||||||
|
|
||||||
|
if (processorEntry==null && reportingTaskEntry==null && controllerServiceEntry==null) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
extensionMapping.addAllProcessors(determineDocumentedNiFiComponents(jarFile,
|
extensionMapping.addAllProcessors(determineDocumentedNiFiComponents(jarFile,
|
||||||
processorEntry));
|
processorEntry));
|
||||||
extensionMapping.addAllReportingTasks(determineDocumentedNiFiComponents(jarFile,
|
extensionMapping.addAllReportingTasks(determineDocumentedNiFiComponents(jarFile,
|
||||||
reportingTaskEntry));
|
reportingTaskEntry));
|
||||||
extensionMapping.addAllControllerServices(determineDocumentedNiFiComponents(jarFile,
|
extensionMapping.addAllControllerServices(determineDocumentedNiFiComponents(jarFile,
|
||||||
controllerServiceEntry));
|
controllerServiceEntry));
|
||||||
|
return true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue