This repository was archived by the owner on Oct 23, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 19
Refactored SerenityConfig #157
Open
bwplotka
wants to merge
7
commits into
d2iq-archive:master
Choose a base branch
from
bwplotka:serenity-config
base: master
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.
Open
Changes from all commits
Commits
Show all changes
7 commits
Select commit
Hold shift + click to select a range
550d4ce
WIP: Refactored SerenityConfig. Example in Overload.hpp & config_test…
bwplotka f19fd5f
Fixed lint issue.
bwplotka fde11f8
Refactored SerenityConfing, templated set & item
bwplotka 3e297af
Fixed small issue in signal detector.
bwplotka df386ab
Applied refactor to other components.
bwplotka 1a7e32a
First part of Serenity Config and validation refactor.
bwplotka e48e3d5
Big Config refactored. Added tests.
bwplotka 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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -20,22 +20,6 @@ | |
| namespace mesos { | ||
| namespace serenity { | ||
|
|
||
| class OverloadDetectorConfig : public SerenityConfig { | ||
| public: | ||
| OverloadDetectorConfig() { } | ||
|
|
||
| explicit OverloadDetectorConfig(const SerenityConfig& customCfg) { | ||
| this->initDefaults(); | ||
| this->applyConfig(customCfg); | ||
| } | ||
|
|
||
| void initDefaults() { | ||
| //! double_t | ||
| //! Detector threshold. | ||
| this->fields[detector::THRESHOLD] = | ||
| detector::DEFAULT_UTILIZATION_THRESHOLD; | ||
| } | ||
| }; | ||
|
|
||
| /** | ||
| * OverloadDetector is able to create contention if utilization is above | ||
|
|
@@ -48,28 +32,40 @@ class OverloadDetector : | |
| OverloadDetector( | ||
| Consumer<Contentions>* _consumer, | ||
| const lambda::function<usage::GetterFunction>& _cpuUsageGetFunction, | ||
| SerenityConfig _conf, | ||
| const Config& _conf, | ||
| const Tag& _tag = Tag(QOS_CONTROLLER, NAME)) | ||
| : tag(_tag), | ||
| cpuUsageGetFunction(_cpuUsageGetFunction), | ||
| Producer<Contentions>(_consumer) { | ||
| SerenityConfig config = OverloadDetectorConfig(_conf); | ||
| this->cfgUtilizationThreshold = | ||
| config.getD(detector::THRESHOLD); | ||
| // Parse config values. | ||
| setUtilizationThreshold( | ||
| _conf.getValue<double_t>(UTILIZATION_THRESHOLD_KEY)); | ||
| } | ||
|
|
||
| ~OverloadDetector() {} | ||
|
|
||
| Try<Nothing> consume(const ResourceUsage& in) override; | ||
|
|
||
| static const constexpr char* NAME = "OverloadDetector"; | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Field should be below functions, right? |
||
|
|
||
| void setUtilizationThreshold(const Result<double_t>& value) { | ||
| cfgUtilizationThreshold = | ||
| ConfigValidator<double_t>(value, UTILIZATION_THRESHOLD_KEY) | ||
| .validateValueIsPositive() | ||
| .getOrElse(DEFAULT_UTILIZATION_THRESHOLD); | ||
| } | ||
|
|
||
| static const constexpr char* UTILIZATION_THRESHOLD_KEY = "THRESHOLD"; | ||
|
|
||
| protected: | ||
| void allProductsReady() override; | ||
| bool hasRequiredFields(const ResourceUsage_Executor& inExec); | ||
|
|
||
| const Tag tag; | ||
| const lambda::function<usage::GetterFunction> cpuUsageGetFunction; | ||
|
|
||
| // cfg parameters. | ||
| double_t cfgUtilizationThreshold; | ||
|
|
||
| static const constexpr double_t DEFAULT_UTILIZATION_THRESHOLD = 0.72; | ||
| }; | ||
|
|
||
| } // namespace serenity | ||
|
|
||
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.
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.
This code is rather self-explanatory.