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


##########
libminifi/src/core/state/nodes/ResponseNodeLoader.cpp:
##########
@@ -25,89 +25,129 @@
 #include "core/state/nodes/QueueMetrics.h"
 #include "core/state/nodes/AgentInformation.h"
 #include "core/state/nodes/ConfigurationChecksums.h"
-#include "c2/C2Agent.h"
 #include "utils/gsl.h"
 #include "utils/RegexUtils.h"
 #include "utils/StringUtils.h"
+#include "c2/C2Utils.h"
 
 namespace org::apache::nifi::minifi::state::response {
 
 ResponseNodeLoader::ResponseNodeLoader(std::shared_ptr<Configure> 
configuration, std::shared_ptr<core::Repository> provenance_repo,
-    std::shared_ptr<core::Repository> flow_file_repo, core::FlowConfiguration* 
flow_configuration)
+    std::shared_ptr<core::Repository> flow_file_repo, 
std::shared_ptr<core::FlowConfiguration> flow_configuration)
   : configuration_(std::move(configuration)),
     provenance_repo_(std::move(provenance_repo)),
     flow_file_repo_(std::move(flow_file_repo)),
-    flow_configuration_(flow_configuration) {
+    flow_configuration_(std::move(flow_configuration)) {
 }
 
-void ResponseNodeLoader::initializeComponentMetrics(core::ProcessGroup* root) {
+void ResponseNodeLoader::clearConfigRoot() {
+  {
+    std::lock_guard<std::mutex> guard(system_metrics_mutex_);
+    system_metrics_.clear();
+  }
+  {
+    std::lock_guard<std::mutex> guard(component_metrics_mutex_);
+    component_metrics_.clear();
+  }
+  {
+    std::lock_guard<std::mutex> guard(root_mutex_);
+    root_ = nullptr;
+  }
+}
+
+void ResponseNodeLoader::setNewConfigRoot(core::ProcessGroup* root) {
+  {
+    std::lock_guard<std::mutex> guard(root_mutex_);
+    root_ = root;
+  }
+  initializeComponentMetrics();
+}
+
+void ResponseNodeLoader::initializeComponentMetrics() {
   {
     std::lock_guard<std::mutex> guard(component_metrics_mutex_);
     component_metrics_.clear();
   }
 
-  if (!root) {
+  std::lock_guard<std::mutex> guard(root_mutex_);
+  if (!root_) {
     return;
   }
 
   std::vector<core::Processor*> processors;
-  root->getAllProcessors(processors);
+  root_->getAllProcessors(processors);

Review Comment:
   Good point, it can be an improvement, updated in 
1c8b48094649174a87b7dcf41d4ee6f1bf1e78bf



-- 
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