[automatic failover] Add Runtime Weight Management for MultiDbClient Endpoints#4435
[automatic failover] Add Runtime Weight Management for MultiDbClient Endpoints#4435atakavci merged 10 commits intoredis:masterfrom
Conversation
- add tests - format
There was a problem hiding this comment.
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)andsetWeight(Endpoint, float)public methods toMultiDbClientfor runtime weight management - Changed the
weightfield fromfinalto mutable inMultiDbConnectionProvider.Databaseand added a setter method - Added comprehensive unit tests in both
MultiDbClientTestandMultiDbConnectionProviderDynamicEndpointUnitTestto 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.
src/test/java/redis/clients/jedis/mcf/MultiDbConnectionProviderDynamicEndpointUnitTest.java
Outdated
Show resolved
Hide resolved
src/test/java/redis/clients/jedis/mcf/MultiDbConnectionProviderDynamicEndpointUnitTest.java
Show resolved
Hide resolved
src/test/java/redis/clients/jedis/mcf/MultiDbConnectionProviderDynamicEndpointUnitTest.java
Show resolved
Hide resolved
…g to actual endpoints - add unit test - assert weight not zero
There was a problem hiding this comment.
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.
src/test/java/redis/clients/jedis/mcf/MultiDbConnectionProviderDynamicEndpointUnitTest.java
Show resolved
Hide resolved
ggivo
left a comment
There was a problem hiding this comment.
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.
sound like a good improvement. i got other things in mind with the API; like improving accessibility with |
Summary
Adds the ability to get and set endpoint weights at runtime in
MultiDbClient.Changes
getWeight(Endpoint)andsetWeight(Endpoint, float)methods toMultiDbClientweightfield mutable inMultiDbConnectionProvider.Databasewith a setterUse Case
Allows dynamic adjustment of endpoint priority for failover operations without recreating the client.