...
Current state: Under Discussion
Discussion thread: here
JIRA: Kafka-14768
Motivation
...
So, This KIP try to raise one solution to improve it.
Public Interfaces
The solution is that we can provide one method for metadata fetch into Producer. When the application restarted/started, it can call it before mark the application is ready for handle requests. So, when the first request/record be handled. the metadata had been fetched so that it's handle's speed will be much faster.
Code Block |
---|
public Cluster getCluster(String topic, long maxBlockTimeMs) {
Objects.requireNonNull(topic, "topic cannot be null");
try {
return waitOnMetadata(topic, null, time.milliseconds(), maxBlockTimeMs).cluster;
} catch (InterruptedException e) {
throw new InterruptException(e);
} |
note: waitOnMetadata(topic, null, time.milliseconds(), maxBlockTimeMs) is the existed method with provide modifier.
Public Interfaces
add new interface with tiny refactor which reduce the duplicated code.
Cluster getCluster(String topic, long maxBlockTimeMs);
Proposed Changes
The core code had been listed in Motivation part.
Compatibility, Deprecation, and Migration Plan
...
- What impact (if any) will there be on existing users?
no impact on existed users. - If we are changing behavior how will we phase out the older behavior?
no changing older behavior. - If we need special migration tools, describe them here.
no. - When will we remove the existing behavior?
no need to remove.
Test Plan
Compare the first record's send time cost to see if any improvement happens.
Rejected Alternatives
maybe we can provide one dedicated method with more naming instead of "getCluster".