[GitHub] nifi-minifi-cpp pull request #90: MINIFI-294 Required vs. optional fields in...
Github user asfgit closed the pull request at: https://github.com/apache/nifi-minifi-cpp/pull/90 --- If your project is set up for it, you can reply to this email and have your reply appear on GitHub as well. If your project does not have this feature enabled and wishes so, or if the feature is enabled but not working, please contact infrastructure at infrastruct...@apache.org or file a JIRA ticket with INFRA. ---
[GitHub] nifi-minifi-cpp pull request #90: MINIFI-294 Required vs. optional fields in...
Github user kevdoran commented on a diff in the pull request: https://github.com/apache/nifi-minifi-cpp/pull/90#discussion_r114787540 --- Diff: libminifi/src/core/yaml/YamlConfiguration.cpp --- @@ -417,29 +405,27 @@ void YamlConfiguration::parseConnectionYaml( // Configure connection source -auto rawRelationship = connectionNode["source relationship name"] -.as(); +checkRequiredField(&connectionNode, "source relationship name", CONFIG_YAML_CONNECTIONS_KEY); +auto rawRelationship = connectionNode["source relationship name"].as(); 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(); + if (connectionNode["source id"]) { - std::string connectionSrcProcId = connectionNode["source id"] - .as(); + std::string connectionSrcProcId = connectionNode["source id"].as(); 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 -- @phrocker I added a commit with some helpful debug log output. Let me know if you have any other suggestions, thanks! --- If your project is set up for it, you can reply to this email and have your reply appear on GitHub as well. If your project does not have this feature enabled and wishes so, or if the feature is enabled but not working, please contact infrastructure at infrastruct...@apache.org or file a JIRA ticket with INFRA. ---
[GitHub] nifi-minifi-cpp pull request #90: MINIFI-294 Required vs. optional fields in...
Github user kevdoran commented on a diff in the pull request: https://github.com/apache/nifi-minifi-cpp/pull/90#discussion_r114773178 --- Diff: libminifi/src/core/yaml/YamlConfiguration.cpp --- @@ -417,29 +405,27 @@ void YamlConfiguration::parseConnectionYaml( // Configure connection source -auto rawRelationship = connectionNode["source relationship name"] -.as(); +checkRequiredField(&connectionNode, "source relationship name", CONFIG_YAML_CONNECTIONS_KEY); +auto rawRelationship = connectionNode["source relationship name"].as(); 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(); + if (connectionNode["source id"]) { - std::string connectionSrcProcId = connectionNode["source id"] - .as(); + std::string connectionSrcProcId = connectionNode["source id"].as(); 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 -- Good idea. I will add some debug output regarding how the source and destination processors are resolved. I could see there being some confusion if, for instance, both name and id fields are provided. --- If your project is set up for it, you can reply to this email and have your reply appear on GitHub as well. If your project does not have this feature enabled and wishes so, or if the feature is enabled but not working, please contact infrastructure at infrastruct...@apache.org or file a JIRA ticket with INFRA. ---
[GitHub] nifi-minifi-cpp pull request #90: MINIFI-294 Required vs. optional fields in...
Github user phrocker commented on a diff in the pull request: https://github.com/apache/nifi-minifi-cpp/pull/90#discussion_r114745591 --- Diff: libminifi/src/core/yaml/YamlConfiguration.cpp --- @@ -417,29 +405,27 @@ void YamlConfiguration::parseConnectionYaml( // Configure connection source -auto rawRelationship = connectionNode["source relationship name"] -.as(); +checkRequiredField(&connectionNode, "source relationship name", CONFIG_YAML_CONNECTIONS_KEY); +auto rawRelationship = connectionNode["source relationship name"].as(); 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(); + if (connectionNode["source id"]) { - std::string connectionSrcProcId = connectionNode["source id"] - .as(); + std::string connectionSrcProcId = connectionNode["source id"].as(); 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 -- @kevdoran I like that you documented your assumption. Could you augment that comment with a log message affirming the decision of the code so that we could better debug "how and why?" --- If your project is set up for it, you can reply to this email and have your reply appear on GitHub as well. If your project does not have this feature enabled and wishes so, or if the feature is enabled but not working, please contact infrastructure at infrastruct...@apache.org or file a JIRA ticket with INFRA. ---
[GitHub] nifi-minifi-cpp pull request #90: MINIFI-294 Required vs. optional fields in...
Github user benqiu2016 commented on a diff in the pull request: https://github.com/apache/nifi-minifi-cpp/pull/90#discussion_r114691577 --- Diff: libminifi/src/core/yaml/YamlConfiguration.cpp --- @@ -417,29 +405,27 @@ void YamlConfiguration::parseConnectionYaml( // Configure connection source -auto rawRelationship = connectionNode["source relationship name"] -.as(); +checkRequiredField(&connectionNode, "source relationship name", CONFIG_YAML_CONNECTIONS_KEY); +auto rawRelationship = connectionNode["source relationship name"].as(); 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(); + if (connectionNode["source id"]) { - std::string connectionSrcProcId = connectionNode["source id"] - .as(); + std::string connectionSrcProcId = connectionNode["source id"].as(); 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 -- does it mean that if process UUID is not config, we need to try to find processor by name? in this case, we do not need to do uuid_parse and parent->findProcessor is by name instead of UUID. please double check with Aldrin. --- If your project is set up for it, you can reply to this email and have your reply appear on GitHub as well. If your project does not have this feature enabled and wishes so, or if the feature is enabled but not working, please contact infrastructure at infrastruct...@apache.org or file a JIRA ticket with INFRA. ---
[GitHub] nifi-minifi-cpp pull request #90: MINIFI-294 Required vs. optional fields in...
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(); +checkRequiredField(&connectionNode, "source relationship name", CONFIG_YAML_CONNECTIONS_KEY); +auto rawRelationship = connectionNode["source relationship name"].as(); 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(); + if (connectionNode["source id"]) { - std::string connectionSrcProcId = connectionNode["source id"] - .as(); + std::string connectionSrcProcId = connectionNode["source id"].as(); 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 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 --- If your project is set up for it, you can reply to this email and have your reply appear on GitHub as well. If your project does not have this feature enabled and wishes so, or if the feature is enabled but not working, please contact infrastructure at infrastruct...@apache.org or file a JIRA ticket with INFRA. ---
[GitHub] nifi-minifi-cpp pull request #90: MINIFI-294 Required vs. optional fields in...
Github user benqiu2016 commented on a diff in the pull request: https://github.com/apache/nifi-minifi-cpp/pull/90#discussion_r114679611 --- Diff: libminifi/src/core/yaml/YamlConfiguration.cpp --- @@ -450,27 +436,24 @@ void YamlConfiguration::parseConnectionYaml( } else { // we ran out of ways to discover the source processor logger_->log_error( - "Could not locate a source with name %s to create a connection", - connectionSrcProcName); + "Could not locate a source with name %s to create a connection", connectionSrcProcName); throw std::invalid_argument( - "Could not locate a source with name " + - connectionSrcProcName + " to create a connection "); + "Could not locate a source with name " + connectionSrcProcName + " to create a connection "); } } } connection->setSourceUUID(srcUUID); // Configure connection destination uuid_t destUUID; -std::string connectionDestProcName = connectionNode["destination name"] -.as(); if (connectionNode["destination id"]) { - std::string connectionDestProcId = connectionNode["destination id"] - .as(); + std::string connectionDestProcId = connectionNode["destination id"].as(); uuid_parse(connectionDestProcId.c_str(), destUUID); } else { // we use the same logic as above for resolving the source processor // for looking up the destination processor in absence of a processor id + checkRequiredField(&connectionNode, "destination name", CONFIG_YAML_CONNECTIONS_KEY); --- End diff -- same as above. --- If your project is set up for it, you can reply to this email and have your reply appear on GitHub as well. If your project does not have this feature enabled and wishes so, or if the feature is enabled but not working, please contact infrastructure at infrastruct...@apache.org or file a JIRA ticket with INFRA. ---
[GitHub] nifi-minifi-cpp pull request #90: MINIFI-294 Required vs. optional fields in...
Github user benqiu2016 commented on a diff in the pull request: https://github.com/apache/nifi-minifi-cpp/pull/90#discussion_r114679460 --- Diff: libminifi/src/core/yaml/YamlConfiguration.cpp --- @@ -417,29 +405,27 @@ void YamlConfiguration::parseConnectionYaml( // Configure connection source -auto rawRelationship = connectionNode["source relationship name"] -.as(); +checkRequiredField(&connectionNode, "source relationship name", CONFIG_YAML_CONNECTIONS_KEY); +auto rawRelationship = connectionNode["source relationship name"].as(); 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(); + if (connectionNode["source id"]) { - std::string connectionSrcProcId = connectionNode["source id"] - .as(); + std::string connectionSrcProcId = connectionNode["source id"].as(); 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 -- i thought we only use source id instead of source name. source id is the process UUID for the connection source --- If your project is set up for it, you can reply to this email and have your reply appear on GitHub as well. If your project does not have this feature enabled and wishes so, or if the feature is enabled but not working, please contact infrastructure at infrastruct...@apache.org or file a JIRA ticket with INFRA. ---
[GitHub] nifi-minifi-cpp pull request #90: MINIFI-294 Required vs. optional fields in...
GitHub user kevdoran opened a pull request: https://github.com/apache/nifi-minifi-cpp/pull/90 MINIFI-294 Required vs. optional fields in config YAML Long description of the changes in this commit can be found in the JIRA for MINFI-294. Basically, better checks are now in place and in the case of missing required fields, better error messaging. This builds upon improvements made in MINIFI-275, and also updates the config.yml exampe in the README.md file to match the code. Thank you for submitting a contribution to Apache NiFi - MiNiFi C++. In order to streamline the review of the contribution we ask you to ensure the following steps have been taken: ### For all changes: - [ ] Is there a JIRA ticket associated with this PR? Is it referenced in the commit message? - [ ] Does your PR title start with MINIFI- where is the JIRA number you are trying to resolve? Pay particular attention to the hyphen "-" character. - [ ] Has your PR been rebased against the latest commit within the target branch (typically master)? - [ ] Is your initial contribution a single, squashed commit? ### For code changes: - [ ] If adding new dependencies to the code, are these dependencies licensed in a way that is compatible for inclusion under [ASF 2.0](http://www.apache.org/legal/resolved.html#category-a)? - [ ] If applicable, have you updated the LICENSE file? - [ ] If applicable, have you updated the NOTICE file? ### For documentation related changes: - [ ] Have you ensured that format looks appropriate for the output in which it is rendered? ### Note: Please ensure that once the PR is submitted, you check travis-ci for build issues and submit an update to your PR as soon as possible. You can merge this pull request into a Git repository by running: $ git pull https://github.com/kevdoran/nifi-minifi-cpp MINIFI-294-config-schema-v1-enhancements Alternatively you can review and apply these changes as the patch at: https://github.com/apache/nifi-minifi-cpp/pull/90.patch To close this pull request, make a commit to your master/trunk branch with (at least) the following in the commit message: This closes #90 commit 080679e127409bbbd2662168dc740f5c00165a8b Author: Kevin Doran Date: 2017-05-03T22:22:14Z MINIFI-294 Required vs. optional fields in config YAML Long description of the changes in this commit can be found in the JIRA for MINFI-294. Basically, better checks are now in place and in the case of missing required fields, better error messaging. This builds upon improvements made in MINIFI-275, and also updates the config.yml exampe in the README.md file to match the code. --- If your project is set up for it, you can reply to this email and have your reply appear on GitHub as well. If your project does not have this feature enabled and wishes so, or if the feature is enabled but not working, please contact infrastructure at infrastruct...@apache.org or file a JIRA ticket with INFRA. ---