Java Code Examples for org.apache.nifi.controller.service.ControllerServiceNode#getIdentifier()
The following examples show how to use
org.apache.nifi.controller.service.ControllerServiceNode#getIdentifier() .
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: NiFiRegistryFlowMapper.java From nifi with Apache License 2.0 | 6 votes |
public VersionedControllerService mapControllerService(final ControllerServiceNode controllerService, final ControllerServiceProvider serviceProvider, final Set<String> includedGroupIds, final Map<String, ExternalControllerServiceReference> externalControllerServiceReferences) { final VersionedControllerService versionedService = new InstantiatedVersionedControllerService(controllerService.getIdentifier(), controllerService.getProcessGroupIdentifier()); versionedService.setIdentifier(getId(controllerService.getVersionedComponentId(), controllerService.getIdentifier())); versionedService.setGroupIdentifier(getGroupId(controllerService.getProcessGroupIdentifier())); versionedService.setName(controllerService.getName()); versionedService.setAnnotationData(controllerService.getAnnotationData()); versionedService.setBundle(mapBundle(controllerService.getBundleCoordinate())); versionedService.setComments(controllerService.getComments()); versionedService.setControllerServiceApis(mapControllerServiceApis(controllerService)); versionedService.setProperties(mapProperties(controllerService, serviceProvider)); versionedService.setPropertyDescriptors(mapPropertyDescriptors(controllerService, serviceProvider, includedGroupIds, externalControllerServiceReferences)); versionedService.setType(controllerService.getCanonicalClassName()); return versionedService; }
Example 2
Source File: StandardValidationContext.java From localization_nifi with Apache License 2.0 | 5 votes |
@Override public ValidationContext getControllerServiceValidationContext(final ControllerService controllerService) { final ControllerServiceNode serviceNode = controllerServiceProvider.getControllerServiceNode(controllerService.getIdentifier()); final ProcessGroup serviceGroup = serviceNode.getProcessGroup(); final String serviceGroupId = serviceGroup == null ? null : serviceGroup.getIdentifier(); return new StandardValidationContext(controllerServiceProvider, serviceNode.getProperties(), serviceNode.getAnnotationData(), serviceGroupId, serviceNode.getIdentifier(),variableRegistry); }
Example 3
Source File: StatusRequestParser.java From nifi-minifi with Apache License 2.0 | 5 votes |
static ControllerServiceStatus parseControllerServiceStatusRequest(ControllerServiceNode controllerServiceNode, String statusTypes, FlowController flowController, Logger logger) { ControllerServiceStatus controllerServiceStatus = new ControllerServiceStatus(); String id = controllerServiceNode.getIdentifier(); controllerServiceStatus.setName(id); String[] statusSplits = statusTypes.split(","); List<Bulletin> bulletinList = flowController.getBulletinRepository().findBulletins( new BulletinQuery.Builder() .sourceIdMatches(id) .build()); for (String statusType : statusSplits) { switch (statusType.toLowerCase().trim()) { case "health": ControllerServiceHealth controllerServiceHealth = new ControllerServiceHealth(); controllerServiceHealth.setState(controllerServiceNode.getState().name()); controllerServiceHealth.setHasBulletins(!bulletinList.isEmpty()); Collection<ValidationResult> validationResults = controllerServiceNode.getValidationErrors(); controllerServiceHealth.setValidationErrorList(transformValidationResults(validationResults)); controllerServiceStatus.setControllerServiceHealth(controllerServiceHealth); break; case "bulletins": controllerServiceStatus.setBulletinList(transformBulletins(bulletinList)); break; } } return controllerServiceStatus; }
Example 4
Source File: StandardValidationContext.java From nifi with Apache License 2.0 | 5 votes |
@Override public ValidationContext getControllerServiceValidationContext(final ControllerService controllerService) { final ControllerServiceNode serviceNode = controllerServiceProvider.getControllerServiceNode(controllerService.getIdentifier()); final ProcessGroup serviceGroup = serviceNode.getProcessGroup(); final String serviceGroupId = serviceGroup == null ? null : serviceGroup.getIdentifier(); return new StandardValidationContext(controllerServiceProvider, serviceNode.getProperties(), serviceNode.getAnnotationData(), serviceGroupId, serviceNode.getIdentifier(), variableRegistry, serviceNode.getProcessGroup().getParameterContext()); }
Example 5
Source File: StandardProcessGroup.java From localization_nifi with Apache License 2.0 | 4 votes |
@Override public void removeControllerService(final ControllerServiceNode service) { boolean removed = false; writeLock.lock(); try { final ControllerServiceNode existing = controllerServices.get(requireNonNull(service).getIdentifier()); if (existing == null) { throw new IllegalStateException("ControllerService " + service.getIdentifier() + " is not a member of this Process Group"); } service.verifyCanDelete(); try (final NarCloseable x = NarCloseable.withComponentNarLoader(service.getControllerServiceImplementation().getClass(), service.getIdentifier())) { final ConfigurationContext configurationContext = new StandardConfigurationContext(service, controllerServiceProvider, null, variableRegistry); ReflectionUtils.quietlyInvokeMethodsWithAnnotation(OnRemoved.class, service.getControllerServiceImplementation(), configurationContext); } for (final Map.Entry<PropertyDescriptor, String> entry : service.getProperties().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 = getControllerService(value); if (referencedNode != null) { referencedNode.removeReference(service); } } } } controllerServices.remove(service.getIdentifier()); flowController.getStateManagerProvider().onComponentRemoved(service.getIdentifier()); removed = true; LOG.info("{} removed from {}", service, this); } finally { if (removed) { try { ExtensionManager.removeInstanceClassLoaderIfExists(service.getIdentifier()); } catch (Throwable t) { } } writeLock.unlock(); } }
Example 6
Source File: FlowController.java From localization_nifi with Apache License 2.0 | 4 votes |
public void addRootControllerService(final ControllerServiceNode serviceNode) { final ControllerServiceNode existing = rootControllerServices.putIfAbsent(serviceNode.getIdentifier(), serviceNode); if (existing != null) { throw new IllegalStateException("Controller Service with ID " + serviceNode.getIdentifier() + " already exists at the Controller level"); } }
Example 7
Source File: AbstractComponentNode.java From nifi with Apache License 2.0 | 4 votes |
private ValidationResult validateControllerServiceApi(final PropertyDescriptor descriptor, final ControllerServiceNode controllerServiceNode) { final Class<? extends ControllerService> controllerServiceApiClass = descriptor.getControllerServiceDefinition(); // If a processor accepts any service don't validate it. if (controllerServiceApiClass.equals(ControllerService.class)) { return null; } final ClassLoader controllerServiceApiClassLoader = controllerServiceApiClass.getClassLoader(); final ExtensionManager extensionManager = serviceProvider.getExtensionManager(); final String serviceId = controllerServiceNode.getIdentifier(); final String propertyName = descriptor.getDisplayName(); final Bundle controllerServiceApiBundle = extensionManager.getBundle(controllerServiceApiClassLoader); if (controllerServiceApiBundle == null) { return createInvalidResult(serviceId, propertyName, "Unable to find bundle for ControllerService API class " + controllerServiceApiClass.getCanonicalName()); } final BundleCoordinate controllerServiceApiCoordinate = controllerServiceApiBundle.getBundleDetails().getCoordinate(); final Bundle controllerServiceBundle = extensionManager.getBundle(controllerServiceNode.getBundleCoordinate()); if (controllerServiceBundle == null) { return createInvalidResult(serviceId, propertyName, "Unable to find bundle for coordinate " + controllerServiceNode.getBundleCoordinate()); } final BundleCoordinate controllerServiceCoordinate = controllerServiceBundle.getBundleDetails().getCoordinate(); final boolean matchesApi = matchesApi(extensionManager, controllerServiceBundle, controllerServiceApiCoordinate); if (!matchesApi) { final String controllerServiceType = controllerServiceNode.getComponentType(); final String controllerServiceApiType = controllerServiceApiClass.getSimpleName(); final String explanation = new StringBuilder() .append(controllerServiceType).append(" - ").append(controllerServiceCoordinate.getVersion()) .append(" from ").append(controllerServiceCoordinate.getGroup()).append(" - ").append(controllerServiceCoordinate.getId()) .append(" is not compatible with ").append(controllerServiceApiType).append(" - ").append(controllerServiceApiCoordinate.getVersion()) .append(" from ").append(controllerServiceApiCoordinate.getGroup()).append(" - ").append(controllerServiceApiCoordinate.getId()) .toString(); return createInvalidResult(serviceId, propertyName, explanation); } return null; }
Example 8
Source File: StandardFlowManager.java From nifi with Apache License 2.0 | 4 votes |
public void addRootControllerService(final ControllerServiceNode serviceNode) { final ControllerServiceNode existing = rootControllerServices.putIfAbsent(serviceNode.getIdentifier(), serviceNode); if (existing != null) { throw new IllegalStateException("Controller Service with ID " + serviceNode.getIdentifier() + " already exists at the Controller level"); } }
Example 9
Source File: StandardReloadComponent.java From nifi with Apache License 2.0 | 4 votes |
@Override public void reload(final ControllerServiceNode existingNode, final String newType, final BundleCoordinate bundleCoordinate, final Set<URL> additionalUrls) throws ControllerServiceInstantiationException { if (existingNode == null) { throw new IllegalStateException("Existing ControllerServiceNode cannot be null"); } final String id = existingNode.getIdentifier(); // ghost components will have a null logger if (existingNode.getLogger() != null) { existingNode.getLogger().debug("Reloading component {} to type {} from bundle {}", new Object[]{id, newType, bundleCoordinate}); } final ExtensionManager extensionManager = flowController.getExtensionManager(); // createControllerService will create a new instance class loader for the same id so // save the instance class loader to use it for calling OnRemoved on the existing service final ClassLoader existingInstanceClassLoader = extensionManager.getInstanceClassLoader(id); // create a new node with firstTimeAdded as true so lifecycle methods get called // attempt the creation to make sure it works before firing the OnRemoved methods below final ControllerServiceNode newNode = flowController.getFlowManager().createControllerService(newType, id, bundleCoordinate, additionalUrls, true, false); // call OnRemoved for the existing service using the previous instance class loader try (final NarCloseable x = NarCloseable.withComponentNarLoader(existingInstanceClassLoader)) { final ConfigurationContext configurationContext = new StandardConfigurationContext(existingNode, flowController.getControllerServiceProvider(), null, flowController.getVariableRegistry()); ReflectionUtils.quietlyInvokeMethodsWithAnnotation(OnRemoved.class, existingNode.getControllerServiceImplementation(), configurationContext); } finally { extensionManager.closeURLClassLoader(id, existingInstanceClassLoader); } // take the invocation handler that was created for new proxy and is set to look at the new node, // and set it to look at the existing node final ControllerServiceInvocationHandler invocationHandler = newNode.getInvocationHandler(); invocationHandler.setServiceNode(existingNode); // create LoggableComponents for the proxy and implementation final ComponentLog componentLogger = new SimpleProcessLogger(id, newNode.getControllerServiceImplementation()); final TerminationAwareLogger terminationAwareLogger = new TerminationAwareLogger(componentLogger); LogRepositoryFactory.getRepository(id).setLogger(terminationAwareLogger); final LoggableComponent<ControllerService> loggableProxy = new LoggableComponent<>(newNode.getProxiedControllerService(), bundleCoordinate, terminationAwareLogger); final LoggableComponent<ControllerService> loggableImplementation = new LoggableComponent<>(newNode.getControllerServiceImplementation(), bundleCoordinate, terminationAwareLogger); // set the new impl, proxy, and invocation handler into the existing node existingNode.setControllerServiceAndProxy(loggableImplementation, loggableProxy, invocationHandler); existingNode.setExtensionMissing(newNode.isExtensionMissing()); // need to refresh the properties in case we are changing from ghost component to real component existingNode.refreshProperties(); logger.debug("Triggering async validation of {} due to controller service reload", existingNode); flowController.getValidationTrigger().triggerAsync(existingNode); }