Skip to content

Comments

[automatic failover] Add Runtime Weight Management for MultiDbClient Endpoints#4435

Merged
atakavci merged 10 commits intoredis:masterfrom
atakavci:failover/dynamicWeights
Feb 24, 2026
Merged

[automatic failover] Add Runtime Weight Management for MultiDbClient Endpoints#4435
atakavci merged 10 commits intoredis:masterfrom
atakavci:failover/dynamicWeights

Conversation

@atakavci
Copy link
Contributor

Summary

Adds the ability to get and set endpoint weights at runtime in MultiDbClient.

Changes

  • Added getWeight(Endpoint) and setWeight(Endpoint, float) methods to MultiDbClient
  • Made weight field mutable in MultiDbConnectionProvider.Database with a setter
  • Added unit tests for weight get/set operations

Use Case

Allows dynamic adjustment of endpoint priority for failover operations without recreating the client.

Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

This PR adds runtime weight management capabilities to MultiDbClient, enabling dynamic adjustment of endpoint priorities for failover operations without recreating the client. The implementation makes the weight field mutable and exposes getter/setter methods through the public API.

Changes:

  • Added getWeight(Endpoint) and setWeight(Endpoint, float) public methods to MultiDbClient for runtime weight management
  • Changed the weight field from final to mutable in MultiDbConnectionProvider.Database and added a setter method
  • Added comprehensive unit tests in both MultiDbClientTest and MultiDbConnectionProviderDynamicEndpointUnitTest to verify weight get/set functionality

Reviewed changes

Copilot reviewed 4 out of 4 changed files in this pull request and generated 11 comments.

File Description
src/main/java/redis/clients/jedis/MultiDbClient.java Added public API methods getWeight() and setWeight() to enable runtime weight management for database endpoints
src/main/java/redis/clients/jedis/mcf/MultiDbConnectionProvider.java Made the weight field mutable by removing final modifier and added setWeight() setter in the Database class
src/test/java/redis/clients/jedis/MultiDbClientTest.java Added integration tests for weight get/set operations including zero weight and multiple updates
src/test/java/redis/clients/jedis/mcf/MultiDbConnectionProviderDynamicEndpointUnitTest.java Added unit tests for weight get/set operations with different weight values

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

Copilot reviewed 13 out of 13 changed files in this pull request and generated 3 comments.


💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Copy link
Collaborator

@ggivo ggivo left a comment

Choose a reason for hiding this comment

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

Change LGTM,
But opened a question for me.

I’m wondering whether we need a way to explicitly trigger re-selection of the best matching DB after the weights change, or if relying on failback (when enabled) is sufficient to eventually select the highest-priority node based on the updated weights.

@atakavci
Copy link
Contributor Author

explicitly trigger re-selection of the best matching DB after the weights change

sound like a good improvement. i got other things in mind with the API; like improving accessibility with MultiDbClient instance for what is exposed from connection provider.
Will work on those in a seperate PR. thanks @ggivo

@atakavci atakavci merged commit be47c2f into redis:master Feb 24, 2026
19 of 20 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants