Skip to content

Conversation

@ggivo
Copy link
Collaborator

@ggivo ggivo commented Oct 7, 2025

Summary

This PR refactors the MultiDb API to improve clarity and maintainability through two major changes:

  1. Renamed endpoint-related methods to use database-centric terminology
  2. Encapsulated retry and circuit breaker configuration into dedicated nested config classes

Changes

1. Endpoint → Database Terminology (Commits: "Rename MultiDbClient endpoint related methods", "Methods Renamed in MultiDbConfig.Builder")

Renamed all endpoint-related methods to use "database" terminology for better clarity:

MultiDbClient methods:

  • addEndpoint()addDatabase()
  • removeEndpoint()removeDatabase()
  • forceActiveEndpoint()forceActiveDatabase()
  • getActiveEndpoint()getActiveDatabaseEndpoint()
  • getEndpoints()getDatabaseEndpoints()

MultiDbConfig.Builder methods:

  • endpoint()database() (both overloaded variants)

2. RetryConfig Encapsulation

  • Created MultiDbConfig.RetryConfig nested class with builder pattern
  • Removed individual retry fields and methods:
    • retryMaxAttemptsRetryConfig.maxAttempts
    • retryWaitDurationRetryConfig.waitDuration
    • retryWaitDurationExponentialBackoffMultiplierRetryConfig.exponentialBackoffMultiplier
    • retryIncludedExceptionListRetryConfig.includedExceptionList
    • retryIgnoreExceptionListRetryConfig.ignoreExceptionList
  • Added single commandRetry property with commandRetry(RetryConfig) builder method

3. CircuitBreakerConfig Encapsulation

  • Created MultiDbConfig.CircuitBreakerConfig nested class with builder pattern
  • Removed individual circuit breaker fields and methods:
    • circuitBreakerFailureRateThresholdCircuitBreakerConfig.failureRateThreshold
    • circuitBreakerSlidingWindowSizeCircuitBreakerConfig.slidingWindowSize
    • circuitBreakerMinNumOfFailuresCircuitBreakerConfig.minNumOfFailures
    • circuitBreakerIncludedExceptionListCircuitBreakerConfig.includedExceptionList
    • circuitBreakerIgnoreExceptionListCircuitBreakerConfig.ignoreExceptionList
  • Added single failureDetector property with failureDetector(CircuitBreakerConfig) builder method

4. Implementation Updates

  • Updated MultiDbConnectionProvider with helper methods:
    • buildRetryConfig() - converts Jedis RetryConfig to Resilience4j RetryConfig
    • buildCircuitBreakerConfig() - converts Jedis CircuitBreakerConfig to Resilience4j CircuitBreakerConfig
  • Updated CircuitBreakerThresholdsAdapter to use new API
  • Preserved all original javadoc documentation with cross-references updated

5. Documentation Updates

  • Updated all code examples in javadoc (4 files)
  • Updated docs/failover.md with new API examples
  • Maintained all inline comments and explanations

6. Test Updates

  • Updated all test files to use new terminology and configuration API
  • All tests pass successfully

API Changes

Endpoint → Database Renaming

Before:

MultiDbClient client = ...;
client.addEndpoint(databaseConfig);
client.removeEndpoint(endpoint);
client.forceActiveEndpoint(endpoint);
Endpoint active = client.getActiveEndpoint();
List<Endpoint> endpoints = client.getEndpoints();

MultiDbConfig.builder()
    .endpoint(databaseConfig)
    .build();

After:

MultiDbClient client = ...;
client.addDatabase(databaseConfig);
client.removeDatabase(endpoint);
client.forceActiveDatabase(endpoint);
Endpoint active = client.getActiveDatabaseEndpoint();
List<Endpoint> endpoints = client.getDatabaseEndpoints();

MultiDbConfig.builder()
    .database(databaseConfig)
    .build();

Configuration changes

Before

MultiDbConfig.builder()
    .retryMaxAttempts(3)
    .retryWaitDuration(500)
    .retryWaitDurationExponentialBackoffMultiplier(2)
    .circuitBreakerSlidingWindowSize(3)
    .circuitBreakerMinNumOfFailures(2)
    .circuitBreakerFailureRateThreshold(50f)
    .build();

After (New API):

MultiDbConfig.builder()
    .commandRetry(MultiDbConfig.RetryConfig.builder()
        .maxAttempts(3)
        .waitDuration(500)
        .exponentialBackoffMultiplier(2)
        .build())
    .failureDetector(MultiDbConfig.CircuitBreakerConfig.builder()
        .slidingWindowSize(3)
        .minNumOfFailures(2)
        .failureRateThreshold(50f)
        .build())
    .build();

@ggivo ggivo requested a review from Copilot October 7, 2025 14:09
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 refactors the MultiDb API to improve clarity and maintainability through two main changes: renaming endpoint-related methods to use database-centric terminology, and encapsulating retry and circuit breaker configuration into dedicated nested config classes.

  • Renamed all endpoint-related methods to use "database" terminology (e.g., addEndpoint()addDatabase())
  • Encapsulated retry configuration into a dedicated RetryConfig nested class with builder pattern
  • Encapsulated circuit breaker configuration into a dedicated CircuitBreakerConfig nested class with builder pattern

Reviewed Changes

Copilot reviewed 16 out of 16 changed files in this pull request and generated 2 comments.

Show a summary per file
File Description
src/test/java/redis/clients/jedis/scenario/ActiveActiveFailoverTest.java Updated test to use new database API and nested config builders
src/test/java/redis/clients/jedis/misc/AutomaticFailoverTest.java Updated test to use new database API and nested config builders
src/test/java/redis/clients/jedis/mcf/MultiDbConnectionProviderTest.java Updated test to use new database API and nested config builders
src/test/java/redis/clients/jedis/mcf/MultiDbCircuitBreakerThresholdsTest.java Updated test to use new database API and nested config builders
src/test/java/redis/clients/jedis/mcf/HealthCheckIntegrationTest.java Updated test to use new database API and nested config builders
src/test/java/redis/clients/jedis/mcf/DefaultValuesTest.java Updated test to verify default values through new API structure
src/test/java/redis/clients/jedis/mcf/DatabaseEvaluateThresholdsTest.java Updated test to use new nested config builders
src/test/java/redis/clients/jedis/mcf/ActiveActiveLocalFailoverTest.java Updated test to use new database API and nested config builders
src/test/java/redis/clients/jedis/failover/FailoverIntegrationTest.java Updated test to use new database API and nested config builders
src/test/java/redis/clients/jedis/MultiDbClientTest.java Updated test method names and API calls to use database terminology
src/main/java/redis/clients/jedis/mcf/MultiDbConnectionProvider.java Added helper methods for building Resilience4j configs and updated to use new API
src/main/java/redis/clients/jedis/mcf/CircuitBreakerThresholdsAdapter.java Updated to use new nested config structure
src/main/java/redis/clients/jedis/builders/MultiDbClientBuilder.java Updated javadoc examples to use new API
src/main/java/redis/clients/jedis/MultiDbConfig.java Added nested RetryConfig and CircuitBreakerConfig classes with builders
src/main/java/redis/clients/jedis/MultiDbClient.java Renamed methods and updated javadoc to use database terminology
docs/failover.md Updated documentation examples to use new API

Tip: Customize your code reviews with copilot-instructions.md. Create the file or learn how to get started.

@ggivo ggivo marked this pull request as ready for review October 7, 2025 14:35
@ggivo ggivo added the breakingchange Pull request that has breaking changes. Must include the breaking behavior in release notes. label Oct 7, 2025
@ggivo ggivo changed the title Refactor MultiDb API: Rename endpoint methods to database and encapsulate retry/circuit breaker configuration [automatic failover] Refactor MultiDb API: Rename endpoint methods to database and encapsulate retry/circuit breaker configuration Oct 7, 2025
@ggivo ggivo changed the base branch from ggivo/multidb-api-rename to master October 7, 2025 15:38
ggivo added 8 commits October 7, 2025 18:47
    - MultiDbClient::addEndpoint -> MultiDbClient::addDatabase
    - MultiDbClient::forceActiveEndpoint -> MultiDbClient::forceActiveDatabase
    - MultiDbClient::removeEndpoint -> MultiDbClient::removeDatabase
    - MultiDbClient::getActiveEndpoint → MultiDbClient::getActiveDatabaseEndpoint
    - MultiDbClient::getEndpoints →  MultiDbClient::getDatabaseEndpoints
 - endpoint(DatabaseConfig databaseConfig) → database(DatabaseConfig databaseConfig)
 - endpoint(Endpoint endpoint, float weight, JedisClientConfig clientConfig) → database(Endpoint endpoint, float weight, JedisClientConfig clientConfig)
 - Related retry settings grouped together
 - RetryConfig class created with  builder pattern

Example usage
MultiDbConfig.RetryConfig.builder()
         .maxAttempts(5)
         .waitDuration(1000)
         .exponentialBackoffMultiplier(2)
         .includedExceptionList(Arrays.asList(JedisConnectionException.class))
         .build())
 - Related cb settings grouped together

Example usage
.failureDetector(MultiDbConfig.CircuitBreakerConfig.builder()
        .slidingWindowSize(3)
        .minNumOfFailures(2)
        .failureRateThreshold(50f)
        .build())
@ggivo ggivo force-pushed the ggivo/multidb-api-rename-2 branch from fb4b4b1 to 84712d7 Compare October 7, 2025 15:48
@ggivo ggivo requested a review from Copilot October 7, 2025 15:48
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 17 out of 17 changed files in this pull request and generated 2 comments.


Tip: Customize your code reviews with copilot-instructions.md. Create the file or learn how to get started.

ggivo and others added 2 commits October 7, 2025 18:52
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
@github-actions
Copy link

github-actions bot commented Oct 7, 2025

Test Results

   283 files  ±0     283 suites  ±0   11m 35s ⏱️ +2s
10 075 tests ±0  10 030 ✅ +411  45 💤  - 411  0 ❌ ±0 
 2 713 runs  ±0   2 713 ✅ ±  0   0 💤 ±  0  0 ❌ ±0 

Results for commit 7f327e6. ± Comparison against base commit 14356c4.

This pull request removes 21 and adds 21 tests. Note that renamed tests count towards both.
redis.clients.jedis.MultiDbClientTest ‑ testAddRemoveEndpointWithDatabaseConfig
redis.clients.jedis.MultiDbClientTest ‑ testAddRemoveEndpointWithEndpointInterface
redis.clients.jedis.MultiDbClientTest ‑ testForceActiveEndpoint
redis.clients.jedis.MultiDbClientTest ‑ testForceActiveEndpointWithNonExistingEndpoint
redis.clients.jedis.MultiDbClientTest ‑ testForceActiveEndpointWithNonHealthyEndpoint
redis.clients.jedis.failover.FailoverIntegrationTest ‑ testManualFailoverNewCommandsAreSentToActiveCluster
redis.clients.jedis.mcf.FailbackMechanismIntegrationTest ‑ testFailbackToHigherWeightCluster
redis.clients.jedis.mcf.FailbackMechanismIntegrationTest ‑ testFailbackToHigherWeightClusterImmediately
redis.clients.jedis.mcf.FailbackMechanismIntegrationTest ‑ testGracePeriodDisablesClusterOnUnhealthy
redis.clients.jedis.mcf.FailbackMechanismIntegrationTest ‑ testGracePeriodReEnablesClusterAfterPeriod
…
redis.clients.jedis.MultiDbClientTest ‑ testAddRemoveDatabaseWithDatabaseConfig
redis.clients.jedis.MultiDbClientTest ‑ testAddRemoveDatabaseWithEndpointInterface
redis.clients.jedis.MultiDbClientTest ‑ testForceActiveDatabase
redis.clients.jedis.MultiDbClientTest ‑ testForceActiveDatabaseWithNonExistingEndpoint
redis.clients.jedis.MultiDbClientTest ‑ testForceActiveDatabaseWithNonHealthyEndpoint
redis.clients.jedis.failover.FailoverIntegrationTest ‑ testManualFailoverNewCommandsAreSentToActiveDatabase
redis.clients.jedis.mcf.FailbackMechanismIntegrationTest ‑ testFailbackToHigherWeightDatabase
redis.clients.jedis.mcf.FailbackMechanismIntegrationTest ‑ testFailbackToHigherWeightDatabaseImmediately
redis.clients.jedis.mcf.FailbackMechanismIntegrationTest ‑ testGracePeriodDisablesDatabaseOnUnhealthy
redis.clients.jedis.mcf.FailbackMechanismIntegrationTest ‑ testGracePeriodReEnablesDatabaseAfterPeriod
…

♻️ This comment has been updated with latest results.

@ggivo
Copy link
Collaborator Author

ggivo commented Oct 8, 2025

run scenario tests

@uglide
Copy link
Contributor

uglide commented Oct 8, 2025

Testcase Errors Failures Skipped Total
redis.clients.jedis.scenario.ConnectionInterruptionTest 0 0 0 4

---- Details for maintainers

Copy link
Contributor

@atakavci atakavci left a comment

Choose a reason for hiding this comment

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

as i understand these changes will go into GA, so lets replace as much as we can

ggivo and others added 3 commits October 8, 2025 13:53
Co-authored-by: atakavci <a_takavci@yahoo.com>
Co-authored-by: atakavci <a_takavci@yahoo.com>
Copy link
Contributor

@atakavci atakavci left a comment

Choose a reason for hiding this comment

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

LGTM!

@ggivo ggivo merged commit 6a4a94b into master Oct 8, 2025
14 checks passed
@ggivo ggivo added the feature label Oct 10, 2025
@ggivo ggivo deleted the ggivo/multidb-api-rename-2 branch October 10, 2025 06:49
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

breakingchange Pull request that has breaking changes. Must include the breaking behavior in release notes. feature

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants