-
Notifications
You must be signed in to change notification settings - Fork 99
MINIFICPP-2669 - Reduce controller service api #2065
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
adamdebreceni
wants to merge
11
commits into
apache:main
Choose a base branch
from
adamdebreceni:MINIFICPP-2669
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
+1,020
−1,298
Open
Changes from all commits
Commits
Show all changes
11 commits
Select commit
Hold shift + click to select a range
accbc85
MINIFICPP-2669 - Reduce controller service api
adamdebreceni 9603f1f
Remove some virtual inhertiance fix linux build
adamdebreceni dfba7f8
MINIFICPP-2669 - Clang tidy fix
adamdebreceni 3eb2b29
MINIFICPP-2669 - Test fix
adamdebreceni bc52d2d
MINIFICPP-2669 - Remove invalid logger
adamdebreceni 4a5f338
MINIFICPP-2669 - Formatting fix
adamdebreceni 068b30c
MINIFICPP-2669 - Rebase fix
adamdebreceni d7ce5f0
MINIFICPP-2669 - Remove ThreadManagementService, review changes
adamdebreceni 4b69931
MINIFICPP-2669 - Fix build
adamdebreceni ce655d7
MINIFICPP-2669 - Fix build
adamdebreceni 0972302
Update core-framework/include/utils/ThreadPool.h
adamdebreceni File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
121 changes: 0 additions & 121 deletions
121
core-framework/include/core/controller/ControllerService.h
This file was deleted.
Oops, something went wrong.
113 changes: 113 additions & 0 deletions
113
core-framework/include/core/controller/ControllerServiceBase.h
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,113 @@ | ||
| /** | ||
| * | ||
| * 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 { | ||
|
|
||
| // A base class that helps with controller service development, contains common functionalities. | ||
| 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_; | ||
| // valid during initialize, sink for supported properties | ||
| ControllerServiceDescriptor* descriptor_{nullptr}; | ||
| // valid during onEnable, provides property access | ||
| ControllerServiceContext* context_{nullptr}; | ||
|
|
||
| std::shared_ptr<core::logging::Logger> logger_; | ||
| }; | ||
|
|
||
| } // namespace org::apache::nifi::minifi::core::controller | ||
57 changes: 57 additions & 0 deletions
57
core-framework/include/core/controller/ControllerServiceFactoryImpl.h
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,57 @@ | ||
| /** | ||
| * 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 <string> | ||
| #include <memory> | ||
| #include <utility> | ||
| #include "core/ClassName.h" | ||
| #include "minifi-cpp/core/controller/ControllerServiceFactory.h" | ||
|
|
||
| namespace org::apache::nifi::minifi::core::controller { | ||
|
|
||
| template<class T> | ||
| class ControllerServiceFactoryImpl : public ControllerServiceFactory { | ||
| public: | ||
| ControllerServiceFactoryImpl() | ||
| : class_name_(core::className<T>()) { | ||
| } | ||
|
|
||
| explicit ControllerServiceFactoryImpl(std::string group_name) | ||
| : group_name_(std::move(group_name)), | ||
| class_name_(core::className<T>()) { | ||
| } | ||
|
|
||
| std::string getGroupName() const override { | ||
| return group_name_; | ||
| } | ||
|
|
||
| std::unique_ptr<ControllerServiceApi> create(ControllerServiceMetadata metadata) override { | ||
| return std::make_unique<T>(metadata); | ||
| } | ||
|
|
||
| std::string getClassName() const override { | ||
| return std::string{class_name_}; | ||
| } | ||
|
|
||
| protected: | ||
| std::string group_name_; | ||
| std::string_view class_name_; | ||
| }; | ||
|
|
||
| } // namespace org::apache::nifi::minifi::core::controller |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
A comment describing the lifetimes (what guarantees that these will remain alive throughout the ControllerService lifetime) would be nice here.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
added comment