nifi-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "ASF GitHub Bot (JIRA)" <j...@apache.org>
Subject [jira] [Commented] (MINIFI-294) Better handling of required vs. optional fields in config schema v1
Date Thu, 04 May 2017 00:52:04 GMT

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

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

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

    https://github.com/apache/nifi-minifi-cpp/pull/90#discussion_r114684796
  
    --- Diff: libminifi/src/core/yaml/YamlConfiguration.cpp ---
    @@ -417,29 +405,27 @@ void YamlConfiguration::parseConnectionYaml(
     
     
             // Configure connection source
    -        auto rawRelationship = connectionNode["source relationship name"]
    -            .as<std::string>();
    +        checkRequiredField(&connectionNode, "source relationship name", CONFIG_YAML_CONNECTIONS_KEY);
    +        auto rawRelationship = connectionNode["source relationship name"].as<std::string>();
             core::Relationship relationship(rawRelationship, "");
    -        logger_->log_debug(
    -            "parseConnection: relationship => [%s]", rawRelationship);
    +        logger_->log_debug("parseConnection: relationship => [%s]", rawRelationship);
             if (connection) {
               connection->setRelationship(relationship);
             }
     
             uuid_t srcUUID;
    -        std::string connectionSrcProcName = connectionNode["source name"]
    -            .as<std::string>();
    +
             if (connectionNode["source id"]) {
    -          std::string connectionSrcProcId = connectionNode["source id"]
    -              .as<std::string>();
    +          std::string connectionSrcProcId = connectionNode["source id"].as<std::string>();
     
               uuid_parse(connectionSrcProcId.c_str(), srcUUID);
             } else {
               // if we don't have a source id, try harder to resolve the source processor.
               // config schema v2 will make this unnecessary
    +          checkRequiredField(&connectionNode, "source name", CONFIG_YAML_CONNECTIONS_KEY);
    --- End diff --
    
    If source id is present, yes. If id not present, there are two possible fallbacks that
rely on the "source name" field. I used the Java implementation as a guide: 
    
    From org.apache.nifi.minifi.commons.schema.v1.ConfigSchemaV1.java [1]
    ```
    List<ConnectionSchema> connectionSchemas = new ArrayList<>(connections.size());
            for (ConnectionSchemaV1 connection : connections) {
                ConnectionSchema convert = connection.convert();
                convert.setId(getUniqueId(ids, convert.getName()));
    
                String sourceName = connection.getSourceName();
                if (remoteInputPortIds.contains(sourceName)) {
                    convert.setSourceId(sourceName);
                } else {
                    if (duplicateProcessorNames.contains(sourceName)) {
                        problematicDuplicateNames.add(sourceName);
                    }
                    String sourceId = processorNameToIdMap.get(sourceName);
                    if (!StringUtil.isNullOrEmpty(sourceId)) {
                        convert.setSourceId(sourceId);
                    }
                }
    
                String destinationName = connection.getDestinationName();
                if (remoteInputPortIds.contains(destinationName)) {
                    convert.setDestinationId(destinationName);
                } else {
                    if (duplicateProcessorNames.contains(destinationName)) {
                        problematicDuplicateNames.add(destinationName);
                    }
                    String destinationId = processorNameToIdMap.get(destinationName);
                    if (!StringUtil.isNullOrEmpty(destinationId)) {
                        convert.setDestinationId(destinationId);
                    }
                }
                connectionSchemas.add(convert);
            }
    ```
    
    [1] https://github.com/apache/nifi-minifi/blob/master/minifi-commons/minifi-commons-schema/src/main/java/org/apache/nifi/minifi/commons/schema/v1/ConfigSchemaV1.java


> Better handling of required vs. optional fields in config schema v1
> -------------------------------------------------------------------
>
>                 Key: MINIFI-294
>                 URL: https://issues.apache.org/jira/browse/MINIFI-294
>             Project: Apache NiFi MiNiFi
>          Issue Type: Bug
>          Components: C++, Documentation, Processing Configuration
>            Reporter: Kevin Doran
>            Assignee: Kevin Doran
>            Priority: Critical
>             Fix For: cpp-0.2.0
>
>
> This is a followup task to MINIFI-275. While the scope of MINIFI-275 was minifi-cpp processing
of components without id fields, which are optional in config schema v1, this ticket covers
all fields for all component types, either doing string checks for required fields (with useful
error messages if absent) or graceful handling of missing optional fields.
> The Config Schema V1 in the minifi-java codebase will be used as a guide for which fields
to treat as required and which to treat as optional. [~aldrin] - please confirm that is the
correct assumption for minifi-cpp. The Java implementation can be found at [1]. Specifically,
in the Java code, required fields are loaded using `getRequiredKeyAsType() and optional fields
are loaded using `getOptionalKeyAsType()`
> Also in scope for this ticket is to update the config.yml examples in the minifi-cpp
README.md file to make sure they are not missing required fields. During testing, it was found
that one example config.yml is missing source name and destination name, which are required
in config schema v1.
> [1] https://github.com/apache/nifi-minifi/tree/master/minifi-commons/minifi-commons-schema/src/main/java/org/apache/nifi/minifi/commons/schema/v1



--
This message was sent by Atlassian JIRA
(v6.3.15#6346)

Mime
View raw message