[
https://issues.apache.org/jira/browse/KAFKA-16937?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=17854554#comment-17854554
]
Greg Harris commented on KAFKA-16937:
-------------------------------------
[~chia7712] I have no code as I haven't pursued it. But some signatures could
be:
{noformat}
interface Time {
CountDownLatch latch(int count); // implicit reference to time included in
returned object, just call CountDownLatch#await(long, TimeUnit) normally
boolean awaitLatch(CountDownLatch latch, long timeout, TimeUnit unit); //
take a vanilla CountDownLatch and apply custom await logic
}{noformat}
It may be possible to implement the above with #waitObject, or maybe it is more
involved and requires a dedicated method on the Time interface, i'm not sure.
We'd need to explore more of the LockSupport, AbstractQueuedSynchronizer, and
etc to figure out how viable this is to do for other synchronization primitives
(Semaphore, ReentrantLock, KafkaCompletableFuture, etc). I also haven't
considered how this idea would interact with virtual threads.
But it would be really cool to have Kafka and Consumers able to completely use
mocked time, instead of mixing mocked and real time. Maybe the Time interface
can be improved to make this possible.
> Consider inlineing Time#waitObject to ProducerMetadata#awaitUpdate
> ------------------------------------------------------------------
>
> Key: KAFKA-16937
> URL: https://issues.apache.org/jira/browse/KAFKA-16937
> Project: Kafka
> Issue Type: Improvement
> Reporter: Chia-Ping Tsai
> Assignee: PoAn Yang
> Priority: Minor
>
> Time#waitObject is implemented by while-loop and it is used by
> `ProducerMetadata` only. Hence, this jira can include following changes:
> 1. move `Time#waitObject` to `ProducerMetadata#awaitUpdate`
> 2. ProducerMetadata#awaitUpdate can throw "exact" TimeoutException [0]
> [0]
> https://github.com/apache/kafka/blob/23fe71d579f84d59ebfe6d5a29e688315cec1285/clients/src/main/java/org/apache/kafka/clients/producer/KafkaProducer.java#L1176
--
This message was sent by Atlassian Jira
(v8.20.10#820010)