-
Notifications
You must be signed in to change notification settings - Fork 25k
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
Do not pass ThreadPool to DesiredBalanceComputer #116590
Do not pass ThreadPool to DesiredBalanceComputer #116590
Conversation
Pinging @elastic/es-distributed-coordination (Team:Distributed Coordination) |
} | ||
|
||
DesiredBalanceComputer(ClusterSettings clusterSettings, ShardsAllocator delegateAllocator, LongSupplier timeSupplierMillis) { | ||
public DesiredBalanceComputer(ClusterSettings clusterSettings, LongSupplier timeSupplierMillis, ShardsAllocator delegateAllocator) { |
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: lets keep the original order of arguments (clusterSettings, delegateAllocator, timeSupplierMillis), this could allow to minimize some of the changes such as:
new DesiredBalanceComputer(clusterSettings, shardsAllocator, time::get) {
new DesiredBalanceComputer(clusterSettings, time::get, shardsAllocator) {
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 IS the original order (i.e. the existing public constructor), just replaced the threadpool with time supplier. :)
@@ -1349,7 +1353,7 @@ public ShardAllocationDecision decideShardAllocation(ShardRouting shard, Routing | |||
} | |||
|
|||
private static DesiredBalanceComputer createDesiredBalanceComputer(ShardsAllocator allocator) { | |||
return new DesiredBalanceComputer(createBuiltInClusterSettings(), mock(ThreadPool.class), allocator); | |||
return new DesiredBalanceComputer(createBuiltInClusterSettings(), mock(ThreadPool.class)::relativeTimeInMillis, allocator); |
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.
It looks like we no longer need mock here
return new DesiredBalanceComputer(createBuiltInClusterSettings(), mock(ThreadPool.class)::relativeTimeInMillis, allocator); | |
return new DesiredBalanceComputer(createBuiltInClusterSettings(), () -> 0L, allocator); |
unassignedIterator.removeAndIgnore(UnassignedInfo.AllocationStatus.NO_ATTEMPT, allocation.changes()); | ||
var desiredBalanceComputer = new DesiredBalanceComputer( | ||
clusterSettings, | ||
mockThreadPool::relativeTimeInMillis, |
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.
It looks like this mockThreadPool could be simplified as well
mockThreadPool::relativeTimeInMillis, | |
() -> currentTime.addAndGet(eachIterationDuration), |
this way it might not be created at all above.
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.
oh, right. didn't see that. thanks.
Relates #115511 (comment). `ThreadPool` is used here only to get time. (I've extracted this out of #116333).
Relates elastic#115511 (comment). `ThreadPool` is used here only to get time. (I've extracted this out of elastic#116333).
Relates elastic#115511 (comment). `ThreadPool` is used here only to get time. (I've extracted this out of elastic#116333).
Relates #115511 (comment).
ThreadPool
is used here only to get time. (I've extracted this out of #116333).