-
Notifications
You must be signed in to change notification settings - Fork 140
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
Refactor structure of stats module #736
Refactor structure of stats module #736
Conversation
Removes valid stats arg from KNNStatsRequest. Valid stats is a global constant so there is not a good reason to make it configurable. It is still written in and out of the stream. This is to prevent breakage in any kind of backwards compatibility. Signed-off-by: John Mazanec <jmazane@amazon.com>
Removes KNNStatsConfig class and moves logic directly into the KNNStats class. KNNStatsConfig just hosted a single map of the stats, so it felt unneccessary to have the whole class. Signed-off-by: John Mazanec <jmazane@amazon.com>
public class StatsIT extends AbstractRollingUpgradeTestCase { | ||
private KNNStats knnStats = new KNNStats(KNN_STATS); | ||
private KNNStats knnStats = new KNNStats(); |
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.
if you want to init this KNNStats the better way to do is using a function having with annotation @before on top of it.
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.
Sure will update.
@@ -75,4 +76,73 @@ private Map<String, KNNStat<?>> getClusterOrNodeStats(Boolean getClusterStats) { | |||
} | |||
return statsMap; | |||
} | |||
|
|||
private Map<String, KNNStat<?>> buildStatsMap() { | |||
return ImmutableMap.<String, KNNStat<?>>builder() |
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.
let's break this function into smaller chunks of private functions which tells what stats we are adding. So that it becomes easier to debug and read.
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.
Sure, will update.
@@ -23,8 +24,7 @@ public class KNNStatsRequest extends BaseNodesRequest<KNNStatsRequest> { | |||
* Key indicating all stats should be retrieved | |||
*/ | |||
public static final String ALL_STATS_KEY = "_all"; | |||
|
|||
private Set<String> validStats; | |||
private Set<String> validStats = StatNames.getNames(); |
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.
init this variable via constructor rather than here, this will help us mock things later on if required.
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.
Will update.
There is NPE happening in one of the Tests. please fix that too. |
Codecov Report
@@ Coverage Diff @@
## main #736 +/- ##
============================================
- Coverage 84.85% 84.85% -0.01%
- Complexity 1074 1075 +1
============================================
Files 152 151 -1
Lines 4364 4370 +6
Branches 390 390
============================================
+ Hits 3703 3708 +5
+ Misses 483 482 -1
- Partials 178 180 +2
Help us with your feedback. Take ten seconds to tell us how you rate us. Have a feature suggestion? Share it here. |
Signed-off-by: John Mazanec <jmazane@amazon.com>
cf122bb
to
c7844ed
Compare
The backport to
To backport manually, run these commands in your terminal: # Fetch latest updates from GitHub
git fetch
# Create a new working tree
git worktree add .worktrees/backport-2.x 2.x
# Navigate to the new working tree
cd .worktrees/backport-2.x
# Create a new branch
git switch --create backport/backport-736-to-2.x
# Cherry-pick the merged commit of this pull request and resolve the conflicts
git cherry-pick -x --mainline 1 185b54daee1f9009c7a67dfa24adb153cfdcd160
# Push it to GitHub
git push --set-upstream origin backport/backport-736-to-2.x
# Go back to the original working tree
cd ../..
# Delete the working tree
git worktree remove .worktrees/backport-2.x Then, create a pull request where the |
Removes valid stats arg from KNNStatsRequest. Valid stats is a global constant so there is not a good reason to make it configurable. It is still written in and out of the stream. This is to prevent breakage in any kind of backwards compatibility. Removes KNNStatsConfig class and moves logic directly into the KNNStats class. KNNStatsConfig just hosted a single map of the stats, so it felt unneccessary to have the whole class. Signed-off-by: John Mazanec <jmazane@amazon.com> (cherry picked from commit 185b54d)
Description
Removes KNNStatsConfig structure. This structure only had a single static variable. Moved the logic directly into the KNNStats class into a private non-static method. This will allow us to pass dependencies into stats during construction as opposed to have to initialize them statically.
Modifies KNNStatsRequest to not take validStats as an argument. Valid stats are the same every time so I dont see reason for making this configurable. Kept the stream logic to prevent break in bwc.
Issues Resolved
[List any issues this PR will resolve]
Check List
By submitting this pull request, I confirm that my contribution is made under the terms of the Apache 2.0 license.
For more information on following Developer Certificate of Origin and signing off your commits, please check here.