Search in sources :

Example 1 with ControllerServiceLogObserver

use of org.apache.nifi.logging.ControllerServiceLogObserver in project nifi by apache.

the class FlowController method createControllerService.

@Override
public ControllerServiceNode createControllerService(final String type, final String id, final BundleCoordinate bundleCoordinate, final Set<URL> additionalUrls, final boolean firstTimeAdded) {
    final ControllerServiceNode serviceNode = controllerServiceProvider.createControllerService(type, id, bundleCoordinate, additionalUrls, firstTimeAdded);
    // Register log observer to provide bulletins when reporting task logs anything at WARN level or above
    final LogRepository logRepository = LogRepositoryFactory.getRepository(id);
    logRepository.addObserver(StandardProcessorNode.BULLETIN_OBSERVER_ID, LogLevel.WARN, new ControllerServiceLogObserver(getBulletinRepository(), serviceNode));
    if (firstTimeAdded) {
        final ControllerService service = serviceNode.getControllerServiceImplementation();
        try (final NarCloseable nc = NarCloseable.withComponentNarLoader(service.getClass(), service.getIdentifier())) {
            ReflectionUtils.quietlyInvokeMethodsWithAnnotation(OnConfigurationRestored.class, service);
        }
    }
    return serviceNode;
}
Also used : NarCloseable(org.apache.nifi.nar.NarCloseable) ControllerServiceNode(org.apache.nifi.controller.service.ControllerServiceNode) ControllerServiceLogObserver(org.apache.nifi.logging.ControllerServiceLogObserver) LogRepository(org.apache.nifi.logging.LogRepository)

Aggregations

ControllerServiceNode (org.apache.nifi.controller.service.ControllerServiceNode)1 ControllerServiceLogObserver (org.apache.nifi.logging.ControllerServiceLogObserver)1 LogRepository (org.apache.nifi.logging.LogRepository)1 NarCloseable (org.apache.nifi.nar.NarCloseable)1