-
Notifications
You must be signed in to change notification settings - Fork 13.6k
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
KIP-476: Add new getAdmin method to KafkaClientSupplier #7162
Conversation
It would be a binary incompatible change to change KafkaClientSupplier.getAdminClient to return the interface, rather than AdminClient. To avoid this, a new method getAdmin is introduced and the old getAdminClient is deprecated.
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.
Overall LGTM.
Note, that this is a public API change and should be included in the KIP. Hence, please update the KIP accordingly and send an "FYI" e-mail to the VOTE thread to point out this minor change (don't think we need to re-vote; it's just to give people a notification in case anyone want to change their vote)
@@ -35,9 +36,22 @@ | |||
* | |||
* @param config Supplied by the {@link java.util.Properties} given to the {@link KafkaStreams} | |||
* @return an instance of {@link AdminClient} | |||
* @deprecated Not used. Implement {@link #getAdmin} instead |
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.
The comment is a little "miss leading" because one still needs to implement this method... Should be add a default implementation that throws an exception?
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'll switch this to have a default impl that throws:
throw new UnsupportedOperationException("Direct use of this method is deprecated. The method will be removed in a future release.");
This means anyone new implementing the interface won't need to implement this method, and calling it will throw, but for any existing implementations they can continue to implement and call as before, though it will generate compiler warnings as its deprecated.
The only downside of this is that now both the old getAdminClient
and new getAdmin
have default implementations that throw. I guess this is OK, as when we remove the old method we can remove the default impl from the new method.
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.
That makes sense.
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 think the main downside is that type safety was lost. The compiler doesn't help you if you forget to implement the method.
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 agree, but...
Most people use the inbuilt suppliers, so aren't affected.
Existing users that have implemented their own versions will work as-is, though they'll get a deprecated warning, which they can choose to clean up by changing getAdminClient
to getAdmin
in their impl, i.e. minor change.
New users might not initially implement either method, but will quickly run into runtime exceptions and rectify the situation.
Plus, this state is only maintained until the next major version bump, (which may be a long time of course), where we can then clean up the old and remove the default from the new.
Thoughts?
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.
Assuming this interface is not implemented often, that seems OK.
...s/src/main/java/org/apache/kafka/streams/processor/internals/DefaultKafkaClientSupplier.java
Outdated
Show resolved
Hide resolved
streams/src/test/java/org/apache/kafka/test/MockClientSupplier.java
Outdated
Show resolved
Hide resolved
streams/src/test/java/org/apache/kafka/test/MockClientSupplier.java
Outdated
Show resolved
Hide resolved
retest this please |
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.
One nit to make the error message more readable.
Overall LGTM.
Call for second review @guozhangwang @bbejeck @vvcephei @ableegoldman @cadonna @abbccdda
@Deprecated | ||
default AdminClient getAdminClient(final Map<String, Object> config) { | ||
throw new UnsupportedOperationException("Direct use of this method is deprecated. " + | ||
"Implementations of KafkaClientSupplier should implement the getAdmin method instead. " + |
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: getAdmin method
-> getAdmin() method
?
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 an incompatible change, why are we doing it in a minor release?
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 see, the assumption is that existing implementations will have overriden it.
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.
Yeah, it's not incompatible with our in-built impls or any existing user impls.
Java 11 / 2.12: Retest this please. |
retest this please |
JDK 11 / 2.13 - test log unavailable retest this please |
LGTM!. |
Java 11 / 2.12:
Java 11 / 2.13: Java 8 passed. |
KIP-476 saw the introduction of a new
Admin
interface to replace the use of theAdminClient
abstract class. A key driver for this was to allow the use of dynamic proxies for the admin client supplied to Kafka streams via theKafkaClientSupplier
.Unfortunately, it would be a binary incompatible change to change
KafkClientSupplier.getAdminClient
to return theAdmin
interface, rather thanAdminClient
. See #7157 which reverted the change.To avoid this, I've added a new method
getAdmin
and deprecated the oldgetAdminClient
.The new
getAdmin
method has a default implementation that simply calls the oldgetAdminClient
method. BothDefaultKafkaClientSupplier
andMockClientSupplier
implement the new method. All KS code has been switched to call the new method.This has the benefit of being binary compatible, but does leave users still needing to implement the, now deprecated,
getAdminClient
method, even though it's not called by KS code.Thoughts?
Committer Checklist (excluded from commit message)