org.apache.nifi.web.api.dto.ControllerServiceDTO Java Examples
The following examples show how to use
org.apache.nifi.web.api.dto.ControllerServiceDTO.
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: ControllerServiceSchemaFunction.java From nifi-minifi with Apache License 2.0 | 6 votes |
@Override public ControllerServiceSchema apply(ControllerServiceDTO controllerServiceDTO) { Map<String, Object> map = new HashMap<>(); map.put(NAME_KEY, controllerServiceDTO.getName()); map.put(ID_KEY, controllerServiceDTO.getId()); map.put(TYPE_KEY, controllerServiceDTO.getType()); map.put(PROPERTIES_KEY, new HashMap<>(nullToEmpty(controllerServiceDTO.getProperties()))); String annotationData = controllerServiceDTO.getAnnotationData(); if(annotationData != null && !annotationData.isEmpty()) { map.put(ANNOTATION_DATA_KEY, annotationData); } return new ControllerServiceSchema(map); }
Example #2
Source File: AuthorizeParameterReference.java From nifi with Apache License 2.0 | 6 votes |
public static void authorizeParameterReferences(final FlowSnippetDTO flowSnippet, final Authorizer authorizer, final Authorizable parameterContextAuthorizable, final NiFiUser user) { for (final ProcessorDTO processorDto : flowSnippet.getProcessors()) { final ProcessorConfigDTO configDto = processorDto.getConfig(); if (configDto == null) { continue; } authorizeParameterReferences(configDto.getProperties(), authorizer, parameterContextAuthorizable, user); } for (final ControllerServiceDTO serviceDto : flowSnippet.getControllerServices()) { authorizeParameterReferences(serviceDto.getProperties(), authorizer, parameterContextAuthorizable, user); } // Note: there is no need to recurse here because when a template/snippet is instantiated, if there are any components in child Process Groups, a new Process Group will be created // without any Parameter Context, so there is no need to perform any authorization beyond the top-level group where the instantiation is occurring. }
Example #3
Source File: FingerprintFactory.java From nifi with Apache License 2.0 | 6 votes |
private void addControllerServiceFingerprint(final StringBuilder builder, final ControllerServiceDTO dto) { builder.append(dto.getId()); builder.append(dto.getVersionedComponentId()); builder.append(dto.getType()); builder.append(dto.getName()); addBundleFingerprint(builder, dto.getBundle()); builder.append(dto.getComments()); builder.append(dto.getAnnotationData()); builder.append(dto.getState()); // get the temp instance of the ControllerService so that we know the default property values final BundleCoordinate coordinate = getCoordinate(dto.getType(), dto.getBundle()); final ConfigurableComponent configurableComponent = extensionManager.getTempComponent(dto.getType(), coordinate); if (configurableComponent == null) { logger.warn("Unable to get ControllerService of type {}; its default properties will be fingerprinted instead of being ignored.", dto.getType()); } addPropertiesFingerprint(builder, configurableComponent, dto.getProperties()); }
Example #4
Source File: FlowFromDOMFactory.java From nifi with Apache License 2.0 | 6 votes |
public static ControllerServiceDTO getControllerService(final Element element, final StringEncryptor encryptor, final FlowEncodingVersion flowEncodingVersion) { final ControllerServiceDTO dto = new ControllerServiceDTO(); dto.setId(getString(element, "id")); dto.setVersionedComponentId(getString(element, "versionedComponentId")); dto.setName(getString(element, "name")); dto.setComments(getString(element, "comment")); dto.setType(getString(element, "class")); dto.setBundle(getBundle(DomUtils.getChild(element, "bundle"))); final boolean enabled = getBoolean(element, "enabled"); dto.setState(enabled ? ControllerServiceState.ENABLED.name() : ControllerServiceState.DISABLED.name()); dto.setProperties(getProperties(element, encryptor, flowEncodingVersion)); dto.setAnnotationData(getString(element, "annotationData")); return dto; }
Example #5
Source File: TemplateUtils.java From nifi with Apache License 2.0 | 6 votes |
private static void scrubControllerServices(final Set<ControllerServiceDTO> controllerServices) { for (final ControllerServiceDTO serviceDTO : controllerServices) { final Map<String, String> properties = serviceDTO.getProperties(); final Map<String, PropertyDescriptorDTO> descriptors = serviceDTO.getDescriptors(); if (properties != null && descriptors != null) { for (final PropertyDescriptorDTO descriptor : descriptors.values()) { if (Boolean.TRUE.equals(descriptor.isSensitive())) { properties.put(descriptor.getName(), null); } scrubPropertyDescriptor(descriptor); } } serviceDTO.setControllerServiceApis(null); serviceDTO.setExtensionMissing(null); serviceDTO.setMultipleVersionsAvailable(null); serviceDTO.setCustomUiUrl(null); serviceDTO.setValidationErrors(null); serviceDTO.setValidationStatus(null); } }
Example #6
Source File: StandardNiFiServiceFacade.java From localization_nifi with Apache License 2.0 | 6 votes |
@Override public ControllerServiceEntity updateControllerService(final Revision revision, final ControllerServiceDTO controllerServiceDTO) { // get the component, ensure we have access to it, and perform the update request final ControllerServiceNode controllerService = controllerServiceDAO.getControllerService(controllerServiceDTO.getId()); final RevisionUpdate<ControllerServiceDTO> snapshot = updateComponent(revision, controllerService, () -> controllerServiceDAO.updateControllerService(controllerServiceDTO), cs -> { final ControllerServiceDTO dto = dtoFactory.createControllerServiceDto(cs); final ControllerServiceReference ref = controllerService.getReferences(); final ControllerServiceReferencingComponentsEntity referencingComponentsEntity = createControllerServiceReferencingComponentsEntity(ref, Sets.newHashSet(controllerService.getIdentifier())); dto.setReferencingComponents(referencingComponentsEntity.getControllerServiceReferencingComponents()); return dto; }); final PermissionsDTO permissions = dtoFactory.createPermissionsDto(controllerService); final List<BulletinDTO> bulletins = dtoFactory.createBulletinDtos(bulletinRepository.findBulletinsForSource(controllerServiceDTO.getId())); final List<BulletinEntity> bulletinEntities = bulletins.stream().map(bulletin -> entityFactory.createBulletinEntity(bulletin, permissions.getCanRead())).collect(Collectors.toList()); return entityFactory.createControllerServiceEntity(snapshot.getComponent(), dtoFactory.createRevisionDTO(snapshot.getLastModification()), permissions, bulletinEntities); }
Example #7
Source File: NiFiClientUtil.java From nifi with Apache License 2.0 | 6 votes |
public ControllerServiceEntity createControllerService(final String type, final String processGroupId, final String bundleGroupId, final String artifactId, final String version) throws NiFiClientException, IOException { final ControllerServiceDTO dto = new ControllerServiceDTO(); dto.setType(type); final BundleDTO bundle = new BundleDTO(); bundle.setGroup(bundleGroupId); bundle.setArtifact(artifactId); bundle.setVersion(version); dto.setBundle(bundle); final ControllerServiceEntity entity = new ControllerServiceEntity(); entity.setComponent(dto); entity.setRevision(createNewRevision()); return nifiClient.getControllerServicesClient().createControllerService(processGroupId, entity); }
Example #8
Source File: ControllerServiceLoader.java From nifi with Apache License 2.0 | 6 votes |
private static ControllerServiceNode createControllerService(final FlowController flowController, final Element controllerServiceElement, final StringEncryptor encryptor, final FlowEncodingVersion encodingVersion) { final ControllerServiceDTO dto = FlowFromDOMFactory.getControllerService(controllerServiceElement, encryptor, encodingVersion); BundleCoordinate coordinate; try { coordinate = BundleUtils.getCompatibleBundle(flowController.getExtensionManager(), dto.getType(), dto.getBundle()); } catch (final IllegalStateException e) { final BundleDTO bundleDTO = dto.getBundle(); if (bundleDTO == null) { coordinate = BundleCoordinate.UNKNOWN_COORDINATE; } else { coordinate = new BundleCoordinate(bundleDTO.getGroup(), bundleDTO.getArtifact(), bundleDTO.getVersion()); } } final ControllerServiceNode node = flowController.getFlowManager().createControllerService(dto.getType(), dto.getId(), coordinate, Collections.emptySet(), false, true); node.setName(dto.getName()); node.setComments(dto.getComments()); node.setVersionedComponentId(dto.getVersionedComponentId()); return node; }
Example #9
Source File: SnippetUtils.java From nifi with Apache License 2.0 | 6 votes |
private Set<ControllerServiceDTO> getControllerServices(final Map<PropertyDescriptor, String> componentProperties) { final Set<ControllerServiceDTO> serviceDtos = new HashSet<>(); for (final Map.Entry<PropertyDescriptor, String> entry : componentProperties.entrySet()) { final PropertyDescriptor descriptor = entry.getKey(); if (descriptor.getControllerServiceDefinition() != null) { final String controllerServiceId = entry.getValue(); if (controllerServiceId != null) { final ControllerServiceNode serviceNode = flowController.getFlowManager().getControllerServiceNode(controllerServiceId); if (serviceNode != null) { serviceDtos.add(dtoFactory.createControllerServiceDto(serviceNode)); final Set<ControllerServiceDTO> recursiveRefs = getControllerServices(serviceNode.getEffectivePropertyValues()); serviceDtos.addAll(recursiveRefs); } } } } return serviceDtos; }
Example #10
Source File: StandardControllerServiceDAO.java From localization_nifi with Apache License 2.0 | 6 votes |
private void configureControllerService(final ControllerServiceNode controllerService, final ControllerServiceDTO controllerServiceDTO) { final String name = controllerServiceDTO.getName(); final String annotationData = controllerServiceDTO.getAnnotationData(); final String comments = controllerServiceDTO.getComments(); final Map<String, String> properties = controllerServiceDTO.getProperties(); if (isNotNull(name)) { controllerService.setName(name); } if (isNotNull(annotationData)) { controllerService.setAnnotationData(annotationData); } if (isNotNull(comments)) { controllerService.setComments(comments); } if (isNotNull(properties)) { controllerService.setProperties(properties); } }
Example #11
Source File: StandardControllerServiceDAO.java From nifi with Apache License 2.0 | 6 votes |
private void configureControllerService(final ControllerServiceNode controllerService, final ControllerServiceDTO controllerServiceDTO) { final String name = controllerServiceDTO.getName(); final String annotationData = controllerServiceDTO.getAnnotationData(); final String comments = controllerServiceDTO.getComments(); final Map<String, String> properties = controllerServiceDTO.getProperties(); controllerService.pauseValidationTrigger(); // avoid causing validation to be triggered multiple times try { if (isNotNull(name)) { controllerService.setName(name); } if (isNotNull(annotationData)) { controllerService.setAnnotationData(annotationData); } if (isNotNull(comments)) { controllerService.setComments(comments); } if (isNotNull(properties)) { controllerService.setProperties(properties); } } finally { controllerService.resumeValidationTrigger(); } }
Example #12
Source File: SnippetUtils.java From localization_nifi with Apache License 2.0 | 6 votes |
private Set<ControllerServiceDTO> getControllerServices(final Map<PropertyDescriptor, String> componentProperties) { final Set<ControllerServiceDTO> serviceDtos = new HashSet<>(); for (final Map.Entry<PropertyDescriptor, String> entry : componentProperties.entrySet()) { final PropertyDescriptor descriptor = entry.getKey(); if (descriptor.getControllerServiceDefinition() != null) { final String controllerServiceId = entry.getValue(); if (controllerServiceId != null) { final ControllerServiceNode serviceNode = flowController.getControllerServiceNode(controllerServiceId); if (serviceNode != null) { serviceDtos.add(dtoFactory.createControllerServiceDto(serviceNode)); final Set<ControllerServiceDTO> recursiveRefs = getControllerServices(serviceNode.getProperties()); serviceDtos.addAll(recursiveRefs); } } } } return serviceDtos; }
Example #13
Source File: StandardControllerServiceDAO.java From nifi with Apache License 2.0 | 6 votes |
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 #14
Source File: FingerprintFactory.java From localization_nifi with Apache License 2.0 | 6 votes |
private void addControllerServiceFingerprint(final StringBuilder builder, final ControllerServiceDTO dto, final FlowController controller) { builder.append(dto.getId()); builder.append(dto.getType()); builder.append(dto.getName()); builder.append(dto.getComments()); builder.append(dto.getAnnotationData()); builder.append(dto.getState()); // create an instance of the ControllerService so that we know the default property values ControllerService controllerService = null; try { if (controller != null) { controllerService = controller.createControllerService(dto.getType(), UUID.randomUUID().toString(), false).getControllerServiceImplementation(); } } catch (Exception e) { logger.warn("Unable to create ControllerService of type {} due to {}; its default properties will be fingerprinted instead of being ignored.", dto.getType(), e.toString()); if (logger.isDebugEnabled()) { logger.warn("", e); } } addPropertiesFingerprint(builder, controllerService, dto.getProperties()); }
Example #15
Source File: FlowFromDOMFactory.java From localization_nifi with Apache License 2.0 | 6 votes |
public static ControllerServiceDTO getControllerService(final Element element, final StringEncryptor encryptor) { final ControllerServiceDTO dto = new ControllerServiceDTO(); dto.setId(getString(element, "id")); dto.setName(getString(element, "name")); dto.setComments(getString(element, "comment")); dto.setType(getString(element, "class")); final boolean enabled = getBoolean(element, "enabled"); dto.setState(enabled ? ControllerServiceState.ENABLED.name() : ControllerServiceState.DISABLED.name()); dto.setProperties(getProperties(element, encryptor)); dto.setAnnotationData(getString(element, "annotationData")); return dto; }
Example #16
Source File: ControllerServiceLoader.java From localization_nifi with Apache License 2.0 | 6 votes |
public static void enableControllerServices(final Map<ControllerServiceNode, Element> nodeMap, final FlowController controller, final StringEncryptor encryptor, final boolean autoResumeState) { // Start services if (autoResumeState) { final Set<ControllerServiceNode> nodesToEnable = new HashSet<>(); for (final ControllerServiceNode node : nodeMap.keySet()) { final Element controllerServiceElement = nodeMap.get(node); final ControllerServiceDTO dto; synchronized (controllerServiceElement.getOwnerDocument()) { dto = FlowFromDOMFactory.getControllerService(controllerServiceElement, encryptor); } final ControllerServiceState state = ControllerServiceState.valueOf(dto.getState()); if (state == ControllerServiceState.ENABLED) { nodesToEnable.add(node); } } enableControllerServices(nodesToEnable, controller, autoResumeState); } }
Example #17
Source File: ControllerServiceResource.java From nifi with Apache License 2.0 | 6 votes |
/** * Populates the uri for the specified controller service. */ public ControllerServiceDTO populateRemainingControllerServiceContent(final ControllerServiceDTO controllerService) { final BundleDTO bundle = controllerService.getBundle(); // see if this processor has any ui extensions final UiExtensionMapping uiExtensionMapping = (UiExtensionMapping) servletContext.getAttribute("nifi-ui-extensions"); if (uiExtensionMapping.hasUiExtension(controllerService.getType(), bundle.getGroup(), bundle.getArtifact(), bundle.getVersion())) { final List<UiExtension> uiExtensions = uiExtensionMapping.getUiExtension(controllerService.getType(), bundle.getGroup(), bundle.getArtifact(), bundle.getVersion()); for (final UiExtension uiExtension : uiExtensions) { if (UiExtensionType.ControllerServiceConfiguration.equals(uiExtension.getExtensionType())) { controllerService.setCustomUiUrl(uiExtension.getContextPath() + "/configure"); } } } return controllerService; }
Example #18
Source File: TemplateUtils.java From localization_nifi with Apache License 2.0 | 6 votes |
private static void scrubControllerServices(final Set<ControllerServiceDTO> controllerServices) { for (final ControllerServiceDTO serviceDTO : controllerServices) { final Map<String, String> properties = serviceDTO.getProperties(); final Map<String, PropertyDescriptorDTO> descriptors = serviceDTO.getDescriptors(); if (properties != null && descriptors != null) { for (final PropertyDescriptorDTO descriptor : descriptors.values()) { if (Boolean.TRUE.equals(descriptor.isSensitive())) { properties.put(descriptor.getName(), null); } scrubPropertyDescriptor(descriptor); } } serviceDTO.setCustomUiUrl(null); serviceDTO.setValidationErrors(null); } }
Example #19
Source File: StandardSnippetDAO.java From localization_nifi with Apache License 2.0 | 6 votes |
private void lookupSensitiveControllerServiceProperties(final Set<ControllerServiceDTO> controllerServices) { // go through each service for (final ControllerServiceDTO serviceDTO : controllerServices) { // ensure that some property configuration have been specified final Map<String, String> serviceProperties = serviceDTO.getProperties(); if (serviceProperties != null) { // find the corresponding controller service final ControllerServiceNode serviceNode = flowController.getControllerServiceNode(serviceDTO.getId()); if (serviceNode == null) { throw new IllegalArgumentException(String.format("Unable to create snippet because Controller Service '%s' could not be found", serviceDTO.getId())); } // look for sensitive properties get the actual value for (Entry<PropertyDescriptor, String> entry : serviceNode.getProperties().entrySet()) { final PropertyDescriptor descriptor = entry.getKey(); if (descriptor.isSensitive()) { serviceProperties.put(descriptor.getName(), entry.getValue()); } } } } }
Example #20
Source File: StandardSnippetDAO.java From nifi with Apache License 2.0 | 6 votes |
private void lookupSensitiveControllerServiceProperties(final Set<ControllerServiceDTO> controllerServices) { // go through each service for (final ControllerServiceDTO serviceDTO : controllerServices) { // ensure that some property configuration have been specified final Map<String, String> serviceProperties = serviceDTO.getProperties(); if (serviceProperties != null) { // find the corresponding controller service final ControllerServiceNode serviceNode = flowController.getFlowManager().getControllerServiceNode(serviceDTO.getId()); if (serviceNode == null) { throw new IllegalArgumentException(String.format("Unable to create snippet because Controller Service '%s' could not be found", serviceDTO.getId())); } // look for sensitive properties get the actual value for (Entry<PropertyDescriptor, String> entry : serviceNode.getRawPropertyValues().entrySet()) { final PropertyDescriptor descriptor = entry.getKey(); if (descriptor.isSensitive()) { serviceProperties.put(descriptor.getName(), entry.getValue()); } } } } }
Example #21
Source File: ControllerServiceLoader.java From nifi with Apache License 2.0 | 5 votes |
private static void configureControllerService(final ControllerServiceNode node, final Element controllerServiceElement, final StringEncryptor encryptor, final FlowEncodingVersion encodingVersion) { final ControllerServiceDTO dto = FlowFromDOMFactory.getControllerService(controllerServiceElement, encryptor, encodingVersion); node.pauseValidationTrigger(); try { node.setAnnotationData(dto.getAnnotationData()); node.setProperties(dto.getProperties()); } finally { node.resumeValidationTrigger(); } }
Example #22
Source File: ControllerServiceAuditor.java From nifi with Apache License 2.0 | 5 votes |
/** * Extracts the values for the configured properties from the specified ControllerService. * * @param controllerService service * @param controllerServiceDTO dto * @return properties */ private Map<String, String> extractConfiguredPropertyValues(ControllerServiceNode controllerService, ControllerServiceDTO controllerServiceDTO) { Map<String, String> values = new HashMap<>(); if (controllerServiceDTO.getName() != null) { values.put(NAME, controllerService.getName()); } if (controllerServiceDTO.getAnnotationData() != null) { values.put(ANNOTATION_DATA, controllerService.getAnnotationData()); } if (controllerServiceDTO.getBundle() != null) { final BundleCoordinate bundle = controllerService.getBundleCoordinate(); values.put(EXTENSION_VERSION, formatExtensionVersion(controllerService.getComponentType(), bundle)); } if (controllerServiceDTO.getProperties() != null) { // for each property specified, extract its configured value final Map<String, String> properties = controllerServiceDTO.getProperties(); final Map<PropertyDescriptor, String> configuredProperties = controllerService.getRawPropertyValues(); for (String propertyName : properties.keySet()) { // build a descriptor for getting the configured value PropertyDescriptor propertyDescriptor = new PropertyDescriptor.Builder().name(propertyName).build(); String configuredPropertyValue = configuredProperties.get(propertyDescriptor); // if the configured value couldn't be found, use the default value from the actual descriptor if (configuredPropertyValue == null) { propertyDescriptor = locatePropertyDescriptor(configuredProperties.keySet(), propertyDescriptor); configuredPropertyValue = propertyDescriptor.getDefaultValue(); } values.put(propertyName, configuredPropertyValue); } } if (controllerServiceDTO.getComments() != null) { values.put(COMMENTS, controllerService.getComments()); } return values; }
Example #23
Source File: StandardControllerServiceDAO.java From nifi with Apache License 2.0 | 5 votes |
private List<String> validateProposedConfiguration(final ControllerServiceNode controllerService, final ControllerServiceDTO controllerServiceDTO) { final List<String> validationErrors = new ArrayList<>(); final Map<String, String> properties = controllerServiceDTO.getProperties(); if (isNotNull(properties)) { try { controllerService.verifyCanUpdateProperties(properties); } catch (final IllegalArgumentException | IllegalStateException iae) { validationErrors.add(iae.getMessage()); } } return validationErrors; }
Example #24
Source File: TestFlowController.java From nifi with Apache License 2.0 | 5 votes |
@Test public void testInstantiateSnippetWithControllerService() throws ProcessorInstantiationException { final String id = UUID.randomUUID().toString(); final BundleCoordinate coordinate = systemBundle.getBundleDetails().getCoordinate(); final ControllerServiceNode controllerServiceNode = controller.getFlowManager().createControllerService(ServiceA.class.getName(), id, coordinate, null, true, true); // create the controller service dto final ControllerServiceDTO csDto = new ControllerServiceDTO(); csDto.setId(UUID.randomUUID().toString()); // use a different id csDto.setParentGroupId(controllerServiceNode.getProcessGroup() == null ? null : controllerServiceNode.getProcessGroup().getIdentifier()); csDto.setName(controllerServiceNode.getName()); csDto.setType(controllerServiceNode.getCanonicalClassName()); csDto.setBundle(new BundleDTO(coordinate.getGroup(), coordinate.getId(), coordinate.getVersion())); csDto.setState(controllerServiceNode.getState().name()); csDto.setAnnotationData(controllerServiceNode.getAnnotationData()); csDto.setComments(controllerServiceNode.getComments()); csDto.setPersistsState(controllerServiceNode.getControllerServiceImplementation().getClass().isAnnotationPresent(Stateful.class)); csDto.setRestricted(controllerServiceNode.isRestricted()); csDto.setExtensionMissing(controllerServiceNode.isExtensionMissing()); csDto.setDescriptors(new LinkedHashMap<>()); csDto.setProperties(new LinkedHashMap<>()); // create the snippet with the controller service final FlowSnippetDTO flowSnippetDTO = new FlowSnippetDTO(); flowSnippetDTO.setControllerServices(Collections.singleton(csDto)); // instantiate the snippet assertEquals(0, controller.getFlowManager().getRootGroup().getControllerServices(false).size()); controller.getFlowManager().instantiateSnippet(controller.getFlowManager().getRootGroup(), flowSnippetDTO); assertEquals(1, controller.getFlowManager().getRootGroup().getControllerServices(false).size()); }
Example #25
Source File: ControllerServiceEntityMerger.java From nifi with Apache License 2.0 | 5 votes |
/** * Merges the ControllerServiceEntity responses. * * @param clientEntity the entity being returned to the client * @param entityMap all node responses */ @Override public void mergeComponents(final ControllerServiceEntity clientEntity, final Map<NodeIdentifier, ControllerServiceEntity> entityMap) { final ControllerServiceDTO clientDto = clientEntity.getComponent(); final Map<NodeIdentifier, ControllerServiceDTO> dtoMap = new HashMap<>(); for (final Map.Entry<NodeIdentifier, ControllerServiceEntity> entry : entityMap.entrySet()) { final ControllerServiceEntity nodeControllerServiceEntity = entry.getValue(); final ControllerServiceDTO nodeControllerServiceDto = nodeControllerServiceEntity.getComponent(); dtoMap.put(entry.getKey(), nodeControllerServiceDto); } mergeDtos(clientDto, dtoMap); }
Example #26
Source File: ClusterReplicationComponentLifecycle.java From nifi with Apache License 2.0 | 5 votes |
private boolean isControllerServiceValidationComplete(final Set<ControllerServiceEntity> controllerServiceEntities, final Map<String, AffectedComponentEntity> affectedComponents) { updateAffectedControllerServices(controllerServiceEntities, affectedComponents); for (final ControllerServiceEntity entity : controllerServiceEntities) { if (!affectedComponents.containsKey(entity.getId())) { continue; } if (ControllerServiceDTO.VALIDATING.equals(entity.getComponent().getValidationStatus())) { return false; } } return true; }
Example #27
Source File: ControllerServicesResult.java From nifi with Apache License 2.0 | 5 votes |
@Override protected void writeSimpleResult(final PrintStream output) throws IOException { final Set<ControllerServiceEntity> serviceEntities = controllerServicesEntity.getControllerServices(); if (serviceEntities == null) { return; } final List<ControllerServiceDTO> serviceDTOS = serviceEntities.stream() .map(s -> s.getComponent()) .collect(Collectors.toList()); Collections.sort(serviceDTOS, Comparator.comparing(ControllerServiceDTO::getName)); final Table table = new Table.Builder() .column("#", 3, 3, false) .column("Name", 5, 40, false) .column("ID", 36, 36, false) .column("State", 5, 40, false) .build(); for (int i=0; i < serviceDTOS.size(); i++) { final ControllerServiceDTO serviceDTO = serviceDTOS.get(i); table.addRow(String.valueOf(i+1), serviceDTO.getName(), serviceDTO.getId(), serviceDTO.getState()); } final TableWriter tableWriter = new DynamicTableWriter(); tableWriter.write(table, output); }
Example #28
Source File: ControllerServiceResult.java From nifi with Apache License 2.0 | 5 votes |
@Override protected void writeSimpleResult(PrintStream output) throws IOException { final ControllerServiceDTO controllerServiceDTO = controllerServiceEntity.getComponent(); final BundleDTO bundle = controllerServiceDTO.getBundle(); output.printf("Name : %s\nID : %s\nType : %s\nBundle: %s - %s %s\nState : %s\n", controllerServiceDTO.getName(), controllerServiceDTO.getId(), controllerServiceDTO.getType(), bundle.getGroup(), bundle.getArtifact(), bundle.getVersion(), controllerServiceDTO.getState()); }
Example #29
Source File: StandardNiFiWebConfigurationContext.java From nifi with Apache License 2.0 | 5 votes |
private ComponentDetails getComponentConfiguration(final ControllerServiceDTO controllerService) { return new ComponentDetails.Builder() .id(controllerService.getId()) .name(controllerService.getName()) .type(controllerService.getType()) .state(controllerService.getState()) .annotationData(controllerService.getAnnotationData()) .properties(controllerService.getProperties()) .validateErrors(controllerService.getValidationErrors()).build(); }
Example #30
Source File: TestFlowController.java From nifi with Apache License 2.0 | 5 votes |
@Test(expected = IllegalArgumentException.class) public void testInstantiateSnippetWhenControllerServiceMissingBundle() throws ProcessorInstantiationException { final String id = UUID.randomUUID().toString(); final BundleCoordinate coordinate = systemBundle.getBundleDetails().getCoordinate(); final ControllerServiceNode controllerServiceNode = controller.getFlowManager().createControllerService(ServiceA.class.getName(), id, coordinate, null, true, true); // create the controller service dto final ControllerServiceDTO csDto = new ControllerServiceDTO(); csDto.setId(UUID.randomUUID().toString()); // use a different id csDto.setParentGroupId(controllerServiceNode.getProcessGroup() == null ? null : controllerServiceNode.getProcessGroup().getIdentifier()); csDto.setName(controllerServiceNode.getName()); csDto.setType(controllerServiceNode.getCanonicalClassName()); csDto.setBundle(null); // missing bundle csDto.setState(controllerServiceNode.getState().name()); csDto.setAnnotationData(controllerServiceNode.getAnnotationData()); csDto.setComments(controllerServiceNode.getComments()); csDto.setPersistsState(controllerServiceNode.getControllerServiceImplementation().getClass().isAnnotationPresent(Stateful.class)); csDto.setRestricted(controllerServiceNode.isRestricted()); csDto.setExtensionMissing(controllerServiceNode.isExtensionMissing()); csDto.setDescriptors(new LinkedHashMap<>()); csDto.setProperties(new LinkedHashMap<>()); // create the snippet with the controller service final FlowSnippetDTO flowSnippetDTO = new FlowSnippetDTO(); flowSnippetDTO.setControllerServices(Collections.singleton(csDto)); // instantiate the snippet assertEquals(0, controller.getFlowManager().getRootGroup().getControllerServices(false).size()); controller.getFlowManager().instantiateSnippet(controller.getFlowManager().getRootGroup(), flowSnippetDTO); }