fgerlits commented on code in PR #1840:
URL: https://github.com/apache/nifi-minifi-cpp/pull/1840#discussion_r1822185704


##########
libminifi/include/core/controller/ControllerServiceLookup.h:
##########
@@ -52,6 +52,14 @@ class ControllerServiceLookup {
    */
   virtual std::shared_ptr<ControllerService> getControllerService(const 
std::string &identifier) const = 0;

Review Comment:
   We should clarify in the doc string how this is different from the other 
overload, eg "Gets the top-level controller service via the provided 
identifier".



##########
libminifi/src/core/controller/ControllerServiceNodeMap.cpp:
##########
@@ -0,0 +1,96 @@
+/**
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#include "core/controller/ControllerServiceNodeMap.h"
+#include "core/ProcessGroup.h"
+
+namespace org::apache::nifi::minifi::core::controller {
+
+ControllerServiceNode* ControllerServiceNodeMap::get(const std::string &id) 
const {
+  std::lock_guard<std::mutex> lock(mutex_);
+  auto exists = controller_service_nodes_.find(id);
+  if (exists != controller_service_nodes_.end())
+    return exists->second.get();
+  else
+    return nullptr;
+}
+
+ControllerServiceNode* ControllerServiceNodeMap::get(const std::string &id, 
const utils::Identifier& processor_uuid) const {
+  std::lock_guard<std::mutex> lock(mutex_);
+  ControllerServiceNode* controller = nullptr;
+  auto exists = controller_service_nodes_.find(id);
+  if (exists != controller_service_nodes_.end()) {
+    controller = exists->second.get();
+  } else {
+    return nullptr;
+  }
+
+  auto process_group_of_controller_exists = process_groups_.find(id);
+  ProcessGroup* process_group = nullptr;
+  if (process_group_of_controller_exists != process_groups_.end()) {
+    process_group = process_group_of_controller_exists->second;
+  } else {
+    return nullptr;
+  }
+
+  if (process_group->findProcessorById(processor_uuid)) {
+    return controller;
+  }
+
+  if (process_group->findControllerService(processor_uuid.to_string(), 
ProcessGroup::Traverse::IncludeChildren)) {

Review Comment:
   Isn't the first parameter of `findControllerService()` the ID of the 
controller service? How does this work if we pass in the ID of the processor?



##########
libminifi/include/core/controller/ControllerServiceProvider.h:
##########
@@ -66,15 +66,20 @@ class ControllerServiceProvider : public CoreComponent, 
public ConfigurableCompo
     return controller_map_->get(id);
   }
 
+  virtual ControllerServiceNode* getControllerServiceNode(const std::string 
&id, const utils::Identifier &controller_uuid) const {

Review Comment:
   should the second parameter be `processor_uuid`?



##########
libminifi/src/core/ProcessGroup.cpp:
##########
@@ -115,11 +115,18 @@ void 
ProcessGroup::addProcessGroup(std::unique_ptr<ProcessGroup> child) {
 
 void ProcessGroup::startProcessingProcessors(TimerDrivenSchedulingAgent& 
timeScheduler,
     EventDrivenSchedulingAgent& eventScheduler, CronDrivenSchedulingAgent& 
cronScheduler) {
-  std::unique_lock<std::recursive_mutex> lock(mutex_);
+
+  std::set<Processor*> processors_to_schedule;

Review Comment:
   This could be a `std::vector`. (I don't want to remove the existing 
`std::set`s, at least not in this PR, but I'd prefer to not add new ones where 
not needed.)



##########
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;
-  std::shared_ptr<core::Processor> processor = 
std::make_shared<org::apache::nifi::minifi::processors::ExtractText>("processorname");
+  auto processor = 
std::make_shared<org::apache::nifi::minifi::processors::ExtractText>("processorname");

Review Comment:
   could this be a `unique_ptr`, too?



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