org.apache.nifi.registry.flow.VersionedControllerService Java Examples
The following examples show how to use
org.apache.nifi.registry.flow.VersionedControllerService.
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: NiFiRegControllerServiceSchemaFunction.java From nifi-minifi with Apache License 2.0 | 6 votes |
@Override public ControllerServiceSchema apply(final VersionedControllerService versionedControllerService) { Map<String, Object> map = new HashMap<>(); map.put(NAME_KEY, versionedControllerService.getName()); map.put(ID_KEY, versionedControllerService.getIdentifier()); map.put(TYPE_KEY, versionedControllerService.getType()); map.put(PROPERTIES_KEY, new HashMap<>(nullToEmpty(versionedControllerService.getProperties()))); String annotationData = versionedControllerService.getAnnotationData(); if(annotationData != null && !annotationData.isEmpty()) { map.put(ANNOTATION_DATA_KEY, annotationData); } return new ControllerServiceSchema(map); }
Example #2
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 #3
Source File: StandardFlowComparator.java From nifi-registry with Apache License 2.0 | 5 votes |
private void compare(final VersionedControllerService serviceA, final VersionedControllerService serviceB, final Set<FlowDifference> differences) { if (compareComponents(serviceA, serviceB, differences)) { return; } addIfDifferent(differences, DifferenceType.ANNOTATION_DATA_CHANGED, serviceA, serviceB, VersionedControllerService::getAnnotationData); addIfDifferent(differences, DifferenceType.BUNDLE_CHANGED, serviceA, serviceB, VersionedControllerService::getBundle); compareProperties(serviceA, serviceB, serviceA.getProperties(), serviceB.getProperties(), serviceA.getPropertyDescriptors(), serviceB.getPropertyDescriptors(), differences); }
Example #4
Source File: StandardFlowComparator.java From nifi-registry with Apache License 2.0 | 4 votes |
@Override public Set<FlowDifference> compareControllerServices(final VersionedControllerService serviceA, final VersionedControllerService serviceB) { final Set<FlowDifference> differences = new HashSet<>(); compare(serviceA, serviceB, differences); return differences; }
Example #5
Source File: ComponentFactory.java From nifi with Apache License 2.0 | 4 votes |
public ControllerService createControllerService(final VersionedControllerService versionedControllerService, final VariableRegistry variableRegistry, final ControllerServiceLookup serviceLookup, final StateManager stateManager, final ParameterLookup parameterLookup) { return createControllerService(versionedControllerService, variableRegistry, null, serviceLookup, stateManager, parameterLookup); }
Example #6
Source File: ComponentFactory.java From nifi with Apache License 2.0 | 4 votes |
private ControllerService createControllerService(final VersionedControllerService versionedControllerService, final VariableRegistry variableRegistry, final Set<URL> classpathUrls, final ControllerServiceLookup serviceLookup, final StateManager stateManager, final ParameterLookup parameterLookup) { final String type = versionedControllerService.getType(); final String identifier = versionedControllerService.getIdentifier(); final Bundle bundle = getAvailableBundle(versionedControllerService.getBundle(), type); if (bundle == null) { throw new IllegalStateException("Unable to find bundle for coordinate " + versionedControllerService.getBundle().getGroup() + ":" + versionedControllerService.getBundle().getArtifact() + ":" + versionedControllerService.getBundle().getVersion()); } final ClassLoader ctxClassLoader = Thread.currentThread().getContextClassLoader(); try { final ClassLoader detectedClassLoader = extensionManager.createInstanceClassLoader(type, identifier, bundle, classpathUrls == null ? Collections.emptySet() : classpathUrls); logger.debug("Setting context class loader to {} (parent = {}) to create {}", detectedClassLoader, detectedClassLoader.getParent(), type); final Class<?> rawClass = Class.forName(type, true, detectedClassLoader); Thread.currentThread().setContextClassLoader(detectedClassLoader); final Object extensionInstance = rawClass.newInstance(); final ComponentLog componentLog = new SLF4JComponentLog(extensionInstance); final ControllerService service = (ControllerService) extensionInstance; final ControllerServiceInitializationContext initializationContext = new StatelessControllerServiceInitializationContext(identifier, service, serviceLookup, stateManager); service.initialize(initializationContext); // If no classpath urls were provided, check if we need to add additional classpath URL's based on configured properties. if (classpathUrls == null) { final Set<URL> additionalClasspathUrls = getAdditionalClasspathResources(service.getPropertyDescriptors(), service.getIdentifier(), versionedControllerService.getProperties(), parameterLookup, variableRegistry, componentLog); if (!additionalClasspathUrls.isEmpty()) { return createControllerService(versionedControllerService, variableRegistry, additionalClasspathUrls, serviceLookup, stateManager, parameterLookup); } } return service; } catch (final Exception e) { throw new ControllerServiceInstantiationException(type, e); } finally { if (ctxClassLoader != null) { Thread.currentThread().setContextClassLoader(ctxClassLoader); } } }
Example #7
Source File: ImportFlowIT.java From nifi with Apache License 2.0 | 4 votes |
private VersionedFlowSnapshot createFlowSnapshot(final List<ControllerServiceNode> controllerServices, final List<ProcessorNode> processors, final Set<Parameter> parameters) { final VersionedFlowSnapshotMetadata snapshotMetadata = new VersionedFlowSnapshotMetadata(); snapshotMetadata.setAuthor("unit-test"); snapshotMetadata.setBucketIdentifier("unit-test-bucket"); snapshotMetadata.setFlowIdentifier("unit-test-flow"); snapshotMetadata.setTimestamp(System.currentTimeMillis()); snapshotMetadata.setVersion(1); final Bucket bucket = new Bucket(); bucket.setCreatedTimestamp(System.currentTimeMillis()); bucket.setIdentifier("unit-test-bucket"); bucket.setName("Unit Test Bucket"); final VersionedFlow flow = new VersionedFlow(); flow.setBucketIdentifier("unit-test-bucket"); flow.setBucketName("Unit Test Bucket"); flow.setCreatedTimestamp(System.currentTimeMillis()); flow.setIdentifier("unit-test-flow"); flow.setName("Unit Test Flow"); final BundleCoordinate coordinate = getSystemBundle().getBundleDetails().getCoordinate(); final Bundle bundle = new Bundle(); bundle.setArtifact(coordinate.getId()); bundle.setGroup(coordinate.getGroup()); bundle.setVersion(coordinate.getVersion()); final NiFiRegistryFlowMapper flowMapper = new NiFiRegistryFlowMapper(getExtensionManager()); final Set<VersionedProcessor> versionedProcessors = new HashSet<>(); for (final ProcessorNode processor : processors) { final VersionedProcessor versionedProcessor = flowMapper.mapProcessor(processor, getFlowController().getControllerServiceProvider(), Collections.emptySet(), new HashMap<>()); versionedProcessors.add(versionedProcessor); processor.setVersionedComponentId(versionedProcessor.getIdentifier()); } final Set<VersionedControllerService> services = new HashSet<>(); for (final ControllerServiceNode serviceNode : controllerServices) { final VersionedControllerService service = flowMapper.mapControllerService(serviceNode, getFlowController().getControllerServiceProvider(), Collections.emptySet(), new HashMap<>()); services.add(service); serviceNode.setVersionedComponentId(service.getIdentifier()); } final VersionedProcessGroup flowContents = new VersionedProcessGroup(); flowContents.setIdentifier("unit-test-flow-contents"); flowContents.setName("Unit Test"); flowContents.setProcessors(versionedProcessors); flowContents.setControllerServices(services); final VersionedFlowSnapshot versionedFlowSnapshot = new VersionedFlowSnapshot(); versionedFlowSnapshot.setSnapshotMetadata(snapshotMetadata); versionedFlowSnapshot.setBucket(bucket); versionedFlowSnapshot.setFlow(flow); versionedFlowSnapshot.setFlowContents(flowContents); if (parameters != null) { final Set<VersionedParameter> versionedParameters = new HashSet<>(); for (final Parameter parameter : parameters) { final VersionedParameter versionedParameter = new VersionedParameter(); versionedParameter.setName(parameter.getDescriptor().getName()); versionedParameter.setValue(parameter.getValue()); versionedParameter.setSensitive(parameter.getDescriptor().isSensitive()); versionedParameters.add(versionedParameter); } final VersionedParameterContext versionedParameterContext = new VersionedParameterContext(); versionedParameterContext.setName("Unit Test Context"); versionedParameterContext.setParameters(versionedParameters); versionedFlowSnapshot.setParameterContexts(Collections.singletonMap(versionedParameterContext.getName(), versionedParameterContext)); flowContents.setParameterContextName("Unit Test Context"); } return versionedFlowSnapshot; }
Example #8
Source File: FlowComparator.java From nifi-registry with Apache License 2.0 | 2 votes |
/** * Compares two versions of a Controller Service and returns the differences between them * * @param serviceA the first Controller Service * @param serviceB the second Controller Service * @return the differences between them */ Set<FlowDifference> compareControllerServices(VersionedControllerService serviceA, VersionedControllerService serviceB);