private static boolean isEmpty(final ControllerServiceDTO controllerServiceDTO){ return controllerServiceDTO == null || StringUtils.isEmpty(controllerServiceDTO.getName()); }
@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("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.getState()); } final TableWriter tableWriter = new DynamicTableWriter(); tableWriter.write(table, output); }
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()); }
Map<String, String> values = new HashMap<>(); if (controllerServiceDTO.getName() != null) { values.put(NAME, controllerService.getName());
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(); } }
rollbackClonedPolicy(ResourceFactory.getComponentResource(ResourceType.ControllerService, controllerServiceDTO.getId(), controllerServiceDTO.getName())); }); snippet.getFunnels().forEach(funnelDTO -> {
private void printServicesNotEnabled(final FlowClient flowClient, final String pgId) throws NiFiClientException, IOException { final ControllerServicesEntity servicesEntity = flowClient.getControllerServices(pgId); if (servicesEntity == null || servicesEntity.getControllerServices() == null) { return; } println(); println("The following services could not be enabled: "); for (final ControllerServiceEntity serviceEntity : servicesEntity.getControllerServices()) { if (!ControllerServiceStates.STATE_ENABLED.equals(serviceEntity.getComponent().getState())) { println(); println("Service: " + serviceEntity.getId() + " - " + serviceEntity.getComponent().getName()); final ControllerServiceDTO serviceDTO = serviceEntity.getComponent(); if (serviceDTO.getValidationErrors() != null) { println(); println("Validation Errors: "); for (final String validationError : serviceDTO.getValidationErrors()) { println("- " + validationError); } } } } }
private static ControllerServiceNode createControllerService(final FlowController flowController, final Element controllerServiceElement, final StringEncryptor encryptor) { final ControllerServiceDTO dto = FlowFromDOMFactory.getControllerService(controllerServiceElement, encryptor); 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; }
private void printServicesStillEnabling(final FlowClient flowClient, final String pgId) throws NiFiClientException, IOException { final ControllerServicesEntity servicesEntity = flowClient.getControllerServices(pgId); if (servicesEntity == null || servicesEntity.getControllerServices() == null) { return; } println(); println("One or more services appear to be stuck enabling: "); for (final ControllerServiceEntity serviceEntity : servicesEntity.getControllerServices()) { if (ControllerServiceStates.STATE_ENABLING.equals(serviceEntity.getComponent().getState())) { println(); println("Service: " + serviceEntity.getId() + " - " + serviceEntity.getComponent().getName()); if (serviceEntity.getBulletins() != null) { println(); println("Reasons: "); for (final BulletinEntity bulletinEntity : serviceEntity.getBulletins()) { println("- " + bulletinEntity.getBulletin().getMessage()); } } } } }
private void printServicesStillDisabling(final FlowClient flowClient, final String pgId) throws NiFiClientException, IOException { final ControllerServicesEntity servicesEntity = flowClient.getControllerServices(pgId); if (servicesEntity == null || servicesEntity.getControllerServices() == null) { return; } println(); println("One or more services appear to be stuck disabling: "); for (final ControllerServiceEntity serviceEntity : servicesEntity.getControllerServices()) { if (ControllerServiceStates.STATE_DISABLING.equals(serviceEntity.getComponent().getState())) { println(); println("Service: " + serviceEntity.getId() + " - " + serviceEntity.getComponent().getName()); if (serviceEntity.getBulletins() != null) { println(); println("Reasons: "); for (final BulletinEntity bulletinEntity : serviceEntity.getBulletins()) { println("- " + bulletinEntity.getBulletin().getMessage()); } } } } }
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(); } }
if (isAnyNotNull(controllerServiceDTO.getName(), controllerServiceDTO.getAnnotationData(), controllerServiceDTO.getComments(),
public AffectedComponentEntity createAffectedComponentEntity(final ControllerServiceEntity serviceEntity) { if (serviceEntity == null) { return null; } final AffectedComponentEntity component = new AffectedComponentEntity(); component.setBulletins(serviceEntity.getBulletins()); component.setId(serviceEntity.getId()); component.setPermissions(serviceEntity.getPermissions()); component.setPosition(serviceEntity.getPosition()); component.setRevision(serviceEntity.getRevision()); component.setUri(serviceEntity.getUri()); final ControllerServiceDTO serviceDto = serviceEntity.getComponent(); final AffectedComponentDTO componentDto = new AffectedComponentDTO(); componentDto.setId(serviceDto.getId()); componentDto.setName(serviceDto.getName()); componentDto.setProcessGroupId(serviceDto.getParentGroupId()); componentDto.setReferenceType(AffectedComponentDTO.COMPONENT_TYPE_CONTROLLER_SERVICE); componentDto.setState(serviceDto.getState()); componentDto.setValidationErrors(serviceDto.getValidationErrors()); component.setComponent(componentDto); return component; }
public ControllerServiceDTO copy(final ControllerServiceDTO original) { final ControllerServiceDTO copy = new ControllerServiceDTO(); copy.setAnnotationData(original.getAnnotationData()); copy.setControllerServiceApis(original.getControllerServiceApis()); copy.setComments(original.getComments()); copy.setCustomUiUrl(original.getCustomUiUrl()); copy.setDescriptors(copy(original.getDescriptors())); copy.setId(original.getId()); copy.setParentGroupId(original.getParentGroupId()); copy.setName(original.getName()); copy.setProperties(copy(original.getProperties())); copy.setReferencingComponents(copy(original.getReferencingComponents())); copy.setState(original.getState()); copy.setType(original.getType()); copy.setBundle(copy(original.getBundle())); copy.setExtensionMissing(original.getExtensionMissing()); copy.setMultipleVersionsAvailable(original.getMultipleVersionsAvailable()); copy.setPersistsState(original.getPersistsState()); copy.setValidationErrors(copy(original.getValidationErrors())); copy.setValidationStatus(original.getValidationStatus()); copy.setVersionedComponentId(original.getVersionedComponentId()); return copy; }
serviceNode.setName(controllerServiceDTO.getName()); if (!topLevel) { serviceNode.setVersionedComponentId(controllerServiceDTO.getVersionedComponentId());
@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); } }
@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); } }