Skip to content
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

Merged
merged 4 commits into from
Aug 22, 2019

Conversation

big-andy-coates
Copy link
Contributor

KIP-476 saw the introduction of a new Admin interface to replace the use of the AdminClient abstract class. A key driver for this was to allow the use of dynamic proxies for the admin client supplied to Kafka streams via the KafkaClientSupplier.

Unfortunately, it would be a binary incompatible change to change KafkClientSupplier.getAdminClient to return the Admin interface, rather than AdminClient. See #7157 which reverted the change.

To avoid this, I've added a new method getAdmin and deprecated the old getAdminClient.

The new getAdmin method has a default implementation that simply calls the old getAdminClient method. Both DefaultKafkaClientSupplier and MockClientSupplier 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)

  • Verify design and implementation
  • Verify test coverage and CI build status
  • Verify documentation (including upgrade notes)

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.
Copy link
Member

@mjsax mjsax left a 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
Copy link
Member

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?

Copy link
Contributor Author

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.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That makes sense.

Copy link
Contributor

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.

Copy link
Contributor Author

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?

Copy link
Contributor

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.

@big-andy-coates
Copy link
Contributor Author

retest this please

Copy link
Member

@mjsax mjsax left a 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. " +
Copy link
Member

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 ?

Copy link
Contributor

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?

Copy link
Contributor

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.

Copy link
Contributor Author

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.

@mjsax
Copy link
Member

mjsax commented Aug 7, 2019

Java 11 / 2.12: kafka.server.DescribeLogDirsRequestTest.testDescribeLogDirsRequest
Java 11 / 2.13: kafka.api.ConsumerBounceTest.testRollingBrokerRestartsWithSmallerMaxGroupSizeConfigDisruptsBigGroup
Java 8: kafka.api.SaslPlainSslEndToEndAuthorizationTest.testNoDescribeProduceOrConsumeWithoutTopicDescribeAcl

Retest this please.

@big-andy-coates
Copy link
Contributor Author

retest this please

@big-andy-coates
Copy link
Contributor Author

JDK 11 / 2.13 - test log unavailable

retest this please

@guozhangwang
Copy link
Contributor

LGTM!.

@mjsax
Copy link
Member

mjsax commented Aug 22, 2019

Java 11 / 2.12:

kafka.api.SaslGssapiSslEndToEndAuthorizationTest.testNoDescribeProduceOrConsumeWithoutTopicDescribeAcl
org.apache.kafka.streams.state.internals.RocksDBGenericOptionsToDbOptionsColumnFamilyOptionsAdapterTest.shouldForwardAllDbOptionsCalls

Java 11 / 2.13: org.apache.kafka.connect.integration.RebalanceSourceConnectorsIntegrationTest.testReconfigConnector

Java 8 passed.

@mjsax mjsax merged commit 35bc53c into apache:trunk Aug 22, 2019
@big-andy-coates big-andy-coates deleted the KIP_476_ks_get_admin branch August 23, 2019 08:36
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
4 participants