[ 
https://issues.apache.org/jira/browse/MINIFI-117?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=15596057#comment-15596057
 ] 

ASF GitHub Bot commented on MINIFI-117:
---------------------------------------

Github user JPercivall commented on a diff in the pull request:

    https://github.com/apache/nifi-minifi/pull/45#discussion_r84527193
  
    --- Diff: 
minifi-commons/minifi-commons-schema/src/main/java/org/apache/nifi/minifi/commons/schema/ConfigSchema.java
 ---
    @@ -142,128 +125,10 @@ public ConfigSchema(Map map) {
             }
         }
     
    -    protected List<ProcessorSchema> getProcessorSchemas(List<Map> 
processorMaps) {
    -        if (processorMaps == null) {
    -            return null;
    -        }
    -        List<ProcessorSchema> processors = 
convertListToType(processorMaps, "processor", ProcessorSchema.class, 
PROCESSORS_KEY);
    -
    -        Map<String, Integer> idMap = 
processors.stream().map(ProcessorSchema::getId).filter(
    -                s -> 
!StringUtil.isNullOrEmpty(s)).collect(Collectors.toMap(Function.identity(), s 
-> 2, Integer::compareTo));
    -
    -        // Set unset ids
    -        processors.stream().filter(connection -> 
StringUtil.isNullOrEmpty(connection.getId())).forEachOrdered(processor -> 
processor.setId(getUniqueId(idMap, processor.getName())));
    -
    -        return processors;
    -    }
    -
    -    protected List<ConnectionSchema> getConnectionSchemas(List<Map> 
connectionMaps) {
    -        if (connectionMaps == null) {
    -            return null;
    -        }
    -        List<ConnectionSchema> connections = 
convertListToType(connectionMaps, "connection", ConnectionSchema.class, 
CONNECTIONS_KEY);
    -        Map<String, Integer> idMap = 
connections.stream().map(ConnectionSchema::getId).filter(
    -                s -> 
!StringUtil.isNullOrEmpty(s)).collect(Collectors.toMap(Function.identity(), s 
-> 2, Integer::compareTo));
    -
    -        Map<String, String> processorNameToIdMap = new HashMap<>();
    -
    -        // We can't look up id by name for names that appear more than once
    -        Set<String> duplicateProcessorNames = new HashSet<>();
    -
    -        List<ProcessorSchema> processors = getProcessors();
    -        if (processors != null) {
    -            processors.stream().forEachOrdered(p -> 
processorNameToIdMap.put(p.getName(), p.getId()));
    -
    -            Set<String> processorNames = new HashSet<>();
    -            
processors.stream().map(ProcessorSchema::getName).forEachOrdered(n -> {
    -                if (!processorNames.add(n)) {
    -                    duplicateProcessorNames.add(n);
    -                }
    -            });
    -        }
    -
    -        Set<String> remoteInputPortIds = new HashSet<>();
    -        List<RemoteProcessingGroupSchema> remoteProcessingGroups = 
getRemoteProcessingGroups();
    -        if (remoteProcessingGroups != null) {
    -            
remoteInputPortIds.addAll(remoteProcessingGroups.stream().filter(r -> 
r.getInputPorts() != null)
    -                    .flatMap(r -> 
r.getInputPorts().stream()).map(RemoteInputPortSchema::getId).collect(Collectors.toSet()));
    -        }
    -
    -        Set<String> problematicDuplicateNames = new HashSet<>();
    -        Set<String> missingProcessorNames = new HashSet<>();
    -        // Set unset ids
    -        connections.stream().filter(connection -> 
StringUtil.isNullOrEmpty(connection.getId())).forEachOrdered(connection -> 
connection.setId(getUniqueId(idMap, connection.getName())));
    -
    -        connections.stream().filter(connection -> 
StringUtil.isNullOrEmpty(connection.getSourceId())).forEach(connection -> {
    -            String sourceName = connection.getSourceName();
    -            if (remoteInputPortIds.contains(sourceName)) {
    -                connection.setSourceId(sourceName);
    -            } else {
    -                if (duplicateProcessorNames.contains(sourceName)) {
    -                    problematicDuplicateNames.add(sourceName);
    -                }
    -                String sourceId = processorNameToIdMap.get(sourceName);
    -                if (StringUtil.isNullOrEmpty(sourceId)) {
    -                    missingProcessorNames.add(sourceName);
    -                } else {
    -                    connection.setSourceId(sourceId);
    -                }
    -            }
    -        });
    -
    -        connections.stream().filter(connection -> 
StringUtil.isNullOrEmpty(connection.getDestinationId()))
    -                .forEach(connection -> {
    -                    String destinationName = 
connection.getDestinationName();
    -                    if (remoteInputPortIds.contains(destinationName)) {
    -                        connection.setDestinationId(destinationName);
    -                    } else {
    -                        if 
(duplicateProcessorNames.contains(destinationName)) {
    -                            problematicDuplicateNames.add(destinationName);
    -                        }
    -                        String destinationId = 
processorNameToIdMap.get(destinationName);
    -                        if (StringUtil.isNullOrEmpty(destinationId)) {
    -                            missingProcessorNames.add(destinationName);
    -                        } else {
    -                            connection.setDestinationId(destinationId);
    -                        }
    -                    }
    -                });
    -
    -        if (problematicDuplicateNames.size() > 0) {
    -            
addValidationIssue(CANNOT_LOOK_UP_PROCESSOR_ID_FROM_PROCESSOR_NAME_DUE_TO_DUPLICATE_PROCESSOR_NAMES
    -                    + 
problematicDuplicateNames.stream().collect(Collectors.joining(", ")));
    -        }
    -        if (missingProcessorNames.size() > 0) {
    -            
addValidationIssue(CONNECTIONS_REFER_TO_PROCESSOR_NAMES_THAT_DONT_EXIST + 
missingProcessorNames.stream().sorted().collect(Collectors.joining(", ")));
    --- End diff --
    
    I believe this and the above check were accidentally removed (this one 
should be "Id" instead of "name") when moving to the lambda functions.


> Maintainable Configuration Versioning
> -------------------------------------
>
>                 Key: MINIFI-117
>                 URL: https://issues.apache.org/jira/browse/MINIFI-117
>             Project: Apache NiFi MiNiFi
>          Issue Type: Bug
>            Reporter: Bryan Rosander
>            Assignee: Bryan Rosander
>
> In order to avoid a tangled web of if/else statements around every possible 
> permutation of config.yml and an equally complicated validation routine, we 
> need to utilize a versioning strategy that allows for specific parsing and 
> validation code for each version of the ConfigSchema.
> This will allow us to determine if a schema will be compatible with an older 
> MiNiFi instance more easily by validating the structure of the file at a 
> given version while still supporting an upconvert on read to the latest 
> ConfigSchema while parsing at runtime.
> It should also facilitate a deprecation strategy of removing older versions' 
> classes without needing to touch current implementation



--
This message was sent by Atlassian JIRA
(v6.3.4#6332)

Reply via email to