Java Code Examples for org.apache.nifi.nar.ExtensionManager#getTempComponent()

The following examples show how to use org.apache.nifi.nar.ExtensionManager#getTempComponent() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: DocGenerator.java    From nifi with Apache License 2.0 6 votes vote down vote up
/**
 * Generates the documentation for a particular configurable component. Will
 * check to see if an "additionalDetails.html" file exists and will link
 * that from the generated documentation.
 *
 * @param componentDocsDir the component documentation directory
 * @param componentClass the class to document
 * @throws InstantiationException ie
 * @throws IllegalAccessException iae
 * @throws IOException ioe
 * @throws InitializationException ie
 */
private static void document(final ExtensionManager extensionManager,
                             final File componentDocsDir,
                             final Class<? extends ConfigurableComponent> componentClass,
                             final BundleCoordinate bundleCoordinate)
        throws InstantiationException, IllegalAccessException, IOException, InitializationException {

    // use temp components from ExtensionManager which should always be populated before doc generation
    final String classType = componentClass.getCanonicalName();
    final ConfigurableComponent component = extensionManager.getTempComponent(classType, bundleCoordinate);

    final DocumentationWriter writer = getDocumentWriter(extensionManager, componentClass);

    final File baseDocumentationFile = new File(componentDocsDir, "index.html");
    if (baseDocumentationFile.exists()) {
        logger.warn(baseDocumentationFile + " already exists, overwriting!");
    }

    try (final OutputStream output = new BufferedOutputStream(new FileOutputStream(baseDocumentationFile))) {
        writer.write(component, output, hasAdditionalInfo(componentDocsDir));
    }
}
 
Example 2
Source File: StandardControllerServiceDAO.java    From nifi with Apache License 2.0 6 votes vote down vote up
private void updateBundle(final ControllerServiceNode controllerService, final ControllerServiceDTO controllerServiceDTO) {
    final BundleDTO bundleDTO = controllerServiceDTO.getBundle();
    if (bundleDTO != null) {
        final ExtensionManager extensionManager = serviceProvider.getExtensionManager();
        final BundleCoordinate incomingCoordinate = BundleUtils.getBundle(extensionManager, controllerService.getCanonicalClassName(), bundleDTO);
        final BundleCoordinate existingCoordinate = controllerService.getBundleCoordinate();
        if (!existingCoordinate.getCoordinate().equals(incomingCoordinate.getCoordinate())) {
            try {
                // we need to use the property descriptors from the temp component here in case we are changing from a ghost component to a real component
                final ConfigurableComponent tempComponent = extensionManager.getTempComponent(controllerService.getCanonicalClassName(), incomingCoordinate);
                final Set<URL> additionalUrls = controllerService.getAdditionalClasspathResources(tempComponent.getPropertyDescriptors());
                flowController.getReloadComponent().reload(controllerService, controllerService.getCanonicalClassName(), incomingCoordinate, additionalUrls);
            } catch (ControllerServiceInstantiationException e) {
                throw new NiFiCoreException(String.format("Unable to update controller service %s from %s to %s due to: %s",
                        controllerServiceDTO.getId(), controllerService.getBundleCoordinate().getCoordinate(), incomingCoordinate.getCoordinate(), e.getMessage()), e);
            }
        }
    }
}
 
Example 3
Source File: StandardReportingTaskDAO.java    From nifi with Apache License 2.0 6 votes vote down vote up
private void updateBundle(ReportingTaskNode reportingTask, ReportingTaskDTO reportingTaskDTO) {
    final BundleDTO bundleDTO = reportingTaskDTO.getBundle();
    if (bundleDTO != null) {
        final ExtensionManager extensionManager = reportingTaskProvider.getExtensionManager();
        final BundleCoordinate incomingCoordinate = BundleUtils.getBundle(extensionManager, reportingTask.getCanonicalClassName(), bundleDTO);
        final BundleCoordinate existingCoordinate = reportingTask.getBundleCoordinate();
        if (!existingCoordinate.getCoordinate().equals(incomingCoordinate.getCoordinate())) {
            try {
                // we need to use the property descriptors from the temp component here in case we are changing from a ghost component to a real component
                final ConfigurableComponent tempComponent = extensionManager.getTempComponent(reportingTask.getCanonicalClassName(), incomingCoordinate);
                final Set<URL> additionalUrls = reportingTask.getAdditionalClasspathResources(tempComponent.getPropertyDescriptors());
                reloadComponent.reload(reportingTask, reportingTask.getCanonicalClassName(), incomingCoordinate, additionalUrls);
            } catch (ReportingTaskInstantiationException e) {
                throw new NiFiCoreException(String.format("Unable to update reporting task %s from %s to %s due to: %s",
                        reportingTaskDTO.getId(), reportingTask.getBundleCoordinate().getCoordinate(), incomingCoordinate.getCoordinate(), e.getMessage()), e);
            }
        }
    }
}
 
Example 4
Source File: StandardProcessorDAO.java    From nifi with Apache License 2.0 6 votes vote down vote up
private void updateBundle(ProcessorNode processor, ProcessorDTO processorDTO) {
    final BundleDTO bundleDTO = processorDTO.getBundle();
    if (bundleDTO != null) {
        final ExtensionManager extensionManager = flowController.getExtensionManager();
        final BundleCoordinate incomingCoordinate = BundleUtils.getBundle(extensionManager, processor.getCanonicalClassName(), bundleDTO);
        final BundleCoordinate existingCoordinate = processor.getBundleCoordinate();
        if (!existingCoordinate.getCoordinate().equals(incomingCoordinate.getCoordinate())) {
            try {
                // we need to use the property descriptors from the temp component here in case we are changing from a ghost component to a real component
                final ConfigurableComponent tempComponent = extensionManager.getTempComponent(processor.getCanonicalClassName(), incomingCoordinate);
                final Set<URL> additionalUrls = processor.getAdditionalClasspathResources(tempComponent.getPropertyDescriptors());
                flowController.getReloadComponent().reload(processor, processor.getCanonicalClassName(), incomingCoordinate, additionalUrls);
            } catch (ProcessorInstantiationException e) {
                throw new NiFiCoreException(String.format("Unable to update processor %s from %s to %s due to: %s",
                        processorDTO.getId(), processor.getBundleCoordinate().getCoordinate(), incomingCoordinate.getCoordinate(), e.getMessage()), e);
            }
        }
    }
}
 
Example 5
Source File: ControllerFacade.java    From nifi with Apache License 2.0 5 votes vote down vote up
/**
 * Gets the cached temporary instance of the component for the given type and bundle.
 *
 * @param type type of the component
 * @param bundle the bundle of the component
 * @return the temporary component
 * @throws IllegalStateException if no temporary component exists for the given type and bundle
 */
public ConfigurableComponent getTemporaryComponent(final String type, final BundleDTO bundle) {
    final ExtensionManager extensionManager = getExtensionManager();
    final BundleCoordinate bundleCoordinate = BundleUtils.getBundle(extensionManager, type, bundle);
    final ConfigurableComponent configurableComponent = extensionManager.getTempComponent(type, bundleCoordinate);

    if (configurableComponent == null) {
        throw new IllegalStateException("Unable to obtain temporary component for " + type);
    }

    return configurableComponent;
}