Skip to content

Commit f8de2fe

Browse files
uglideggivoCopilotatakavci
authored
Add builders for classes based on UnifiedJedis (#4263)
* Setup test infra for automatic failover tests * Add toxyproxy * Add test endpoints * Add example tests * [automatic-failover] Enforce formatting for automatic failover codebase (#4176) * enforce formating for mcf * enforce formating for mcf * Trigger integration test jobs feature branches * [automatic failover] Improve failover resilience by evaluating circuit breaker before retries (#4178) * fix: Change evaluation order of circuit breaker and retry mechanisms This commit modifies the order in which circuit breaker and retry mechanisms are evaluated during failover scenarios. Previously, the circuit breaker was applied after all retries were exhausted, which could delay failover in unstable network conditions. Now, the circuit breaker counts each connection error separately, even during retry attempts. * format * format * use java-8 compatible formater version * fix AutomaticFailoverTest * formating * [automatic-failover] Implement failover retry for in-flight commands (#4175) * Implement failover retry for in-flight commands This change adds support for retrying in-flight commands when a Redis connection fails and the client automatically fails over to another cluster. The feature is configurable through the FailoverOptions builder. Key changes: - Added retryFailedInflightCommands option to FailoverOptions - Implemented retry logic in CircuitBreakerCommandExecutor - Added integration tests to verify both retry and no-retry behavior - Created utility methods for test setup and configuration This enhancement improves resilience for long-running commands like blocking operations, allowing them to transparently continue on the failover cluster without client-side errors. * Update src/main/java/redis/clients/jedis/mcf/CircuitBreakerCommandExecutor.java Co-authored-by: Copilot <[email protected]> # Conflicts: # src/main/java/redis/clients/jedis/mcf/CircuitBreakerCommandExecutor.java * format format & clean-up * fix FailoverIntegrationTest.testInflightCommandsAreNotRetriedAfterFailover blpop timeout should be less than async command timeout to prevent completing with java.util.concurrent.TimeoutException instead of actuall command failure * Address comments from review - rename retryFailedInflightCommands->retryOnFailover - remove check for CB in OPEN state * remove unused method --------- Co-authored-by: Copilot <[email protected]> * [automatic-failover] Fix formatting for anticipated AA Failover changes (#4183) * fix formatting for anticipated failover changes * additional formatting to cover given folders * [automatic failover] Implement HealtStatusManager + weighted endpoints (#4189) * - weighted cluster seleciton - Healtstatus manager with initial listener and registration logic - pluggable health checker strategy introduced, these are draft NoOpStrategy, EchoStrategy, LagAwareStrategy, - fix failing tests impacted from weighted clusters * - add builder for ClusterConfig - add echo ot CommandObjects and UnifiedJEdis - improve StrategySupplier by accepting jedisclientconfig - adapt EchoStrategy to StrategySupplier. Now it handles the creation of connection by accepting endpoint and JedisClientConfig - make healthchecks disabled by default - drop noOpStrategy - add unit&integration tests for health check * - fix naming * clean up and mark override methods * fix link in javadoc * fix formatting * - fix double registered listeners in healtstatusmgr - clear redundant catch - replace failover options and drop failoveroptions class - remove forced_unhealthy from healthstatus - fix failback check - add disabled flag to cluster - update/fix related tests * Update src/main/java/redis/clients/jedis/mcf/EchoStrategy.java Co-authored-by: Copilot <[email protected]> --------- Co-authored-by: Copilot <[email protected]> * [automatic failover] Implement add/remove endpoints (#4200) * - weighted cluster seleciton - Healtstatus manager with initial listener and registration logic - pluggable health checker strategy introduced, these are draft NoOpStrategy, EchoStrategy, LagAwareStrategy, - fix failing tests impacted from weighted clusters * - add builder for ClusterConfig - add echo ot CommandObjects and UnifiedJEdis - improve StrategySupplier by accepting jedisclientconfig - adapt EchoStrategy to StrategySupplier. Now it handles the creation of connection by accepting endpoint and JedisClientConfig - make healthchecks disabled by default - drop noOpStrategy - add unit&integration tests for health check * - fix naming * clean up and mark override methods * fix link in javadoc * fix formatting * - fix double registered listeners in healtstatusmgr - clear redundant catch - replace failover options and drop failoveroptions class - remove forced_unhealthy from healthstatus - fix failback check - add disabled flag to cluster - update/fix related tests * Update src/main/java/redis/clients/jedis/mcf/EchoStrategy.java Co-authored-by: Copilot <[email protected]> * - add remove endpoints * - replace cluster disabled with failbackCandidate - replace failback enabled with failbacksupported in client - fix formatting - set defaults * - remove failback candidate - fix failing tests * - fix remove logic - fix failing tests --------- Co-authored-by: Copilot <[email protected]> * [automatic failover] Implement failback with given grace period (#4204) * - weighted cluster seleciton - Healtstatus manager with initial listener and registration logic - pluggable health checker strategy introduced, these are draft NoOpStrategy, EchoStrategy, LagAwareStrategy, - fix failing tests impacted from weighted clusters * - add builder for ClusterConfig - add echo ot CommandObjects and UnifiedJEdis - improve StrategySupplier by accepting jedisclientconfig - adapt EchoStrategy to StrategySupplier. Now it handles the creation of connection by accepting endpoint and JedisClientConfig - make healthchecks disabled by default - drop noOpStrategy - add unit&integration tests for health check * - fix naming * clean up and mark override methods * fix link in javadoc * fix formatting * - fix double registered listeners in healtstatusmgr - clear redundant catch - replace failover options and drop failoveroptions class - remove forced_unhealthy from healthstatus - fix failback check - add disabled flag to cluster - update/fix related tests * Update src/main/java/redis/clients/jedis/mcf/EchoStrategy.java Co-authored-by: Copilot <[email protected]> * - add remove endpoints * - replace cluster disabled with failbackCandidate - replace failback enabled with failbacksupported in client - fix formatting - set defaults * - remove failback candidate - fix failing tests * - fix remove logic - fix failing tests * - periodic failback checks - introduce graceperiod - fix issue when CB is forced_open and gracePeriod is completed * - format * - fix timing issue --------- Co-authored-by: Copilot <[email protected]> * [automatic failover] Implement wait on healthCheck results during client init (#4207) * - weighted cluster seleciton - Healtstatus manager with initial listener and registration logic - pluggable health checker strategy introduced, these are draft NoOpStrategy, EchoStrategy, LagAwareStrategy, - fix failing tests impacted from weighted clusters * - add builder for ClusterConfig - add echo ot CommandObjects and UnifiedJEdis - improve StrategySupplier by accepting jedisclientconfig - adapt EchoStrategy to StrategySupplier. Now it handles the creation of connection by accepting endpoint and JedisClientConfig - make healthchecks disabled by default - drop noOpStrategy - add unit&integration tests for health check * - fix naming * clean up and mark override methods * fix link in javadoc * fix formatting * - fix double registered listeners in healtstatusmgr - clear redundant catch - replace failover options and drop failoveroptions class - remove forced_unhealthy from healthstatus - fix failback check - add disabled flag to cluster - update/fix related tests * Update src/main/java/redis/clients/jedis/mcf/EchoStrategy.java Co-authored-by: Copilot <[email protected]> * - add remove endpoints * - replace cluster disabled with failbackCandidate - replace failback enabled with failbacksupported in client - fix formatting - set defaults * - remove failback candidate - fix failing tests * - fix remove logic - fix failing tests * - periodic failback checks - introduce graceperiod - fix issue when CB is forced_open and gracePeriod is completed * - introduce StatusTracker with purpose of waiting initial healthcheck results during consturction of provider - add HealthStatus.UNKNOWN as default for Cluster - handle status changes in order of events during initialization - add tests for status tracker and orderingof events - fix impacted unit&integ tests * - introduce forceActiveCluster by duration - fix formatting * - fix failing tests by waiting on clusters to get healthy * - fix failing scenario test - downgrade logback version for slf4j compatibility - increase timeouts for faultInjector * - adressing reviews and feedback * - fix formatting * - fix formatting * - get rid of the queue and event ordering for healthstatus change in MultiClusterPooledConnectionProvider - add test for init and post init events - fix failing tests * - replace use of reflection with helper methods - fix failing tests due to method name change * - replace 'sleep' with 'await', feedback from @a-TODO-rov --------- Co-authored-by: Copilot <[email protected]> * [automatic failover] Introduce fast failover mode - a thread-sync-free approach with builders (#4226) * - weighted cluster seleciton - Healtstatus manager with initial listener and registration logic - pluggable health checker strategy introduced, these are draft NoOpStrategy, EchoStrategy, LagAwareStrategy, - fix failing tests impacted from weighted clusters * - add builder for ClusterConfig - add echo ot CommandObjects and UnifiedJEdis - improve StrategySupplier by accepting jedisclientconfig - adapt EchoStrategy to StrategySupplier. Now it handles the creation of connection by accepting endpoint and JedisClientConfig - make healthchecks disabled by default - drop noOpStrategy - add unit&integration tests for health check * - fix naming * clean up and mark override methods * fix link in javadoc * fix formatting * - fix double registered listeners in healtstatusmgr - clear redundant catch - replace failover options and drop failoveroptions class - remove forced_unhealthy from healthstatus - fix failback check - add disabled flag to cluster - update/fix related tests * Update src/main/java/redis/clients/jedis/mcf/EchoStrategy.java Co-authored-by: Copilot <[email protected]> * - add remove endpoints * - replace cluster disabled with failbackCandidate - replace failback enabled with failbacksupported in client - fix formatting - set defaults * - remove failback candidate - fix failing tests * - fix remove logic - fix failing tests * - periodic failback checks - introduce graceperiod - fix issue when CB is forced_open and gracePeriod is completed * - introduce StatusTracker with purpose of waiting initial healthcheck results during consturction of provider - add HealthStatus.UNKNOWN as default for Cluster - handle status changes in order of events during initialization - add tests for status tracker and orderingof events - fix impacted unit&integ tests * - introduce forceActiveCluster by duration - fix formatting * - fix failing tests by waiting on clusters to get healthy * - fix failing scenario test - downgrade logback version for slf4j compatibility - increase timeouts for faultInjector * - adressing reviews and feedback * - fix formatting * - fix formatting * - get rid of the queue and event ordering for healthstatus change in MultiClusterPooledConnectionProvider - add test for init and post init events - fix failing tests * - replace use of reflection with helper methods - fix failing tests due to method name change * - introduce clusterSwitchEvent and drop clusterFailover post processor - fix broken echostrategy due to connection issue - make healtthCheckStrategy closable and close on - adding fastfailover mode to config and provider - add local failover tests for total failover duration * - introduce fastfailover using objectMaker injection into connectionFactory * - polish * - cleanup * - improve healtcheck thread visibility * - introduce TrackingConnectionPool with FailFastConnectionFactory - added builders to connection and connectionFactory - introduce initializtionTracker to track list of connections during their construction. * - return broken source as usual - do not throw exception is failover already happening * - unblock waiting threads * - failover by closing the pool * - formatting * - check waiters and active/idle connections to force disconnect * - add builder to trackingconnectionpool * - fix failing tests due to mocked ctor for trackingConnectionPool * - replace initTracker with split initializtion of conn * - refactor on builders and ctors * - undo format * - clena up * - add exceptions to logs * - add max wait duration and minConsecutiveSuccessCount to healthCheckStrategy * - replace 'sleep' with 'await', feedback from @a-TODO-rov * - fix status tracker tests --------- Co-authored-by: Copilot <[email protected]> * [automatic failover] Add tests: EchoStrategy does recover on connection error (#4230) * Add tests: EchoStrategy does recover on connection error * log error's on exception * [automatic failover] Replace 'SimpleEntry' with 'HealthCheckResult' (#4236) * - replace SimpleEntry with HealthCheckResult * - format * [automatic failover] Add rate limiter to test MultiThreadedFakeApp (#4248) * Add option for rate limiter to MultiThreadedFakeApp * retrigger checks * [automatic failover] Implement lag-aware api (#4235) * - lag-aware api * - introduce healtCheckMetaConfig - add config objects for both EchoStrategy and LagAwareStrategy - make StrategySupplier interface generic - fix impacted tests * - fix issues with docs and log * Fix EchoStrategyIntegrationTest after merge * Implement resolve bdbId based on configured HostAndPort * format & merge RedisRestAPI unit tests * introduce builder for LagAwareStrategy * configurable extended-check - provide option to enable/disable lag check - default to lag-aware check with AVAILABILITY_LAG_TOLERANCE_DEFAULT of 100ms * - fix java doc issue * - formatting * -fix doc issue * - formatting * revert introduce healtCheckMetaConfig - introduces type unsafe warnings, revert till they are resovled * Add list constructor * Add option for rate limiter to MultiThreadedFakeApp * Use /v1/local/bdbs/<int:uid>/endpoint/availability - use /v1/local/bdbs/<int:uid>/endpoint/availability instead of availability address vs /v1/bdbs/<int:uid>/availability * Add builder factory method for base HealthCheckStrategy.Config * format * format * revert to /v1/bdbs/<int:uid>/availability reading again the spec /local is inteded to be used when configuring LoadBalancers * revert to /v1/bdbs/<int:uid>/availability reading again the spec /local is inteded to be used when configuring LoadBalancers * format * fix unit test after revert of local * format * Address review comments - remove misleading default value comment - renamed Config.endpoint to Config.restEndpoint - renamed dataPathAvailability -> databaseAvailability --------- Co-authored-by: ggivo <[email protected]> * [automatic failover] Refactor cluster to replace `HealthStatus` with `HealthCheck` itself (#4244) * - set sleep duration 1 ms for forceDisconnect * - refactor cluster to replace HealthStatus with HealthCheck itself * - move Endpoint to parent package * - format * - fix typo * - adjust tests with new provider behaviour with HealthCheck * Address review comments - rename getTimeout() -> getMaxWaitFor() - remove unnecessary noHealthChecks * resolve merge conflicts * format * format --------- Co-authored-by: Ivo Gaydazhiev <[email protected]> * [automatic failover] fix: health checks continue to run even after provider is closed. (#4252) * fix: health checks continue to run even after provider is closed. Closes #4251 * format * format & fix tests after merge format * [automatic failover] Improve AA failover scenario test (#4249) * Improve AA failover test * Fix endpoint name * Count failedCommandsAfterFailover * do not enforce formating on ActiveActiveFailoverTest --------- Co-authored-by: Ivo Gaydazhiev <[email protected]> * [automatic failover ]fix: only notify health status listeners on actual state changes #4255 (#4256) * fix: only notify health status listeners on actual state changes #4255 - Replace overlapping health checks with sequential execution - use wasUpdated flag to prevent false notifications from timestamp conflicts. Eliminates race conditions causing spurious failovers. Closes: #4255 * format * Update src/main/java/redis/clients/jedis/mcf/HealthCheckImpl.java Co-authored-by: atakavci <[email protected]> * revert to fixed rate health checks * fix ActiveActiveLocalFailoverTest - reduced endpoint pause to 10s to speed up test - ensure test endpoint is eavailable before startign the test (awaits up to endpoint pause time) --------- Co-authored-by: atakavci <[email protected]> * Connection.forceDisconnect should also set the connection as broken #4233 (#4258) Address: Connection.forceDisconnect should also set the connection as broken #4233 * [automatic failover] Update failover docs (#4257) * Initial draft * Cover health checks * Add javadoc's for MultiClusterClientConfig * Fix docs for health checks * Fix javadoc's * Update wordlist.txt --------- Co-authored-by: Ivo Gaydazhiev <[email protected]> * rever hbase-formatter.xml changes - ensure hbase-formatter.xml match current one in master * reformat to comply with hbase-formater rules in master * fix errors after merge - setClusterFailoverPostProcessor renamed - format AutomaticFailoverTest * format - Endpoint.java * format - ActiveActiveLocalFailoverTest - FailbackMechanismIntegrationTest - FailbackMechanismUnitTest - PeriodicFailbackTest - StatusTrackerTest format - ActiveActiveLocalFailoverTest.java * Add failover containers for testing to local test infra * Introduce Builders for classes based on UnifiedJedis * Cleanup Builders and fix minor issues * Fix formatting #1 * Improve javadocs * Enable params visibility in the CI * Remove redundant JVM flags * Guard the reflection tests Skip the reflection tests if the "with-param-names" flag is not enabled during the test run * [automatic failover] Address review comments (#4264) Address review comments - replace magic numbers in tests with constats * Add unit tests for builders * Address review comments * Add missing changes after revert * Fix error after merge - resolve cannot find symbol Error: symbol: class MultiClusterPooledConnectionProvider * Allow overriding CommandObjects in builders * Fix formatting * Pull clientConfig to the AbstractClientBuilder and remove redundant redisProtocol * Create default client config in AbstractClientBuilder Instead of creating it in createDefaultConnectionProvider() * Use builder in JedisPooled tests * Use builder in ClusterCommand tests * Fix formatting * Add missing value for maxTotalRetriesDuration * [churn] Code clean up * Use builder in SentineledConnectionProviderTest --------- Co-authored-by: ggivo <[email protected]> Co-authored-by: Copilot <[email protected]> Co-authored-by: atakavci <[email protected]>
1 parent b899f3f commit f8de2fe

29 files changed

+2107
-61
lines changed

.github/workflows/test-on-docker.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -80,9 +80,9 @@ jobs:
8080
export TEST_WORK_FOLDER=$REDIS_ENV_WORK_DIR
8181
echo $TEST_WORK_FOLDER
8282
if [ -z "$TESTS" ]; then
83-
mvn clean compile verify
83+
mvn -Dwith-param-names=true clean compile verify
8484
else
85-
mvn -Dtest=$TESTS clean verify
85+
mvn -Dwith-param-names=true -Dtest=$TESTS clean verify
8686
fi
8787
env:
8888
JVM_OPTS: "-XX:+HeapDumpOnOutOfMemoryError -XX:+ExitOnOutOfMemoryError -XX:HeapDumpPath=${{ runner.temp }}/heapdump-${{ matrix.redis_version }}.hprof"

Makefile

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -522,10 +522,10 @@ stop:
522522
test: | start mvn-test-local stop
523523

524524
mvn-test-local:
525-
@TEST_ENV_PROVIDER=local mvn -Dtest=${TEST} clean verify
525+
@TEST_ENV_PROVIDER=local mvn -Dwith-param-names=true -Dtest=${TEST} clean compile test
526526

527527
mvn-test:
528-
mvn -Dtest=${TEST} clean verify
528+
mvn -Dwith-param-names=true -Dtest=${TEST} clean compile test
529529

530530
package: | start mvn-package stop
531531

pom.xml

Lines changed: 32 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -391,7 +391,7 @@
391391
</goals>
392392
<configuration>
393393
<argLine>@{failsafeSuffixArgLine} ${JVM_OPTS}</argLine>
394-
394+
395395
<includes>
396396
<include>**/*IntegrationTest.java</include>
397397
<include>**/*IntegrationTests.java</include>
@@ -496,6 +496,7 @@
496496
<include>**/scenario/RestEndpointUtil.java</include>
497497
<include>src/main/java/redis/clients/jedis/MultiClusterClientConfig.java</include>
498498
<include>src/main/java/redis/clients/jedis/HostAndPort.java</include>
499+
<include>**/builders/*.java</include>
499500
</includes>
500501
</configuration>
501502
<executions>
@@ -576,5 +577,35 @@
576577
</plugins>
577578
</build>
578579
</profile>
580+
<profile>
581+
<id>tests-with-params</id>
582+
<activation>
583+
<property>
584+
<name>with-param-names</name>
585+
<value>true</value>
586+
</property>
587+
</activation>
588+
<build>
589+
<plugins>
590+
<plugin>
591+
<artifactId>maven-compiler-plugin</artifactId>
592+
<version>3.14.0</version>
593+
<configuration>
594+
<source>1.8</source>
595+
<target>1.8</target>
596+
<parameters>true</parameters>
597+
</configuration>
598+
</plugin>
599+
<plugin>
600+
<artifactId>maven-surefire-plugin</artifactId>
601+
<version>${maven.surefire.version}</version>
602+
<configuration>
603+
<argLine>@{argLine} ${JVM_OPTS}</argLine>
604+
</configuration>
605+
</plugin>
606+
</plugins>
607+
</build>
608+
</profile>
609+
579610
</profiles>
580611
</project>

src/main/java/redis/clients/jedis/CommandObjects.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -51,10 +51,10 @@ protected RedisProtocol getProtocol() {
5151
private JedisBroadcastAndRoundRobinConfig broadcastAndRoundRobinConfig = null;
5252
private Lock mapperLock = new ReentrantLock(true);
5353
private volatile JsonObjectMapper jsonObjectMapper;
54-
private final AtomicInteger searchDialect = new AtomicInteger(2); // DEFAULT_SEARCH_DIALECT = 2;
54+
private final AtomicInteger searchDialect = new AtomicInteger(SearchProtocol.DEFAULT_DIALECT);
5555

5656
@Experimental
57-
void setKeyArgumentPreProcessor(CommandKeyArgumentPreProcessor keyPreProcessor) {
57+
public void setKeyArgumentPreProcessor(CommandKeyArgumentPreProcessor keyPreProcessor) {
5858
this.keyPreProcessor = keyPreProcessor;
5959
}
6060

src/main/java/redis/clients/jedis/JedisCluster.java

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,11 +8,14 @@
88
import org.apache.commons.pool2.impl.GenericObjectPoolConfig;
99

1010
import redis.clients.jedis.annots.Experimental;
11+
import redis.clients.jedis.builders.ClusterClientBuilder;
1112
import redis.clients.jedis.executors.ClusterCommandExecutor;
13+
import redis.clients.jedis.executors.CommandExecutor;
1214
import redis.clients.jedis.providers.ClusterConnectionProvider;
1315
import redis.clients.jedis.csc.Cache;
1416
import redis.clients.jedis.csc.CacheConfig;
1517
import redis.clients.jedis.csc.CacheFactory;
18+
import redis.clients.jedis.providers.ConnectionProvider;
1619
import redis.clients.jedis.util.JedisClusterCRC16;
1720

1821
public class JedisCluster extends UnifiedJedis {
@@ -334,6 +337,33 @@ private JedisCluster(ClusterConnectionProvider provider, int maxAttempts, Durati
334337
super(provider, maxAttempts, maxTotalRetriesDuration, protocol, clientSideCache);
335338
}
336339

340+
private JedisCluster(CommandExecutor commandExecutor, ConnectionProvider connectionProvider, CommandObjects commandObjects, RedisProtocol redisProtocol, Cache cache) {
341+
super(commandExecutor, connectionProvider, commandObjects, redisProtocol, cache);
342+
}
343+
344+
/**
345+
* Fluent builder for {@link JedisCluster} (Redis Cluster).
346+
* <p>
347+
* Obtain an instance via {@link #builder()}.
348+
* </p>
349+
*/
350+
static public class Builder extends ClusterClientBuilder<JedisCluster> {
351+
352+
@Override
353+
protected JedisCluster createClient() {
354+
return new JedisCluster(commandExecutor, connectionProvider, commandObjects, clientConfig.getRedisProtocol(),
355+
cache);
356+
}
357+
}
358+
359+
/**
360+
* Create a new builder for configuring JedisCluster instances.
361+
* @return a new {@link JedisCluster.Builder} instance
362+
*/
363+
public static Builder builder() {
364+
return new Builder();
365+
}
366+
337367
/**
338368
* Returns all nodes that were configured to connect to in key-value pairs ({@link Map}).<br>
339369
* Key is the HOST:PORT and the value is the connection pool.

src/main/java/redis/clients/jedis/JedisPooled.java

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,9 +8,12 @@
88
import org.apache.commons.pool2.PooledObjectFactory;
99
import org.apache.commons.pool2.impl.GenericObjectPoolConfig;
1010
import redis.clients.jedis.annots.Experimental;
11+
import redis.clients.jedis.builders.StandaloneClientBuilder;
1112
import redis.clients.jedis.csc.Cache;
1213
import redis.clients.jedis.csc.CacheConfig;
1314
import redis.clients.jedis.csc.CacheFactory;
15+
import redis.clients.jedis.executors.CommandExecutor;
16+
import redis.clients.jedis.providers.ConnectionProvider;
1417
import redis.clients.jedis.providers.PooledConnectionProvider;
1518
import redis.clients.jedis.util.JedisURIHelper;
1619
import redis.clients.jedis.util.Pool;
@@ -425,6 +428,33 @@ public JedisPooled(PooledConnectionProvider provider) {
425428
super(provider);
426429
}
427430

431+
private JedisPooled(CommandExecutor commandExecutor, ConnectionProvider connectionProvider, CommandObjects commandObjects, RedisProtocol redisProtocol, Cache cache) {
432+
super(commandExecutor, connectionProvider, commandObjects, redisProtocol, cache);
433+
}
434+
435+
/**
436+
* Fluent builder for {@link JedisPooled} (standalone).
437+
* <p>
438+
* Obtain an instance via {@link #builder()}.
439+
* </p>
440+
*/
441+
static public class Builder extends StandaloneClientBuilder<JedisPooled> {
442+
443+
@Override
444+
protected JedisPooled createClient() {
445+
return new JedisPooled(commandExecutor, connectionProvider, commandObjects, clientConfig.getRedisProtocol(),
446+
cache);
447+
}
448+
}
449+
450+
/**
451+
* Create a new builder for configuring JedisPooled instances.
452+
* @return a new {@link JedisPooled.Builder} instance
453+
*/
454+
public static Builder builder() {
455+
return new Builder();
456+
}
457+
428458
public final Pool<Connection> getPool() {
429459
return ((PooledConnectionProvider) provider).getPool();
430460
}

src/main/java/redis/clients/jedis/JedisSentineled.java

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,9 +3,12 @@
33
import java.util.Set;
44
import org.apache.commons.pool2.impl.GenericObjectPoolConfig;
55
import redis.clients.jedis.annots.Experimental;
6+
import redis.clients.jedis.builders.SentinelClientBuilder;
67
import redis.clients.jedis.csc.Cache;
78
import redis.clients.jedis.csc.CacheConfig;
89
import redis.clients.jedis.csc.CacheFactory;
10+
import redis.clients.jedis.executors.CommandExecutor;
11+
import redis.clients.jedis.providers.ConnectionProvider;
912
import redis.clients.jedis.providers.SentineledConnectionProvider;
1013

1114
public class JedisSentineled extends UnifiedJedis {
@@ -49,6 +52,34 @@ public JedisSentineled(SentineledConnectionProvider sentineledConnectionProvider
4952
super(sentineledConnectionProvider);
5053
}
5154

55+
private JedisSentineled(CommandExecutor commandExecutor, ConnectionProvider connectionProvider, CommandObjects commandObjects, RedisProtocol redisProtocol, Cache cache) {
56+
super(commandExecutor, connectionProvider, commandObjects, redisProtocol, cache);
57+
}
58+
59+
/**
60+
* Fluent builder for {@link JedisSentineled} (Redis Sentinel).
61+
* <p>
62+
* Obtain an instance via {@link #builder()}.
63+
* </p>
64+
*/
65+
static public class Builder extends SentinelClientBuilder<JedisSentineled> {
66+
67+
@Override
68+
protected JedisSentineled createClient() {
69+
return new JedisSentineled(commandExecutor, connectionProvider, commandObjects, clientConfig.getRedisProtocol(),
70+
cache);
71+
}
72+
}
73+
74+
/**
75+
* Create a new builder for configuring JedisSentineled instances.
76+
*
77+
* @return a new {@link JedisSentineled.Builder} instance
78+
*/
79+
public static Builder builder() {
80+
return new Builder();
81+
}
82+
5283
public HostAndPort getCurrentMaster() {
5384
return ((SentineledConnectionProvider) provider).getCurrentMaster();
5485
}

src/main/java/redis/clients/jedis/MultiClusterClientConfig.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@
4545
* <p>
4646
* <strong>Usage Example:</strong>
4747
* </p>
48-
*
48+
*
4949
* <pre>
5050
* {
5151
* &#64;code

src/main/java/redis/clients/jedis/UnifiedJedis.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -282,7 +282,7 @@ private UnifiedJedis(CommandExecutor executor, ConnectionProvider provider, Comm
282282
}
283283

284284
@Experimental
285-
private UnifiedJedis(CommandExecutor executor, ConnectionProvider provider, CommandObjects commandObjects,
285+
UnifiedJedis(CommandExecutor executor, ConnectionProvider provider, CommandObjects commandObjects,
286286
RedisProtocol protocol, Cache cache) {
287287

288288
if (cache != null && protocol != RedisProtocol.RESP3) {

0 commit comments

Comments
 (0)