fgerlits commented on code in PR #2296:
URL: https://github.com/apache/nifi-minifi-cpp/pull/2296#discussion_r4665701057
##########
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:
not a bug, just a suggestion:
```suggestion
std::string message = fmt::format("The following component-relationship
pairs are not terminated by any connection: {}", unterminated_relationships);
```
is simpler to write and the output looks better:
```
old: [(a, 1)(b, 2)(c, 3)]
new: [("a", "1"), ("b", "2"), ("c", "3")]
```
(needs `#include "fmt/ranges.h"`)
##########
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:
nitpick: there should be a blank line between the two NOTEs, so they are
rendered as separate paragraphs
##########
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:
Claude suggested to change this to
```suggestion
if (!processor->isAutoTerminated(relationship) &&
processor->getOutGoingConnections(relationship.getName()).empty()) {
unterminated_relationships.emplace_back(processor->getName(),
relationship.getName());
```
and drop the `terminated_relationships` set, because it is simpler, and it
matches what is needed later at `ProcessSession.cpp:819`.
--
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]