Skip to content

Commit

Permalink
Add simple JedisCluster constructor with HostAndPortMapper (#3302)
Browse files Browse the repository at this point in the history
  • Loading branch information
sazzad16 committed Feb 27, 2023
1 parent 84d0aaa commit 51334b3
Showing 1 changed file with 15 additions and 8 deletions.
23 changes: 15 additions & 8 deletions src/main/java/redis/clients/jedis/JedisCluster.java
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@
import java.util.Map;
import java.util.Set;
import org.apache.commons.pool2.impl.GenericObjectPoolConfig;
import redis.clients.jedis.executors.ClusterCommandExecutor;
import redis.clients.jedis.providers.ClusterConnectionProvider;

public class JedisCluster extends UnifiedJedis {
Expand Down Expand Up @@ -100,6 +99,12 @@ public JedisCluster(Set<HostAndPort> nodes, String user, String password) {
this(nodes, DefaultJedisClientConfig.builder().user(user).password(password).build());
}

public JedisCluster(Set<HostAndPort> nodes, String user, String password,
HostAndPortMapper hostAndPortMap) {
this(nodes, DefaultJedisClientConfig.builder().user(user).password(password)
.hostAndPortMapper(hostAndPortMap).build());
}

public JedisCluster(Set<HostAndPort> nodes, final GenericObjectPoolConfig<Connection> poolConfig) {
this(nodes, DEFAULT_TIMEOUT, DEFAULT_MAX_ATTEMPTS, poolConfig);
}
Expand All @@ -124,8 +129,8 @@ public JedisCluster(Set<HostAndPort> clusterNodes, int connectionTimeout, int so
this(clusterNodes, connectionTimeout, soTimeout, maxAttempts, password, null, poolConfig);
}

public JedisCluster(Set<HostAndPort> clusterNodes, int connectionTimeout,
int soTimeout, int maxAttempts, String password, String clientName,
public JedisCluster(Set<HostAndPort> clusterNodes, int connectionTimeout, int soTimeout,
int maxAttempts, String password, String clientName,
GenericObjectPoolConfig<Connection> poolConfig) {
this(clusterNodes, connectionTimeout, soTimeout, maxAttempts, null, password, clientName,
poolConfig);
Expand All @@ -139,9 +144,9 @@ public JedisCluster(Set<HostAndPort> clusterNodes, int connectionTimeout, int so
maxAttempts, poolConfig);
}

public JedisCluster(Set<HostAndPort> clusterNodes, int connectionTimeout,
int soTimeout, int infiniteSoTimeout, int maxAttempts, String user, String password,
String clientName, GenericObjectPoolConfig<Connection> poolConfig) {
public JedisCluster(Set<HostAndPort> clusterNodes, int connectionTimeout, int soTimeout,
int infiniteSoTimeout, int maxAttempts, String user, String password, String clientName,
GenericObjectPoolConfig<Connection> poolConfig) {
this(clusterNodes, DefaultJedisClientConfig.builder().connectionTimeoutMillis(connectionTimeout)
.socketTimeoutMillis(soTimeout).blockingSocketTimeoutMillis(infiniteSoTimeout)
.user(user).password(password).clientName(clientName).build(), maxAttempts, poolConfig);
Expand Down Expand Up @@ -169,7 +174,8 @@ public JedisCluster(Set<HostAndPort> clusterNodes, JedisClientConfig clientConfi
}

public JedisCluster(Set<HostAndPort> clusterNodes, JedisClientConfig clientConfig,
int maxAttempts, Duration maxTotalRetriesDuration, GenericObjectPoolConfig<Connection> poolConfig) {
int maxAttempts, Duration maxTotalRetriesDuration,
GenericObjectPoolConfig<Connection> poolConfig) {
super(clusterNodes, clientConfig, poolConfig, maxAttempts, maxTotalRetriesDuration);
}

Expand All @@ -181,7 +187,8 @@ public JedisCluster(Set<HostAndPort> clusterNodes, JedisClientConfig clientConfi
super(clusterNodes, clientConfig, maxAttempts);
}

public JedisCluster(Set<HostAndPort> clusterNodes, JedisClientConfig clientConfig, int maxAttempts, Duration maxTotalRetriesDuration) {
public JedisCluster(Set<HostAndPort> clusterNodes, JedisClientConfig clientConfig, int maxAttempts,
Duration maxTotalRetriesDuration) {
super(clusterNodes, clientConfig, maxAttempts, maxTotalRetriesDuration);
}

Expand Down

0 comments on commit 51334b3

Please sign in to comment.