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


##########
libminifi/src/c2/C2Client.cpp:
##########
@@ -218,38 +222,45 @@ std::vector<state::response::NodeReporter::ReportedNode> 
C2Client::getHeartbeatN
   configuration_->get(minifi::Configuration::nifi_c2_full_heartbeat, fullHb);
   const bool include = include_manifest || fullHb == "true";
 
-  std::vector<state::response::NodeReporter::ReportedNode> nodes;
+  std::vector<state::response::NodeReporter::ReportedNode> reported_nodes;
   std::lock_guard<std::mutex> guard{metrics_mutex_};
-  nodes.reserve(root_response_nodes_.size());
-  for (const auto &entry : root_response_nodes_) {
-    auto identifier = 
std::dynamic_pointer_cast<state::response::AgentIdentifier>(entry.second);
-    if (identifier) {
-      identifier->includeAgentManifest(include);
-    }
-    if (entry.second) {
-      state::response::NodeReporter::ReportedNode reported_node;
-      reported_node.name = entry.second->getName();
-      reported_node.is_array = entry.second->isArray();
-      reported_node.serialized_nodes = entry.second->serialize();
-      nodes.push_back(reported_node);
+  reported_nodes.reserve(root_response_nodes_.size());
+  for (const auto& [name, node_values] : root_response_nodes_) {
+    for (const auto& node : node_values) {
+      auto identifier = 
std::dynamic_pointer_cast<state::response::AgentIdentifier>(node);
+      if (identifier) {
+        identifier->includeAgentManifest(include);
+      }
+      if (node) {
+        state::response::NodeReporter::ReportedNode reported_node;
+        reported_node.name = node->getName();
+        reported_node.is_array = node->isArray();
+        reported_node.serialized_nodes = node->serialize();
+        reported_nodes.push_back(reported_node);
+      }
     }
   }
-  return nodes;
+  return reported_nodes;
 }
 
 void C2Client::initializeResponseNodes(core::ProcessGroup* root) {
+  if (!root_response_nodes_.empty()) {
+    return;
+  }
   std::string class_csv;
   std::lock_guard<std::mutex> guard{metrics_mutex_};
   if (configuration_->get(minifi::Configuration::nifi_c2_root_classes, 
class_csv)) {
     std::vector<std::string> classes = utils::StringUtils::split(class_csv, 
",");
 
     for (const std::string& clazz : classes) {
-      auto response_node = response_node_loader_.loadResponseNode(clazz, root);
-      if (!response_node) {
+      auto response_nodes = response_node_loader_.loadResponseNodes(clazz, 
root);
+      if (response_nodes.empty()) {
         continue;
       }
 
-      root_response_nodes_[response_node->getName()] = 
std::move(response_node);
+      for (auto response_node: response_nodes) {
+        
root_response_nodes_[response_node->getName()].push_back(std::move(response_node));

Review Comment:
   Updated in 567764bbdc4bac04b07b50337293ae732fd8580d



-- 
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-unsubscr...@nifi.apache.org

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

Reply via email to