Replace superfluous usage of Counter with Supplier#39048
Replace superfluous usage of Counter with Supplier#39048matriv merged 5 commits intoelastic:masterfrom
Conversation
`Counter` was used as a means of a functional argument to pass the relative cached time before `Supplier` iface was introduced.
|
Pinging @elastic/es-core-infra |
| private final ShardSearchRequest request; | ||
| private final SearchShardTarget shardTarget; | ||
| private final Counter timeEstimateCounter; | ||
| private final Supplier<Long> timeEstimate; |
|
|
||
| public Counter estimatedTimeInMillisCounter() { | ||
| return cachedTimeThread.counter; | ||
| public Supplier<Long> estimatedTimeInMillis() { |
There was a problem hiding this comment.
this can be removed and replaced by ThreadPool::relativeTimeInMillis on the consumer end
|
|
||
| final DefaultSearchContext searchContext = new DefaultSearchContext(idGenerator.incrementAndGet(), request, shardTarget, | ||
| engineSearcher, clusterService, indexService, indexShard, bigArrays, threadPool.estimatedTimeInMillisCounter(), timeout, | ||
| engineSearcher, clusterService, indexService, indexShard, bigArrays, threadPool.estimatedTimeInMillis(), timeout, |
There was a problem hiding this comment.
use threadPool::relativeTimeInMillis
| return currentTimeMillis; | ||
| } | ||
| }; | ||
| public Supplier<Long> estimatedTimeInMillis() { |
There was a problem hiding this comment.
just use :: relativeTimeInMillis on the consumer end.
|
@s1monw Thank you! Addressed comments. |
jasontedor
left a comment
There was a problem hiding this comment.
I left a comment about naming.
| private final ShardSearchRequest request; | ||
| private final SearchShardTarget shardTarget; | ||
| private final Counter timeEstimateCounter; | ||
| private final LongSupplier timeEstimate; |
There was a problem hiding this comment.
I think this name is misleading because we are using a relative notion of time here whereas the name could be construed as an estimate of the absolute time (like a timestamp). In other places we use the name relativeTimeSupplier to make it clear the purpose of the variable, and to avoid a problem if in the future someone were to use this variable for another piece of code to try to get the absolute time. It would also be worthwhile to add a comment explaining why relative time is okay here. It is important to keep the two uses between absolute and relative time absolutely clear.
There was a problem hiding this comment.
Should we change also the iface method name(): https://github.com/elastic/elasticsearch/pull/39048/files#diff-2410736cbe252badfd50ccbfceebc857R398 ?
There was a problem hiding this comment.
I would just name it timeSupplier. I also think we should not expose the LongSupplier on SerachContext at all and only provide a method to access the time public long getTime() on SearchContext.java The usage is simple and can just call this method. no need to expose the supplier.
There was a problem hiding this comment.
Chose getTimeInMillis() to be even more clear.
There was a problem hiding this comment.
Please include the word relative in the name.
| private final ShardSearchRequest request; | ||
| private final SearchShardTarget shardTarget; | ||
| private final Counter timeEstimateCounter; | ||
| private final LongSupplier timeEstimate; |
There was a problem hiding this comment.
I would just name it timeSupplier. I also think we should not expose the LongSupplier on SerachContext at all and only provide a method to access the time public long getTime() on SearchContext.java The usage is simple and can just call this method. no need to expose the supplier.
jasontedor
left a comment
There was a problem hiding this comment.
I still have concerns about the naming not being explicit enough.
|
@jasontedor please check again |
jasontedor
left a comment
There was a problem hiding this comment.
LGTM. Thank you for the improvement and all the iterations.
`Counter` was used as a means of a functional argument to pass the relative cached time before `Supplier` iface was introduced.
* elastic/master: Ensure index commit released when testing timeouts (elastic#39273) Avoid using TimeWarp in TransformIntegrationTests. (elastic#39277) Fixed missed stopping of SchedulerEngine (elastic#39193) [CI] Mute CcrRetentionLeaseIT.testRetentionLeaseIsRenewedDuringRecovery (elastic#39269) Muting AutoFollowIT.testAutoFollowManyIndices (elastic#39264) Clarify the use of sleep in CCR test Fix testCannotShrinkLeaderIndex (elastic#38529) Fix CCR tests that manipulate transport requests Align generated release notes with doc standards (elastic#39234) Mute test (elastic#39248) ReadOnlyEngine should update translog recovery state information (elastic#39238) Wrap accounting breaker check in assertBusy (elastic#39211) Simplify and Fix Synchronization in InternalTestCluster (elastic#39168) [Tests] Make testEngineGCDeletesSetting deterministic (elastic#38942) Extend nextDoc to delegate to the wrapped doc-value iterator for date_nanos (elastic#39176) Change ShardFollowTask to reuse common serialization logic (elastic#39094) Replace superfluous usage of Counter with Supplier (elastic#39048) Disable bwc tests for elastic#39094
`Counter` was used as a means of a functional argument to pass the relative cached time before `Supplier` iface was introduced.
`Counter` was used as a means of a functional argument to pass the relative cached time before `Supplier` iface was introduced.
Counterwas used as a means of a functional argument to passaround the relative cached time before
Supplieriface was introduced.