msharee9 commented on a change in pull request #743: Minificpp 1169 - Simplify 
C2 metrics collection and reporting
URL: https://github.com/apache/nifi-minifi-cpp/pull/743#discussion_r392347808
 
 

 ##########
 File path: libminifi/src/FlowController.cpp
 ##########
 @@ -907,29 +908,44 @@ int16_t FlowController::clearConnection(const 
std::string &connection) {
   return -1;
 }
 
-int16_t 
FlowController::getResponseNodes(std::vector<std::shared_ptr<state::response::ResponseNode>>
 &metric_vector, uint16_t metricsClass) {
+std::shared_ptr<state::response::ResponseNode> 
FlowController::getMetricsNode(const std::string& metricsClass) const {
   std::lock_guard<std::mutex> lock(metrics_mutex_);
-
-  for (auto metric : root_response_nodes_) {
-    metric_vector.push_back(metric.second);
+  if (!metricsClass.empty()) {
+    const auto citer = component_metrics_.find(metricsClass);
+    if (citer != component_metrics_.end()) {
+      return citer->second;
+    }
+  } else {
+    const auto iter = root_response_nodes_.find("metrics");
+    if (iter != root_response_nodes_.end()) {
+      return iter->second;
+    }
 
 Review comment:
   There is no code duplication as far as I see. we are looking up different 
maps in if and else branches.

----------------------------------------------------------------
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.
 
For queries about this service, please contact Infrastructure at:
[email protected]


With regards,
Apache Git Services

Reply via email to