Skip to content

Conversation

@li4wang
Copy link
Contributor

@li4wang li4wang commented Sep 27, 2025

The existing ZooKeeper client architecture relies on StaticHostProvider, which lacks auto service discovery capabilities and must wait for external mechanisms to push server list updates, either through manual configuration changes or reconfig notifications.

This PR provides a HostProvider implementation that performs dynamic service discovery based on DNS SRV record. The following is a summary of the changes:

  1. DnsSrvHostProvider: New HostProvider implementation that performs DNS SRV lookups to discover ZooKeeper servers
  2. HostConnectionManager: Extracted connection management and reconfiguration logic from StaticHostProvider into a reusable component
  3. StaticHostProvider Refactoring: Modified to use HostConnectionManager for consistent connection handling across providers
  4. ConnectionType: New enum that represents the type of connection resolutions
  5. Configuration: Added zookeeper.hostProvider.dnsSrvRefreshIntervalMs client property for DNS refresh intervals

Copy link
Contributor

@anmolnar anmolnar left a comment

Choose a reason for hiding this comment

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

Where are the changes of StaticHostProvider?

@li4wang
Copy link
Contributor Author

li4wang commented Dec 15, 2025

Where are the changes of StaticHostProvider?

I thought it would be better to check in the updated StaticHostProvider later in a separate PR, as the changes are code refactoring, so I took it out from this PR.

However, I noticed that StaticHostProvider is mentioned in the summary of this PR, let me just added it back to avoid any confusion.

@li4wang li4wang force-pushed the ZOOKEEPER-4956 branch 8 times, most recently from dc2bfe6 to 6e01933 Compare December 17, 2025 03:54
@li4wang
Copy link
Contributor Author

li4wang commented Dec 17, 2025

Hi @anmolnar, thanks a lot for your feedback. I've responded to all the comments. Can you please take a look at the updated PR? Thanks.

Copy link
Contributor

@anmolnar anmolnar left a comment

Choose a reason for hiding this comment

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

Just a few more comments, otherwise looks good to me.

*
* @return the ConnectionType supported by this provider
*/
default ConnectionType getSupportedConnectionType() {
Copy link
Contributor

Choose a reason for hiding this comment

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

Where do you use this new field? Why is this information important?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Removed, not needed any more.

* This is an internal enum used for connection string and provider validation.
*/
@InterfaceAudience.Private
public enum ConnectionType {
Copy link
Contributor

Choose a reason for hiding this comment

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

I can't find usages of this new type in your code.

@li4wang li4wang force-pushed the ZOOKEEPER-4956 branch 4 times, most recently from 757b86d to 654c6c1 Compare December 19, 2025 08:00
@anmolnar
Copy link
Contributor

Please see my comments on the other pr #2321
I think we should merge these patches into a single one.

@li4wang
Copy link
Contributor Author

li4wang commented Dec 19, 2025

I think we should merge these patches into a single one.

Yes, working on merging #2321 into this one right now.

@li4wang li4wang force-pushed the ZOOKEEPER-4956 branch 5 times, most recently from d101e10 to c5449f8 Compare December 23, 2025 00:31
…ynamic server discovery

Author: Li Wang <liwang@apple.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants