lordgamez commented on code in PR #2296:
URL: https://github.com/apache/nifi-minifi-cpp/pull/2296#discussion_r4668497120


##########
libminifi/src/core/ProcessGroup.cpp:
##########
@@ -478,10 +480,52 @@ std::size_t ProcessGroup::getTotalFlowFileCount() const {
   return sum;
 }
 
+void ProcessGroup::verifyRelationshipTerminations() const {
+  std::map<std::string, Connection*> connections;
+  getConnections(connections);
+  std::set<std::pair<const Connectable*, std::string>> 
terminated_relationships;
+  for (const auto& [_, connection] : connections) {
+    for (const auto& relationship : connection->getRelationships()) {
+      terminated_relationships.emplace(connection->getSource(), 
relationship.getName());
+    }
+  }
+
+  std::vector<Processor*> processors;
+  getAllProcessors(processors);
+
+  std::vector<std::pair<std::string, std::string>> unterminated_relationships;
+  for (auto* processor : processors) {
+    // RPG input ports (SEND direction) only send their incoming flow files to 
the remote instance and never transfer to a local relationship,
+    // while RPG output ports (RECEIVE direction) transfer the received flow 
files to their relationship, so those are still verified
+    if (auto port = 
dynamic_cast<minifi::RemoteProcessGroupPort*>(&processor->getImpl());
+        port && port->getDirection() == sitetosite::TransferDirection::SEND) {
+      continue;
+    }
+    for (const auto& relationship : processor->getSupportedRelationships()) {
+      if (processor->isAutoTerminated(relationship)) {
+        continue;
+      }
+      if (!terminated_relationships.contains({processor, 
relationship.getName()})) {
+        unterminated_relationships.emplace_back(processor->getName(), 
relationship.getName());
+      }
+    }
+  }
+
+  if (!unterminated_relationships.empty()) {
+    std::string message = "The following component-relationship pairs are not 
terminated by any connection: [";
+    for (const auto& [processor, relationship] : unterminated_relationships) {
+      message.append(fmt::format("({}, {})", processor, relationship));
+    }
+    message += "]";

Review Comment:
   Updated in 
https://github.com/apache/nifi-minifi-cpp/pull/2296/commits/76f053d4fed906107328dfa4c68236af830dfdc7



##########
CONFIGURE.md:
##########
@@ -133,6 +133,7 @@ Remote Processing Groups:
 Besides YAML configuration format, MiNiFi C++ also supports JSON 
configuration. To see different uses cases in both formats, please refer to the 
[examples page](examples/README.md) for flow config examples.
 
 **NOTE:** Make sure to specify id for each component (Processor, Connection, 
Controller, RPG etc.) to make sure that Apache MiNiFi C++ can reload the state 
after a process restart. The id should be unique in the flow configuration.
+**NOTE:** Make sure to terminate all outgoing connections of processors, 
ports, funnels, either by connecting them to another component or 
auto-terminating them, otherwise the flow validation fails on startup.

Review Comment:
   Updated in 
https://github.com/apache/nifi-minifi-cpp/pull/2296/commits/76f053d4fed906107328dfa4c68236af830dfdc7



##########
libminifi/src/core/ProcessGroup.cpp:
##########
@@ -478,10 +480,52 @@ std::size_t ProcessGroup::getTotalFlowFileCount() const {
   return sum;
 }
 
+void ProcessGroup::verifyRelationshipTerminations() const {
+  std::map<std::string, Connection*> connections;
+  getConnections(connections);
+  std::set<std::pair<const Connectable*, std::string>> 
terminated_relationships;
+  for (const auto& [_, connection] : connections) {
+    for (const auto& relationship : connection->getRelationships()) {
+      terminated_relationships.emplace(connection->getSource(), 
relationship.getName());
+    }
+  }
+
+  std::vector<Processor*> processors;
+  getAllProcessors(processors);
+
+  std::vector<std::pair<std::string, std::string>> unterminated_relationships;
+  for (auto* processor : processors) {
+    // RPG input ports (SEND direction) only send their incoming flow files to 
the remote instance and never transfer to a local relationship,
+    // while RPG output ports (RECEIVE direction) transfer the received flow 
files to their relationship, so those are still verified
+    if (auto port = 
dynamic_cast<minifi::RemoteProcessGroupPort*>(&processor->getImpl());
+        port && port->getDirection() == sitetosite::TransferDirection::SEND) {
+      continue;
+    }
+    for (const auto& relationship : processor->getSupportedRelationships()) {
+      if (processor->isAutoTerminated(relationship)) {
+        continue;
+      }
+      if (!terminated_relationships.contains({processor, 
relationship.getName()})) {
+        unterminated_relationships.emplace_back(processor->getName(), 
relationship.getName());
+      }

Review Comment:
   Updated in 
https://github.com/apache/nifi-minifi-cpp/pull/2296/commits/76f053d4fed906107328dfa4c68236af830dfdc7



-- 
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: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to