-
Notifications
You must be signed in to change notification settings - Fork 1.9k
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 BalancedAllocator.Balancer to LocalShardsBalancer #4761
Refactor BalancedAllocator.Balancer to LocalShardsBalancer #4761
Conversation
Gradle Check (Jenkins) Run Completed with:
|
Codecov Report
@@ Coverage Diff @@
## main #4761 +/- ##
============================================
+ Coverage 70.66% 70.72% +0.05%
- Complexity 57578 57717 +139
============================================
Files 4661 4663 +2
Lines 276662 276671 +9
Branches 40325 40317 -8
============================================
+ Hits 195501 195668 +167
+ Misses 64926 64697 -229
- Partials 16235 16306 +71
Help us with your feedback. Take ten seconds to tell us how you rate us. Have a feature suggestion? Share it here. |
346326c
to
5975a0f
Compare
Signed-off-by: Kunal Kotwani <kkotwani@amazon.com>
5975a0f
to
4474c97
Compare
Gradle Check (Jenkins) Run Completed with:
|
Gradle Check (Jenkins) Run Completed with:
|
* | ||
* @opensearch.internal | ||
*/ | ||
public class LocalShardsBalancer extends ShardsBalancer { |
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.
I'm not sure how conservative we need to be here, but in the interest of compatibility it seems like we could leave the inner class 'Balancer' in place with its current name and just change it to extend the newly introduced interface. These things are tagged opensearch.internal
but that doesn't mean they aren't used somewhere (though I couldn't find any usage of Balancer in any other repo in opensearch-project). What do you think?
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.
- Why do we want to expose the
Balancer
outsideBalancedShardAllocator
- Can we use a factory for
Balancer
creation?
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.
Why do we want to expose the Balancer outside BalancedShardAllocator
I don't think we want to, but it is already used in org.opensearch.cluster.routing.allocation.AllocationConstraints
which requires it to be public.
Can we use a factory for Balancer creation?
The approach here (#4759) calls for having 2 balancers with one running after the other, so I'm not sure a factory would help.
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.
I'm not sure how conservative we need to be here, but in the interest of compatibility it seems like we could leave the inner class 'Balancer' in place with its current name and just change it to extend the newly introduced interface. These things are tagged
opensearch.internal
but that doesn't mean they aren't used somewhere (though I couldn't find any usage of Balancer in any other repo in opensearch-project). What do you think?
I wanted to improve the readability and maintainability by splitting it across appropriate classes. We can keep LocalShardsBalancer
and BalancedShardsAllocator.Balancer
and deprecate the latter. We can get rid of it with 3.0.0.
Signed-off-by: Kunal Kotwani <kkotwani@amazon.com>
Gradle Check (Jenkins) Run Completed with:
|
* | ||
* @opensearch.internal | ||
*/ | ||
public class LocalShardsBalancer extends ShardsBalancer { |
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.
nit - Make this class final?
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.
That's a good suggestion. I recently updated the PR to add back the Balancer
class to maintain BWC, which essentially extends LocalShardsBalancer
.
I'll do that with v3.0 when we get rid of the Balancer
class.
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-4761-to-2.x
# Cherry-pick the merged commit of this pull request and resolve the conflicts
git cherry-pick -x --mainline 1 1d654851ff2ea50b0fbb07b7602945f3a0e4cc88
# Push it to GitHub
git push --set-upstream origin backport/backport-4761-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 |
…h-project#4761) * Refactor BalancedAllocator.Balancer to LocalShardsBalancer Signed-off-by: Kunal Kotwani <kkotwani@amazon.com> * Deprecate Balancer to maintain BWC Signed-off-by: Kunal Kotwani <kkotwani@amazon.com> Signed-off-by: Kunal Kotwani <kkotwani@amazon.com> (cherry picked from commit 1d65485)
…h-project#4761) * Refactor BalancedAllocator.Balancer to LocalShardsBalancer Signed-off-by: Kunal Kotwani <kkotwani@amazon.com> * Deprecate Balancer to maintain BWC Signed-off-by: Kunal Kotwani <kkotwani@amazon.com> Signed-off-by: Kunal Kotwani <kkotwani@amazon.com> (cherry picked from commit 1d65485)
…4818) * Refactor BalancedAllocator.Balancer to LocalShardsBalancer (#4761) * Refactor BalancedAllocator.Balancer to LocalShardsBalancer Signed-off-by: Kunal Kotwani <kkotwani@amazon.com> * Deprecate Balancer to maintain BWC Signed-off-by: Kunal Kotwani <kkotwani@amazon.com> Signed-off-by: Kunal Kotwani <kkotwani@amazon.com> (cherry picked from commit 1d65485) * Update changelog Signed-off-by: Kunal Kotwani <kkotwani@amazon.com> Signed-off-by: Kunal Kotwani <kkotwani@amazon.com>
…h-project#4761) * Refactor BalancedAllocator.Balancer to LocalShardsBalancer Signed-off-by: Kunal Kotwani <kkotwani@amazon.com> * Deprecate Balancer to maintain BWC Signed-off-by: Kunal Kotwani <kkotwani@amazon.com> Signed-off-by: Kunal Kotwani <kkotwani@amazon.com>
Signed-off-by: Kunal Kotwani kkotwani@amazon.com
Description
BalancedShardsAllocator.Balancer
to a new classLocalShardsBalancer
ShardsBalancer
in prep forRemoteShard
supportIssues Resolved
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.