From 1830a1113766f50d1240e8c4c0e887dd74f0f90b Mon Sep 17 00:00:00 2001 From: Gabor Gyimesi Date: Wed, 30 Oct 2024 15:00:09 +0100 Subject: [PATCH] Review update --- .../standard-processors/tests/unit/ExtractTextTests.cpp | 2 +- libminifi/include/core/controller/ControllerServiceLookup.h | 3 ++- .../include/core/controller/ControllerServiceNodeMap.h | 4 +++- libminifi/src/core/ProcessGroup.cpp | 4 ++-- libminifi/src/core/controller/ControllerServiceNodeMap.cpp | 6 +++--- 5 files changed, 11 insertions(+), 8 deletions(-) diff --git a/extensions/standard-processors/tests/unit/ExtractTextTests.cpp b/extensions/standard-processors/tests/unit/ExtractTextTests.cpp index 98d55fa1ea..2c207b386d 100644 --- a/extensions/standard-processors/tests/unit/ExtractTextTests.cpp +++ b/extensions/standard-processors/tests/unit/ExtractTextTests.cpp @@ -47,7 +47,7 @@ const char* TEST_ATTR = "ExtractedText"; TEST_CASE("Test creation of ExtractText", "[extracttextCreate]") { TestController testController; - auto processor = std::make_shared("processorname"); + auto processor = std::make_unique("processorname"); REQUIRE(processor->getName() == "processorname"); utils::Identifier processoruuid = processor->getUUID(); REQUIRE(processoruuid); diff --git a/libminifi/include/core/controller/ControllerServiceLookup.h b/libminifi/include/core/controller/ControllerServiceLookup.h index b84da32608..ad6cd62cae 100644 --- a/libminifi/include/core/controller/ControllerServiceLookup.h +++ b/libminifi/include/core/controller/ControllerServiceLookup.h @@ -46,7 +46,8 @@ class ControllerServiceLookup { virtual ~ControllerServiceLookup() = default; /** - * Gets the controller service via the provided identifier. + * Gets the controller service via the provided identifier. This overload returns the controller service in a global scope from all + * available controller services in the flow. * @param identifier reference string for controller service. * @return controller service reference. */ diff --git a/libminifi/include/core/controller/ControllerServiceNodeMap.h b/libminifi/include/core/controller/ControllerServiceNodeMap.h index 5d085ab14e..27a47e1048 100644 --- a/libminifi/include/core/controller/ControllerServiceNodeMap.h +++ b/libminifi/include/core/controller/ControllerServiceNodeMap.h @@ -41,7 +41,7 @@ class ControllerServiceNodeMap { ControllerServiceNodeMap& operator=(ControllerServiceNodeMap&&) = delete; ControllerServiceNode* get(const std::string &id) const; - ControllerServiceNode* get(const std::string &id, const utils::Identifier &processor_uuid) const; + ControllerServiceNode* get(const std::string &id, const utils::Identifier &processor_or_controller_uuid) const; bool put(const std::string &id, const std::shared_ptr &serviceNode); bool put(const std::string &id, ProcessGroup* process_group); @@ -51,7 +51,9 @@ class ControllerServiceNodeMap { protected: mutable std::mutex mutex_; + // Map of controller service id to the controller service node std::map> controller_service_nodes_; + // Map of controller service id to the process group that contains it std::map> process_groups_; }; diff --git a/libminifi/src/core/ProcessGroup.cpp b/libminifi/src/core/ProcessGroup.cpp index 5ed3305484..7fdcf175d9 100644 --- a/libminifi/src/core/ProcessGroup.cpp +++ b/libminifi/src/core/ProcessGroup.cpp @@ -116,11 +116,11 @@ void ProcessGroup::addProcessGroup(std::unique_ptr child) { void ProcessGroup::startProcessingProcessors(TimerDrivenSchedulingAgent& timeScheduler, EventDrivenSchedulingAgent& eventScheduler, CronDrivenSchedulingAgent& cronScheduler) { - std::set processors_to_schedule; + std::vector processors_to_schedule; { std::unique_lock lock(mutex_); for (const auto& processor : failed_processors_) { - processors_to_schedule.insert(processor); + processors_to_schedule.push_back(processor); } } diff --git a/libminifi/src/core/controller/ControllerServiceNodeMap.cpp b/libminifi/src/core/controller/ControllerServiceNodeMap.cpp index ccab6581d7..dded7150ce 100644 --- a/libminifi/src/core/controller/ControllerServiceNodeMap.cpp +++ b/libminifi/src/core/controller/ControllerServiceNodeMap.cpp @@ -30,7 +30,7 @@ ControllerServiceNode* ControllerServiceNodeMap::get(const std::string &id) cons return nullptr; } -ControllerServiceNode* ControllerServiceNodeMap::get(const std::string &id, const utils::Identifier& processor_uuid) const { +ControllerServiceNode* ControllerServiceNodeMap::get(const std::string &id, const utils::Identifier& processor_or_controller_uuid) const { std::lock_guard lock(mutex_); ControllerServiceNode* controller = nullptr; auto exists = controller_service_nodes_.find(id); @@ -48,11 +48,11 @@ ControllerServiceNode* ControllerServiceNodeMap::get(const std::string &id, cons return nullptr; } - if (process_group->findProcessorById(processor_uuid)) { + if (process_group->findProcessorById(processor_or_controller_uuid, ProcessGroup::Traverse::IncludeChildren)) { return controller; } - if (process_group->findControllerService(processor_uuid.to_string(), ProcessGroup::Traverse::IncludeChildren)) { + if (process_group->findControllerService(processor_or_controller_uuid.to_string(), ProcessGroup::Traverse::IncludeChildren)) { return controller; }