-
Notifications
You must be signed in to change notification settings - Fork 25.6k
Split AllocationDecider into sub-interfaces and group deciders #130880
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
Conversation
|
Pinging @elastic/es-distributed-coordination (Team:Distributed Coordination) |
| import java.util.Optional; | ||
| import java.util.Set; | ||
|
|
||
| public class DefaultAllocationDecider |
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.
Should probably move to test package. Production deciders implement interfaces. This one only for testing.
DaveCTurner
left a comment
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 don't like this much, it seems much more complicated and the benefits are pretty minimal. It makes the job of someone implementing a decider (often from outside the distrib/allocation team these days) even more complicated than it is already.
|
Sad to hear. I'm still liking how it looks, explicit and yet minimal, easier to read and navigate, no hidden defaults. Some deciders are orthogonal to each other but share same defaults, which is counter intuitive. I will keep this PR open for now. |
|
This significantly complicates the AllocationDeciders. Adding a new AllocationDecider method would require creating a new interface. If we were to prove that the current code has significant performance loss in the AllocationDeciders calls, compared to your PoC, then paying the complexity cost could be of interest. But without that proof I think this proposal only has downsides. |
It does not. Adding new method to AllocationDecider requires new interface. Implementation of decider chooses a set of interfaces it wants to implement. |
I see this as perceived complexity, due to more verbose "implement" statement. But it's explicit what each decider suppose to do. Real complexity reduces since every decider has smaller surface, no defaults. I dont see reasons for these defaults to exists. AllocationDeciders uses "YES" by default when looping through it's deciders. Changing default to something non-yes, will break everything. |
This change splits
AllocationDeciderinto collection of interfaces. This should help with applying deciders that implement interfaces rather than calling all of them with default "Decision.ALWAYS" result. Every decider now explicitly tell which interface it implements:So
AllocationDeciderscan use this type information to group deciders for specific API call.For testing ease added a new class DefaultAllocationDecider that uses previous behaviour of abstract class with "Decision.ALWAYS".
Major change in
AllocationDeciderandAllocationDeciders. I do preserve default behaviour. Especially for ShardToNode decider that combinescanAllocate,canForceAllocatePrimary, andcanAllocateReplicaWhenThereIsRetentionLease, since later two depends oncanAllocate.