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

The following examples show how to use org.apache.nifi.nar.ExtensionManager#removeInstanceClassLoader() . 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: StandardControllerServiceProvider.java    From nifi with Apache License 2.0 6 votes vote down vote up
@Override
public void removeControllerService(final ControllerServiceNode serviceNode) {
    requireNonNull(serviceNode);
    serviceCache.remove(serviceNode.getIdentifier());

    final ProcessGroup group = serviceNode.getProcessGroup();
    if (group == null) {
        flowManager.removeRootControllerService(serviceNode);
        return;
    }

    group.removeControllerService(serviceNode);
    LogRepositoryFactory.removeRepository(serviceNode.getIdentifier());
    final ExtensionManager extensionManager = flowController.getExtensionManager();
    extensionManager.removeInstanceClassLoader(serviceNode.getIdentifier());
    serviceCache.remove(serviceNode.getIdentifier());
}
 
Example 2
Source File: ControllerServiceInitializer.java    From nifi-minifi with Apache License 2.0 5 votes vote down vote up
@Override
public void teardown(ConfigurableComponent component) {
    try (NarCloseable narCloseable = NarCloseable.withComponentNarLoader(component.getClass(), component.getIdentifier())) {
        ControllerService controllerService = (ControllerService) component;

        final ComponentLog logger = new MockComponentLogger();
        final MockConfigurationContext context = new MockConfigurationContext();
        ReflectionUtils.quietlyInvokeMethodsWithAnnotation(OnShutdown.class, controllerService, logger, context);
    } finally {
        ExtensionManager.removeInstanceClassLoader(component.getIdentifier());
    }
}
 
Example 3
Source File: ProcessorInitializer.java    From nifi-minifi with Apache License 2.0 5 votes vote down vote up
@Override
public void teardown(ConfigurableComponent component) {
    Processor processor = (Processor) component;
    try (NarCloseable narCloseable = NarCloseable.withComponentNarLoader(component.getClass(), component.getIdentifier())) {

        final ComponentLog logger = new MockComponentLogger();
        final MockProcessContext context = new MockProcessContext();
        ReflectionUtils.quietlyInvokeMethodsWithAnnotation(OnShutdown.class, processor, logger, context);
    } finally {
        ExtensionManager.removeInstanceClassLoader(component.getIdentifier());
    }
}
 
Example 4
Source File: ReportingTaskingInitializer.java    From nifi-minifi with Apache License 2.0 5 votes vote down vote up
@Override
public void teardown(ConfigurableComponent component) {
    ReportingTask reportingTask = (ReportingTask) component;
    try (NarCloseable narCloseable = NarCloseable.withComponentNarLoader(component.getClass(), component.getIdentifier())) {

        final MockConfigurationContext context = new MockConfigurationContext();
        ReflectionUtils.quietlyInvokeMethodsWithAnnotation(OnShutdown.class, reportingTask, new MockComponentLogger(), context);
    } finally {
        ExtensionManager.removeInstanceClassLoader(component.getIdentifier());
    }
}
 
Example 5
Source File: StandardFlowManager.java    From nifi with Apache License 2.0 5 votes vote down vote up
public void removeRootControllerService(final ControllerServiceNode service) {
    final ControllerServiceNode existing = rootControllerServices.get(requireNonNull(service).getIdentifier());
    if (existing == null) {
        throw new IllegalStateException(service + " is not a member of this Process Group");
    }

    service.verifyCanDelete();

    final ExtensionManager extensionManager = flowController.getExtensionManager();
    final VariableRegistry variableRegistry = flowController.getVariableRegistry();

    try (final NarCloseable x = NarCloseable.withComponentNarLoader(extensionManager, service.getControllerServiceImplementation().getClass(), service.getIdentifier())) {
        final ConfigurationContext configurationContext = new StandardConfigurationContext(service, flowController.getControllerServiceProvider(), null, variableRegistry);
        ReflectionUtils.quietlyInvokeMethodsWithAnnotation(OnRemoved.class, service.getControllerServiceImplementation(), configurationContext);
    }

    for (final Map.Entry<PropertyDescriptor, String> entry : service.getEffectivePropertyValues().entrySet()) {
        final PropertyDescriptor descriptor = entry.getKey();
        if (descriptor.getControllerServiceDefinition() != null) {
            final String value = entry.getValue() == null ? descriptor.getDefaultValue() : entry.getValue();
            if (value != null) {
                final ControllerServiceNode referencedNode = getRootControllerService(value);
                if (referencedNode != null) {
                    referencedNode.removeReference(service, descriptor);
                }
            }
        }
    }

    rootControllerServices.remove(service.getIdentifier());
    flowController.getStateManagerProvider().onComponentRemoved(service.getIdentifier());

    extensionManager.removeInstanceClassLoader(service.getIdentifier());

    logger.info("{} removed from Flow Controller", service);
}