-
Notifications
You must be signed in to change notification settings - Fork 25.7k
Refactor MoveDecision method names for clarity #136139
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
Changes from 4 commits
bbd6002
d3d7a24
8df6adc
f7562a1
198f419
d6efcee
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change | ||||
|---|---|---|---|---|---|---|
|
|
@@ -92,11 +92,11 @@ public void writeTo(StreamOutput out) throws IOException { | |||||
| * Creates a move decision for the shard being able to remain on its current node, so the shard won't | ||||||
| * be forced to move to another node. | ||||||
| */ | ||||||
| public static MoveDecision remain(Decision canRemainDecision) { | ||||||
| public static MoveDecision createMoveDecisionWithRemainYesDecision(Decision canRemainDecision) { | ||||||
| assert canRemainDecision.type() != Type.NO; | ||||||
|
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. Does
Contributor
Author
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. This is 10 year old code, maybe older. It hasn't been updated in a very long time. I tracked it back to the BalancedShardsAllocator (many refactors), but then gave up :) THROTTLE was added in 2012. This is original Elasticsearch founder code -- i.e. completed quickly, not prettily.
Member
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. Can we also assert
Contributor
Author
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. Sure, done |
||||||
| if (canRemainDecision == Decision.YES) { | ||||||
| return CACHED_STAY_DECISION; | ||||||
| } | ||||||
| assert canRemainDecision.type() != Type.NO; | ||||||
| return new MoveDecision(null, null, AllocationDecision.NO_ATTEMPT, canRemainDecision, null, 0); | ||||||
| } | ||||||
|
|
||||||
|
|
@@ -150,11 +150,21 @@ public boolean isDecisionTaken() { | |||||
| * returns {@code false} otherwise. If {@link #isDecisionTaken()} returns {@code false}, | ||||||
| * then invoking this method will throw an {@code IllegalStateException}. | ||||||
| */ | ||||||
| public boolean forceMove() { | ||||||
| public boolean cannotRemainAndCanMove() { | ||||||
| checkDecisionState(); | ||||||
| return canRemain() == false && canMoveDecision == AllocationDecision.YES; | ||||||
| } | ||||||
|
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. Good call, |
||||||
|
|
||||||
| /** | ||||||
| * Returns {@code true} if the shard cannot remain on its current node and _cannot_ be moved. | ||||||
| * returns {@code false} otherwise. If {@link #isDecisionTaken()} returns {@code false}, | ||||||
| * then invoking this method will throw an {@code IllegalStateException}. | ||||||
| */ | ||||||
| public boolean cannotRemainAndCannotMove() { | ||||||
| checkDecisionState(); | ||||||
| return canRemainDecision.type() != Type.YES && canMoveDecision != AllocationDecision.YES; | ||||||
|
||||||
| return canRemainDecision.type() != Type.YES && canMoveDecision != AllocationDecision.YES; | |
| return canRemain() == false && canMoveDecision != AllocationDecision.YES; |
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.
Done
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: I think such a static method name usually skip the type name, e.g.:
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.
Updated to
createRemainYesDecision.