You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@nifi.apache.org by GitBox <gi...@apache.org> on 2021/08/03 08:45:27 UTC

[GitHub] [nifi-minifi-cpp] fgerlits commented on a change in pull request #1132: MINIFICPP-1603 Support Funnels element in flow definition

fgerlits commented on a change in pull request #1132:
URL: https://github.com/apache/nifi-minifi-cpp/pull/1132#discussion_r681548615



##########
File path: docker/test/integration/minifi/flow_serialization/Minifi_flow_yaml_serializer.py
##########
@@ -92,21 +108,22 @@ def serialize(self, connectable, root=None, visited=None):
                     res['Connections'].append({
                         'name': str(uuid.uuid4()),
                         'source id': str(connectable.uuid),
-                        'source relationship name': conn_name,
                         'destination id': str(proc.uuid),
                         'drop empty': ("true" if proc.drop_empty_flowfiles else "false")

Review comment:
       Not related to this change, but do you know why `drop empty` is not included in the other (single-outgoing-connection) case?  That seems to be the only difference in the two blocks, without this, the duplication could be removed.

##########
File path: libminifi/src/core/yaml/YamlConfiguration.cpp
##########
@@ -805,6 +806,36 @@ void YamlConfiguration::parsePropertiesNodeYaml(const YAML::Node& propertiesNode
   validateComponentProperties(processor, component_name, yaml_section);
 }
 
+void YamlConfiguration::parseFunnelsYaml(const YAML::Node& node, core::ProcessGroup* parent) {
+  if (!parent) {
+    logger_->log_error("parseFunnelsYaml: no parent group was provided");
+    return;
+  }
+  if (!node || !node.IsSequence()) {
+    return;
+  }
+
+  for (const auto& element : node) {
+    YAML::Node funnel_node = element.as<YAML::Node>();
+
+    std::string id = getOrGenerateId(funnel_node);
+
+    // Default name to be same as ID
+    std::string name = funnel_node["name"].as<std::string>(id);
+
+    const utils::optional<utils::Identifier> uuid = utils::Identifier::parse(id) | utils::orElse([this] {
+      logger_->log_debug("Incorrect connection UUID format.");
+      throw Exception(ExceptionType::GENERAL_EXCEPTION, "Incorrect connection UUID format.");

Review comment:
       both of these should be "Incorrect funnel UUID format."

##########
File path: libminifi/src/core/yaml/YamlConnectionParser.cpp
##########
@@ -29,24 +29,48 @@ namespace yaml {
 // This is no longer needed in c++17
 constexpr const char* YamlConnectionParser::CONFIG_YAML_CONNECTIONS_KEY;
 
+void YamlConnectionParser::addNewRelationshipToConnection(const std::string& relationship_name, const std::shared_ptr<minifi::Connection>& connection) const {
+  core::Relationship relationship(relationship_name, "");
+  logger_->log_debug("parseConnection: relationship => [%s]", relationship_name);
+  connection->addRelationship(std::move(relationship));
+}
+
+void YamlConnectionParser::addFunnelRelationshipToConnection(const std::shared_ptr<minifi::Connection>& connection) const {
+  utils::Identifier srcUUID;
+  try {
+    srcUUID = getSourceUUIDFromYaml();
+  } catch(const std::exception&) {
+    return;

Review comment:
       should we log an error here?

##########
File path: libminifi/src/core/yaml/YamlConnectionParser.cpp
##########
@@ -29,24 +29,48 @@ namespace yaml {
 // This is no longer needed in c++17
 constexpr const char* YamlConnectionParser::CONFIG_YAML_CONNECTIONS_KEY;
 
+void YamlConnectionParser::addNewRelationshipToConnection(const std::string& relationship_name, const std::shared_ptr<minifi::Connection>& connection) const {
+  core::Relationship relationship(relationship_name, "");
+  logger_->log_debug("parseConnection: relationship => [%s]", relationship_name);
+  connection->addRelationship(std::move(relationship));
+}
+
+void YamlConnectionParser::addFunnelRelationshipToConnection(const std::shared_ptr<minifi::Connection>& connection) const {
+  utils::Identifier srcUUID;
+  try {
+    srcUUID = getSourceUUIDFromYaml();
+  } catch(const std::exception&) {
+    return;
+  }
+  auto processor = parent_->findProcessorById(srcUUID);
+  if (!processor) {
+    logger_->log_error("Could not find processor with id %s", srcUUID.to_string());
+    return;
+  }
+
+  auto& processor_ref = *processor.get();
+  if (typeid(minifi::core::Funnel) == typeid(processor_ref)) {
+    addNewRelationshipToConnection(minifi::core::Funnel::Success.getName(), connection);
+  }

Review comment:
       it could be useful to add an else branch with an error log here, too




-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: issues-unsubscribe@nifi.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org