szaszm commented on code in PR #2065:
URL: https://github.com/apache/nifi-minifi-cpp/pull/2065#discussion_r2616331256
##########
minifi-api/include/minifi-cpp/controllers/RecordSetReader.h:
##########
@@ -16,21 +16,23 @@
*/
#pragma once
-#include "minifi-cpp/core/controller/ControllerService.h"
+#include "minifi-cpp/core/controller/ControllerServiceInterface.h"
#include "minifi-cpp/core/ControllerServiceApiDefinition.h"
#include "minifi-cpp/core/Record.h"
#include "utils/Enum.h"
#include "utils/ProcessorConfigUtils.h"
#include "minifi-cpp/io/InputStream.h"
+#include "minifi-cpp/agent/agent_version.h"
namespace org::apache::nifi::minifi::core {
-class RecordSetReader : public virtual controller::ControllerService {
+class RecordSetReader : public virtual controller::ControllerServiceInterface {
public:
static constexpr auto ProvidesApi = core::ControllerServiceApiDefinition{
.artifact = "minifi-system",
.group = "org.apache.nifi.minifi",
.type = "org.apache.nifi.minifi.core.RecordSetReader",
+ .version = "1.0.0"
Review Comment:
I think the version of components shipped with minifi should always match
the minifi version, what do you think?
##########
core-framework/include/core/controller/ControllerServiceBase.h:
##########
@@ -0,0 +1,116 @@
+/**
+ *
+ * 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.
+ */
+#pragma once
+
+#include <memory>
+#include <string>
+#include <utility>
+#include <vector>
+
+#include "minifi-cpp/properties/Configure.h"
+#include "core/Core.h"
+#include "core/ConfigurableComponentImpl.h"
+#include "core/Connectable.h"
+#include "minifi-cpp/core/controller/ControllerServiceApi.h"
+#include "minifi-cpp/core/controller/ControllerServiceInterface.h"
+#include "minifi-cpp/core/ControllerServiceApiDefinition.h"
+#include "minifi-cpp/core/controller/ControllerServiceMetadata.h"
+
+namespace org::apache::nifi::minifi::core::controller {
+
+/**
+ * Controller Service base class that contains some pure virtual methods.
+ *
+ * Design: OnEnable is executed when the controller service is being enabled.
+ * Note that keeping state here must be protected in this function.
Review Comment:
I don't understand this sentence, could you elaborate or rephrase?
##########
core-framework/src/utils/ThreadPool.cpp:
##########
@@ -152,7 +152,7 @@ void ThreadPool::manageWorkers() {
continue;
}
if (thread_manager_->isAboveMax(current_workers_)) {
- auto max = thread_manager_->getMaxConcurrentTasks();
+ auto max = 1; // thread_manager_->getMaxConcurrentTasks();
Review Comment:
why did this change? leftover debug thing?
##########
core-framework/include/core/controller/ControllerServiceBase.h:
##########
@@ -0,0 +1,116 @@
+/**
+ *
+ * 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.
+ */
+#pragma once
+
+#include <memory>
+#include <string>
+#include <utility>
+#include <vector>
+
+#include "minifi-cpp/properties/Configure.h"
+#include "core/Core.h"
+#include "core/ConfigurableComponentImpl.h"
+#include "core/Connectable.h"
+#include "minifi-cpp/core/controller/ControllerServiceApi.h"
+#include "minifi-cpp/core/controller/ControllerServiceInterface.h"
+#include "minifi-cpp/core/ControllerServiceApiDefinition.h"
+#include "minifi-cpp/core/controller/ControllerServiceMetadata.h"
+
+namespace org::apache::nifi::minifi::core::controller {
+
+/**
+ * Controller Service base class that contains some pure virtual methods.
+ *
+ * Design: OnEnable is executed when the controller service is being enabled.
+ * Note that keeping state here must be protected in this function.
+ */
+class ControllerServiceBase : public ControllerServiceApi {
+ public:
+ explicit ControllerServiceBase(ControllerServiceMetadata metadata)
+ : name_(std::move(metadata.name)),
+ uuid_(metadata.uuid),
+ logger_(std::move(metadata.logger)) {}
+
+ virtual void initialize() {}
+
+ void initialize(ControllerServiceDescriptor& descriptor) final {
+ gsl_Expects(!descriptor_);
+ descriptor_ = &descriptor;
+ auto guard = gsl::finally([&] {descriptor_ = nullptr;});
+ initialize();
+ }
+
+ void setSupportedProperties(std::span<const PropertyReference> properties) {
+ gsl_Expects(descriptor_);
+ descriptor_->setSupportedProperties(properties);
+ }
+
+ ~ControllerServiceBase() override {}
+
+ virtual void onEnable() {}
+
+ /**
+ * Function is called when Controller Services are enabled and being run
+ */
+ void onEnable(ControllerServiceContext& context, const
std::shared_ptr<Configure>& configuration, const
std::vector<std::shared_ptr<ControllerServiceInterface>>& linked_services)
final {
+ configuration_ = configuration;
+ linked_services_ = linked_services;
+ gsl_Expects(!context_);
+ context_ = &context;
+ auto guard = gsl::finally([&] {context_ = nullptr;});
+ onEnable();
+ }
+
+ [[nodiscard]] nonstd::expected<std::string, std::error_code>
getProperty(std::string_view name) const {
+ gsl_Expects(context_);
+ return context_->getProperty(name);
+ }
+
+ [[nodiscard]] nonstd::expected<std::vector<std::string>, std::error_code>
getAllPropertyValues(std::string_view name) const {
+ gsl_Expects(context_);
+ return context_->getAllPropertyValues(name);
+ }
+
+ /**
+ * Function is called when Controller Services are disabled
+ */
+ void notifyStop() override {}
+
+ std::string getName() const {
+ return name_;
+ }
+
+ utils::Identifier getUUID() const {
+ return uuid_;
+ }
+
+
+ static constexpr auto ImplementsApis =
std::array<ControllerServiceApiDefinition, 0>{};
+
+ protected:
+ std::string name_;
+ utils::Identifier uuid_;
+ std::vector<std::shared_ptr<controller::ControllerServiceInterface> >
linked_services_;
+ std::shared_ptr<Configure> configuration_;
+ ControllerServiceDescriptor* descriptor_{nullptr};
+ ControllerServiceContext* context_{nullptr};
Review Comment:
A comment describing the lifetimes (what guarantees that these will remain
alive throughout the ControllerService lifetime) would be nice here.
--
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]