adam-markovics commented on a change in pull request #1284:
URL: https://github.com/apache/nifi-minifi-cpp/pull/1284#discussion_r832339939



##########
File path: libminifi/src/FlowController.cpp
##########
@@ -438,30 +432,43 @@ std::shared_ptr<state::response::ResponseNode> 
FlowController::getAgentManifest(
   return agentInfo;
 }
 
+void 
FlowController::executeOnAllComponents(std::function<void(state::StateController*)>
 func) {
+  std::lock_guard<std::recursive_mutex> lock(mutex_);
+  for (auto* component: getAllComponents()) {
+    func(component);
+  }

Review comment:
       Done.

##########
File path: libminifi/src/FlowController.cpp
##########
@@ -506,31 +513,36 @@ std::map<std::string, std::unique_ptr<io::InputStream>> 
FlowController::getDebug
   return debug_info;
 }
 
-void 
FlowController::getAllProcessorControllers(std::vector<state::StateController*>&
 controllerVec,
-                                              const 
std::function<std::unique_ptr<state::ProcessorController>(core::Processor&)>& 
controllerFactory) {
-  std::lock_guard<std::recursive_mutex> lock(mutex_);
-
+std::vector<state::StateController*> 
FlowController::getAllProcessorControllers(
+        const 
std::function<std::unique_ptr<state::ProcessorController>(core::Processor&)>& 
controllerFactory) {
+  std::vector<state::StateController*> controllerVec{this};
   std::vector<core::Processor*> processorVec;
   root_->getAllProcessors(processorVec);
 
   for (const auto& processor : processorVec) {
-    // find controller for processor, if it doesn't exist, create one
+    // reference to the existing or newly created controller
     auto& controller = processor_to_controller_[processor->getUUID()];
     if (!controller) {
       controller = controllerFactory(*processor);
     }
     controllerVec.push_back(controller.get());
   }
+
+  return controllerVec;
 }
 
-void FlowController::getProcessorController(const std::string& name, 
std::vector<state::StateController*>& controllerVec,
-                                          const 
std::function<std::unique_ptr<state::ProcessorController>(core::Processor&)>& 
controllerFactory) {
+state::StateController* FlowController::getProcessorController(const 
std::string& name, const 
std::function<std::unique_ptr<state::ProcessorController>(core::Processor&)>& 
controllerFactory) {
   auto* processor = root_->findProcessorByName(name);
-  auto& controller = processor_to_controller_[processor->getUUID()];
-  if (!controller) {
-    controller = controllerFactory(*processor);
+  if (processor == nullptr) {
+    logger_->log_error("Could not get processor controller for requested name 
\"%s\", because processor was not found either", name);
+  }

Review comment:
       Done.




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