DATAREDIS-574 - Polishing.
Updated reference Documentation, JavaDoc and add some minor code changes (rename methods, fix return types, diamond operators,…). Original Pull Request: #236
This commit is contained in:
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2015-2016 the original author or authors.
|
||||
* Copyright 2015-2017 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@@ -53,7 +53,7 @@ public class RedisClusterConfiguration {
|
||||
* Creates new {@link RedisClusterConfiguration}.
|
||||
*/
|
||||
public RedisClusterConfiguration() {
|
||||
this(new MapPropertySource("RedisClusterConfiguration", Collections.<String, Object> emptyMap()));
|
||||
this(new MapPropertySource("RedisClusterConfiguration", Collections.emptyMap()));
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -64,12 +64,13 @@ public class RedisClusterConfiguration {
|
||||
* clusterHostAndPorts[0] = 127.0.0.1:23679
|
||||
* clusterHostAndPorts[1] = 127.0.0.1:23680 ...
|
||||
* </code>
|
||||
*
|
||||
* <pre>
|
||||
*
|
||||
* @param clusterNodes must not be {@literal null}.
|
||||
*/
|
||||
public RedisClusterConfiguration(Collection<String> clusterNodes) {
|
||||
this(new MapPropertySource("RedisClusterConfiguration", asMap(clusterNodes, -1, -1, null)));
|
||||
this(new MapPropertySource("RedisClusterConfiguration", asMap(clusterNodes, -1)));
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -90,11 +91,11 @@ public class RedisClusterConfiguration {
|
||||
|
||||
notNull(propertySource, "PropertySource must not be null!");
|
||||
|
||||
this.clusterNodes = new LinkedHashSet<RedisNode>();
|
||||
this.clusterNodes = new LinkedHashSet<>();
|
||||
|
||||
if (propertySource.containsProperty(REDIS_CLUSTER_NODES_CONFIG_PROPERTY)) {
|
||||
appendClusterNodes(commaDelimitedListToSet(propertySource.getProperty(REDIS_CLUSTER_NODES_CONFIG_PROPERTY)
|
||||
.toString()));
|
||||
appendClusterNodes(
|
||||
commaDelimitedListToSet(propertySource.getProperty(REDIS_CLUSTER_NODES_CONFIG_PROPERTY).toString()));
|
||||
}
|
||||
if (propertySource.containsProperty(REDIS_CLUSTER_MAX_REDIRECTS_CONFIG_PROPERTY)) {
|
||||
this.maxRedirects = NumberUtils.parseNumber(
|
||||
@@ -139,7 +140,7 @@ public class RedisClusterConfiguration {
|
||||
}
|
||||
|
||||
/**
|
||||
* @return
|
||||
* @return this.
|
||||
*/
|
||||
public RedisClusterConfiguration clusterNode(RedisNode node) {
|
||||
|
||||
@@ -148,14 +149,14 @@ public class RedisClusterConfiguration {
|
||||
}
|
||||
|
||||
/**
|
||||
* @return
|
||||
* @return max number of redirects to follow or {@literal null} if not set.
|
||||
*/
|
||||
public Integer getMaxRedirects() {
|
||||
return maxRedirects != null && maxRedirects > Integer.MIN_VALUE ? maxRedirects : null;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param maxRedirects
|
||||
* @param maxRedirects the max number of redirects to follow.
|
||||
*/
|
||||
public void setMaxRedirects(int maxRedirects) {
|
||||
|
||||
@@ -164,9 +165,9 @@ public class RedisClusterConfiguration {
|
||||
}
|
||||
|
||||
/**
|
||||
* @param host
|
||||
* @param port
|
||||
* @return
|
||||
* @param host Redis cluster node host name or ip address.
|
||||
* @param port Redis cluster node port.
|
||||
* @return this.
|
||||
*/
|
||||
public RedisClusterConfiguration clusterNode(String host, Integer port) {
|
||||
return clusterNode(new RedisNode(host, port));
|
||||
@@ -180,7 +181,9 @@ public class RedisClusterConfiguration {
|
||||
}
|
||||
|
||||
/**
|
||||
* @return
|
||||
* Get the {@link RedisPassword} defined.
|
||||
*
|
||||
* @return never {@literal null}.
|
||||
* @since 2.0
|
||||
*/
|
||||
public RedisPassword getPassword() {
|
||||
@@ -204,26 +207,24 @@ public class RedisClusterConfiguration {
|
||||
|
||||
notNull(args, "HostAndPort need to be seperated by ':'.");
|
||||
isTrue(args.length == 2, "Host and Port String needs to specified as host:port");
|
||||
return new RedisNode(args[0], Integer.valueOf(args[1]).intValue());
|
||||
return new RedisNode(args[0], Integer.valueOf(args[1]));
|
||||
}
|
||||
|
||||
/**
|
||||
* @param clusterHostAndPorts must not be {@literal null} or empty.
|
||||
* @param timeout
|
||||
* @param redirects
|
||||
* @param redirects the max number of redirects to follow.
|
||||
* @param password can be {@literal null} or empty.
|
||||
* @return
|
||||
* @return cluster config map with properties.
|
||||
*/
|
||||
private static Map<String, Object> asMap(Collection<String> clusterHostAndPorts, long timeout, int redirects,
|
||||
String password) {
|
||||
private static Map<String, Object> asMap(Collection<String> clusterHostAndPorts, int redirects) {
|
||||
|
||||
notNull(clusterHostAndPorts, "ClusterHostAndPorts must not be null!");
|
||||
|
||||
Map<String, Object> map = new HashMap<String, Object>();
|
||||
Map<String, Object> map = new HashMap<>();
|
||||
map.put(REDIS_CLUSTER_NODES_CONFIG_PROPERTY, StringUtils.collectionToCommaDelimitedString(clusterHostAndPorts));
|
||||
|
||||
if (redirects >= 0) {
|
||||
map.put(REDIS_CLUSTER_MAX_REDIRECTS_CONFIG_PROPERTY, Integer.valueOf(redirects));
|
||||
map.put(REDIS_CLUSTER_MAX_REDIRECTS_CONFIG_PROPERTY, redirects);
|
||||
}
|
||||
|
||||
return map;
|
||||
|
||||
@@ -25,6 +25,8 @@ import java.util.Optional;
|
||||
import java.util.function.Function;
|
||||
|
||||
import org.springframework.util.Assert;
|
||||
import org.springframework.util.ObjectUtils;
|
||||
import org.springframework.util.StringUtils;
|
||||
|
||||
/**
|
||||
* Value object which may or may not contain a Redis password.
|
||||
@@ -34,13 +36,14 @@ import org.springframework.util.Assert;
|
||||
* The password is stored as character array.
|
||||
*
|
||||
* @author Mark Paluch
|
||||
* @author Christoph Strobl
|
||||
* @since 2.0
|
||||
*/
|
||||
@RequiredArgsConstructor(access = AccessLevel.PRIVATE)
|
||||
@EqualsAndHashCode
|
||||
public class RedisPassword {
|
||||
|
||||
private static final RedisPassword NONE = new RedisPassword(new char[0]);
|
||||
private static final RedisPassword NONE = new RedisPassword(new char[] {});
|
||||
|
||||
private final char[] thePassword;
|
||||
|
||||
@@ -53,7 +56,7 @@ public class RedisPassword {
|
||||
public static RedisPassword of(String passwordAsString) {
|
||||
|
||||
return Optional.ofNullable(passwordAsString) //
|
||||
.filter(it -> it.length() != 0) //
|
||||
.filter(StringUtils::hasText) //
|
||||
.map(it -> new RedisPassword(it.toCharArray())) //
|
||||
.orElseGet(RedisPassword::none);
|
||||
}
|
||||
@@ -61,13 +64,13 @@ public class RedisPassword {
|
||||
/**
|
||||
* Create a {@link RedisPassword} from a {@code char} array.
|
||||
*
|
||||
* @param passwordAsChars the password as string.
|
||||
* @param passwordAsChars the password as char array.
|
||||
* @return the {@link RedisPassword} for {@code passwordAsChars}.
|
||||
*/
|
||||
public static RedisPassword of(char[] passwordAsChars) {
|
||||
|
||||
return Optional.ofNullable(passwordAsChars) //
|
||||
.filter(it -> it.length != 0) //
|
||||
.filter(it -> !ObjectUtils.isEmpty(passwordAsChars)) //
|
||||
.map(it -> new RedisPassword(Arrays.copyOf(it, it.length))) //
|
||||
.orElseGet(RedisPassword::none);
|
||||
}
|
||||
@@ -87,7 +90,7 @@ public class RedisPassword {
|
||||
* @return {@code true} if there is a password present, otherwise {@code false}
|
||||
*/
|
||||
public boolean isPresent() {
|
||||
return thePassword.length != 0;
|
||||
return !ObjectUtils.isEmpty(thePassword);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -117,11 +120,7 @@ public class RedisPassword {
|
||||
|
||||
Assert.notNull(mapper, "Mapper function must not be null!");
|
||||
|
||||
if (isPresent()) {
|
||||
return Optional.ofNullable(mapper.apply(thePassword));
|
||||
}
|
||||
|
||||
return Optional.empty();
|
||||
return toOptional().map(mapper);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -140,7 +139,8 @@ public class RedisPassword {
|
||||
return Optional.empty();
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
/*
|
||||
* (non-Javadoc)
|
||||
* @see java.lang.Object#toString()
|
||||
*/
|
||||
@Override
|
||||
|
||||
@@ -54,7 +54,7 @@ public class RedisSentinelConfiguration {
|
||||
* Creates new {@link RedisSentinelConfiguration}.
|
||||
*/
|
||||
public RedisSentinelConfiguration() {
|
||||
this(new MapPropertySource("RedisSentinelConfiguration", Collections.<String, Object> emptyMap()));
|
||||
this(new MapPropertySource("RedisSentinelConfiguration", Collections.emptyMap()));
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -89,7 +89,7 @@ public class RedisSentinelConfiguration {
|
||||
|
||||
notNull(propertySource, "PropertySource must not be null!");
|
||||
|
||||
this.sentinels = new LinkedHashSet<RedisNode>();
|
||||
this.sentinels = new LinkedHashSet<>();
|
||||
|
||||
if (propertySource.containsProperty(REDIS_SENTINEL_MASTER_CONFIG_PROPERTY)) {
|
||||
this.setMaster(propertySource.getProperty(REDIS_SENTINEL_MASTER_CONFIG_PROPERTY).toString());
|
||||
@@ -145,13 +145,7 @@ public class RedisSentinelConfiguration {
|
||||
public void setMaster(final String name) {
|
||||
|
||||
notNull(name, "Name of sentinel master must not be null.");
|
||||
setMaster(new NamedNode() {
|
||||
|
||||
@Override
|
||||
public String getName() {
|
||||
return name;
|
||||
}
|
||||
});
|
||||
setMaster(() -> name);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -168,7 +162,7 @@ public class RedisSentinelConfiguration {
|
||||
/**
|
||||
* Get the {@literal Sentinel} master node.
|
||||
*
|
||||
* @return
|
||||
* @return get the master node.
|
||||
*/
|
||||
public NamedNode getMaster() {
|
||||
return master;
|
||||
@@ -176,8 +170,8 @@ public class RedisSentinelConfiguration {
|
||||
|
||||
/**
|
||||
* @see #setMaster(String)
|
||||
* @param master
|
||||
* @return
|
||||
* @param master The master node name.
|
||||
* @return this.
|
||||
*/
|
||||
public RedisSentinelConfiguration master(String master) {
|
||||
this.setMaster(master);
|
||||
@@ -186,8 +180,8 @@ public class RedisSentinelConfiguration {
|
||||
|
||||
/**
|
||||
* @see #setMaster(NamedNode)
|
||||
* @param master
|
||||
* @return
|
||||
* @param master the master node
|
||||
* @return this.
|
||||
*/
|
||||
public RedisSentinelConfiguration master(NamedNode master) {
|
||||
this.setMaster(master);
|
||||
@@ -196,8 +190,8 @@ public class RedisSentinelConfiguration {
|
||||
|
||||
/**
|
||||
* @see #addSentinel(RedisNode)
|
||||
* @param sentinel
|
||||
* @return
|
||||
* @param sentinel the node to add as sentinel.
|
||||
* @return this.
|
||||
*/
|
||||
public RedisSentinelConfiguration sentinel(RedisNode sentinel) {
|
||||
this.addSentinel(sentinel);
|
||||
@@ -206,9 +200,9 @@ public class RedisSentinelConfiguration {
|
||||
|
||||
/**
|
||||
* @see #sentinel(RedisNode)
|
||||
* @param host
|
||||
* @param port
|
||||
* @return
|
||||
* @param host redis sentinel node host name or ip.
|
||||
* @param port redis sentinel port.
|
||||
* @return this.
|
||||
*/
|
||||
public RedisSentinelConfiguration sentinel(String host, Integer port) {
|
||||
return sentinel(new RedisNode(host, port));
|
||||
@@ -222,7 +216,7 @@ public class RedisSentinelConfiguration {
|
||||
}
|
||||
|
||||
/**
|
||||
* @return
|
||||
* @return the initial db index.
|
||||
* @since 2.0
|
||||
*/
|
||||
public int getDatabase() {
|
||||
@@ -237,13 +231,13 @@ public class RedisSentinelConfiguration {
|
||||
*/
|
||||
public void setDatabase(int index) {
|
||||
|
||||
Assert.isTrue(index >= 0, "invalid DB index (a positive index required)");
|
||||
Assert.isTrue(index >= 0, () -> String.format("Invalid DB index '%s' (a positive index required)", index));
|
||||
|
||||
this.database = index;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return
|
||||
* @return never {@literal null}.
|
||||
* @since 2.0
|
||||
*/
|
||||
public RedisPassword getPassword() {
|
||||
@@ -273,14 +267,14 @@ public class RedisSentinelConfiguration {
|
||||
/**
|
||||
* @param master must not be {@literal null} or empty.
|
||||
* @param sentinelHostAndPorts must not be {@literal null}.
|
||||
* @return
|
||||
* @return configuration map.
|
||||
*/
|
||||
private static Map<String, Object> asMap(String master, Set<String> sentinelHostAndPorts) {
|
||||
|
||||
hasText(master, "Master address must not be null or empty!");
|
||||
notNull(sentinelHostAndPorts, "SentinelHostAndPorts must not be null!");
|
||||
|
||||
Map<String, Object> map = new HashMap<String, Object>();
|
||||
Map<String, Object> map = new HashMap<>();
|
||||
map.put(REDIS_SENTINEL_MASTER_CONFIG_PROPERTY, master);
|
||||
map.put(REDIS_SENTINEL_NODES_CONFIG_PROPERTY, StringUtils.collectionToCommaDelimitedString(sentinelHostAndPorts));
|
||||
|
||||
|
||||
@@ -19,15 +19,16 @@ import org.springframework.util.Assert;
|
||||
|
||||
/**
|
||||
* Configuration class used for setting up {@link RedisConnection} via {@link RedisConnectionFactory} using connecting
|
||||
* to <a href="http://redis.io/">Redis</a>.
|
||||
* to a single node <a href="http://redis.io/">Redis</a> installation.
|
||||
*
|
||||
* @author Mark Paluch
|
||||
* @author Christoph Strobl
|
||||
* @since 2.0
|
||||
*/
|
||||
public class RedisStandaloneConfiguration {
|
||||
|
||||
public static final String DEFAULT_HOST = "localhost";
|
||||
public static final int DEFAULT_PORT = 6379;
|
||||
private static final String DEFAULT_HOST = "localhost";
|
||||
private static final int DEFAULT_PORT = 6379;
|
||||
|
||||
private String hostName = DEFAULT_HOST;
|
||||
private int port = DEFAULT_PORT;
|
||||
@@ -65,35 +66,35 @@ public class RedisStandaloneConfiguration {
|
||||
}
|
||||
|
||||
/**
|
||||
* @return
|
||||
* @return the hostname or ip of the Redis node.
|
||||
*/
|
||||
public String getHostName() {
|
||||
return hostName;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return
|
||||
* @return the port or the Redis node.
|
||||
*/
|
||||
public int getPort() {
|
||||
return port;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param hostName
|
||||
* @param hostName the hostname or ip of the Redis node.
|
||||
*/
|
||||
public void setHostName(String hostName) {
|
||||
this.hostName = hostName;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param port
|
||||
* @param port the Redis node port to connect to.
|
||||
*/
|
||||
public void setPort(int port) {
|
||||
this.port = port;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return
|
||||
* @return the db index.
|
||||
*/
|
||||
public int getDatabase() {
|
||||
return database;
|
||||
@@ -106,13 +107,13 @@ public class RedisStandaloneConfiguration {
|
||||
*/
|
||||
public void setDatabase(int index) {
|
||||
|
||||
Assert.isTrue(index >= 0, "invalid DB index (a positive index required)");
|
||||
Assert.isTrue(index >= 0, () -> String.format("Invalid DB index '%s' (a positive index required)", index));
|
||||
|
||||
this.database = index;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return
|
||||
* @return never {@literal null}.
|
||||
*/
|
||||
public RedisPassword getPassword() {
|
||||
return password;
|
||||
|
||||
@@ -61,7 +61,7 @@ class DefaultJedisClientConfiguration implements JedisClientConfiguration {
|
||||
* @see org.springframework.data.redis.connection.jedis.JedisClientConfiguration#useSsl()
|
||||
*/
|
||||
@Override
|
||||
public boolean useSsl() {
|
||||
public boolean isUseSsl() {
|
||||
return useSsl;
|
||||
}
|
||||
|
||||
@@ -93,7 +93,7 @@ class DefaultJedisClientConfiguration implements JedisClientConfiguration {
|
||||
* @see org.springframework.data.redis.connection.jedis.JedisClientConfiguration#usePooling()
|
||||
*/
|
||||
@Override
|
||||
public boolean usePooling() {
|
||||
public boolean isUsePooling() {
|
||||
return usePooling;
|
||||
}
|
||||
|
||||
|
||||
@@ -46,6 +46,7 @@ import org.springframework.util.Assert;
|
||||
* </ul>
|
||||
*
|
||||
* @author Mark Paluch
|
||||
* @author Christoph Strobl
|
||||
* @since 2.0
|
||||
* @see redis.clients.jedis.Jedis
|
||||
* @see org.springframework.data.redis.connection.RedisStandaloneConfiguration
|
||||
@@ -57,7 +58,7 @@ public interface JedisClientConfiguration {
|
||||
/**
|
||||
* @return {@literal true} to use SSL, {@literal false} to use unencrypted connections.
|
||||
*/
|
||||
boolean useSsl();
|
||||
boolean isUseSsl();
|
||||
|
||||
/**
|
||||
* @return the optional {@link SSLSocketFactory}.
|
||||
@@ -77,7 +78,7 @@ public interface JedisClientConfiguration {
|
||||
/**
|
||||
* @return {@literal true} to use connection-pooling.
|
||||
*/
|
||||
boolean usePooling();
|
||||
boolean isUsePooling();
|
||||
|
||||
/**
|
||||
* @return the optional {@link GenericObjectPoolConfig}.
|
||||
@@ -112,11 +113,23 @@ public interface JedisClientConfiguration {
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates an empty {@link JedisClientConfiguration}.
|
||||
* Creates a default {@link JedisClientConfiguration}.
|
||||
* <dl>
|
||||
* <dt>SSL enabled</dt>
|
||||
* <dd>no</dd>
|
||||
* <dt>Pooling enabled</dt>
|
||||
* <dd>no</dd>
|
||||
* <dt>Client Name</dt>
|
||||
* <dd>[not set]</dd>
|
||||
* <dt>Read Timeout</dt>
|
||||
* <dd>2000 msec</dd>
|
||||
* <dt>Connect Timeout</dt>
|
||||
* <dd>2000 msec</dd>
|
||||
* </dl>
|
||||
*
|
||||
* @return an empty {@link JedisClientConfiguration}.
|
||||
* @return a {@link JedisClientConfiguration} with defaults.
|
||||
*/
|
||||
static JedisClientConfiguration create() {
|
||||
static JedisClientConfiguration defaultConfiguration() {
|
||||
return builder().build();
|
||||
}
|
||||
|
||||
@@ -132,13 +145,6 @@ public interface JedisClientConfiguration {
|
||||
*/
|
||||
JedisSslClientConfigurationBuilder useSsl();
|
||||
|
||||
/**
|
||||
* Use plaintext connections instead of SSL.
|
||||
*
|
||||
* @return {@link JedisSslClientConfigurationBuilder}.
|
||||
*/
|
||||
JedisClientConfigurationBuilder usePlaintext();
|
||||
|
||||
/**
|
||||
* Enable connection-pooling.
|
||||
*
|
||||
@@ -146,18 +152,12 @@ public interface JedisClientConfiguration {
|
||||
*/
|
||||
JedisPoolingClientConfigurationBuilder usePooling();
|
||||
|
||||
/**
|
||||
* Disable connection-pooling.
|
||||
*
|
||||
* @return {@link JedisClientConfigurationBuilder}.
|
||||
*/
|
||||
JedisClientConfigurationBuilder useUnpooledConnections();
|
||||
|
||||
/**
|
||||
* Configure a {@code clientName} to be set with {@code CLIENT SETNAME}.
|
||||
*
|
||||
* @param clientName must not be {@literal null}.
|
||||
* @return {@literal this} builder.
|
||||
* @throws IllegalArgumentException if clientName is {@literal null}.
|
||||
*/
|
||||
JedisClientConfigurationBuilder clientName(String clientName);
|
||||
|
||||
@@ -166,6 +166,7 @@ public interface JedisClientConfiguration {
|
||||
*
|
||||
* @param readTimeout must not be {@literal null}.
|
||||
* @return {@literal this} builder.
|
||||
* @throws IllegalArgumentException if readTimeout is {@literal null}.
|
||||
*/
|
||||
JedisClientConfigurationBuilder readTimeout(Duration readTimeout);
|
||||
|
||||
@@ -174,6 +175,7 @@ public interface JedisClientConfiguration {
|
||||
*
|
||||
* @param connectTimeout must not be {@literal null}.
|
||||
* @return {@literal this} builder.
|
||||
* @throws IllegalArgumentException if connectTimeout is {@literal null}.
|
||||
*/
|
||||
JedisClientConfigurationBuilder connectTimeout(Duration connectTimeout);
|
||||
|
||||
@@ -193,6 +195,7 @@ public interface JedisClientConfiguration {
|
||||
/**
|
||||
* @param poolConfig must not be {@literal null}.
|
||||
* @return {@literal this} builder.
|
||||
* @throws IllegalArgumentException if poolConfig is {@literal null}.
|
||||
*/
|
||||
JedisPoolingClientConfigurationBuilder poolConfig(GenericObjectPoolConfig poolConfig);
|
||||
|
||||
@@ -219,18 +222,21 @@ public interface JedisClientConfiguration {
|
||||
/**
|
||||
* @param sslSocketFactory must not be {@literal null}.
|
||||
* @return {@literal this} builder.
|
||||
* @throws IllegalArgumentException if sslSocketFactory is {@literal null}.
|
||||
*/
|
||||
JedisSslClientConfigurationBuilder sslSocketFactory(SSLSocketFactory sslSocketFactory);
|
||||
|
||||
/**
|
||||
* @param sslParameters must not be {@literal null}.
|
||||
* @return {@literal this} builder.
|
||||
* @throws IllegalArgumentException if sslParameters is {@literal null}.
|
||||
*/
|
||||
JedisSslClientConfigurationBuilder sslParameters(SSLParameters sslParameters);
|
||||
|
||||
/**
|
||||
* @param hostnameVerifier must not be {@literal null}.
|
||||
* @return {@literal this} builder.
|
||||
* @throws IllegalArgumentException if hostnameVerifier is {@literal null}.
|
||||
*/
|
||||
JedisSslClientConfigurationBuilder hostnameVerifier(HostnameVerifier hostnameVerifier);
|
||||
|
||||
@@ -268,31 +274,23 @@ public interface JedisClientConfiguration {
|
||||
|
||||
private DefaultJedisClientConfigurationBuilder() {}
|
||||
|
||||
/* (non-Javadoc)
|
||||
/*
|
||||
* (non-Javadoc)
|
||||
* @see org.springframework.data.redis.connection.jedis.JedisClientConfiguration.JedisClientConfigurationBuilder#useSsl()
|
||||
*/
|
||||
@Override
|
||||
public DefaultJedisClientConfigurationBuilder useSsl() {
|
||||
public JedisSslClientConfigurationBuilder useSsl() {
|
||||
|
||||
this.useSsl = true;
|
||||
return this;
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see org.springframework.data.redis.connection.jedis.JedisClientConfiguration.JedisClientConfigurationBuilder#usePlaintext()
|
||||
*/
|
||||
@Override
|
||||
public JedisClientConfigurationBuilder usePlaintext() {
|
||||
|
||||
this.useSsl = false;
|
||||
return this;
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
/*
|
||||
* (non-Javadoc)
|
||||
* @see org.springframework.data.redis.connection.jedis.JedisClientConfiguration.JedisSslClientConfigurationBuilder#sslSocketFactory(javax.net.ssl.SSLSocketFactory)
|
||||
*/
|
||||
@Override
|
||||
public DefaultJedisClientConfigurationBuilder sslSocketFactory(SSLSocketFactory sslSocketFactory) {
|
||||
public JedisSslClientConfigurationBuilder sslSocketFactory(SSLSocketFactory sslSocketFactory) {
|
||||
|
||||
Assert.notNull(sslSocketFactory, "SSLSocketFactory must not be null!");
|
||||
|
||||
@@ -300,11 +298,12 @@ public interface JedisClientConfiguration {
|
||||
return this;
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
/*
|
||||
* (non-Javadoc)
|
||||
* @see org.springframework.data.redis.connection.jedis.JedisClientConfiguration.JedisSslClientConfigurationBuilder#sslParameters(javax.net.ssl.SSLParameters)
|
||||
*/
|
||||
@Override
|
||||
public DefaultJedisClientConfigurationBuilder sslParameters(SSLParameters sslParameters) {
|
||||
public JedisSslClientConfigurationBuilder sslParameters(SSLParameters sslParameters) {
|
||||
|
||||
Assert.notNull(sslParameters, "SSLParameters must not be null!");
|
||||
|
||||
@@ -312,11 +311,12 @@ public interface JedisClientConfiguration {
|
||||
return this;
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
/*
|
||||
* (non-Javadoc)
|
||||
* @see org.springframework.data.redis.connection.jedis.JedisClientConfiguration.JedisSslClientConfigurationBuilder#hostnameVerifier(javax.net.ssl.HostnameVerifier)
|
||||
*/
|
||||
@Override
|
||||
public DefaultJedisClientConfigurationBuilder hostnameVerifier(HostnameVerifier hostnameVerifier) {
|
||||
public JedisSslClientConfigurationBuilder hostnameVerifier(HostnameVerifier hostnameVerifier) {
|
||||
|
||||
Assert.notNull(hostnameVerifier, "HostnameVerifier must not be null!");
|
||||
|
||||
@@ -324,31 +324,23 @@ public interface JedisClientConfiguration {
|
||||
return this;
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
/*
|
||||
* (non-Javadoc)
|
||||
* @see org.springframework.data.redis.connection.jedis.JedisClientConfiguration.JedisClientConfigurationBuilder#usePooling()
|
||||
*/
|
||||
@Override
|
||||
public DefaultJedisClientConfigurationBuilder usePooling() {
|
||||
public JedisPoolingClientConfigurationBuilder usePooling() {
|
||||
|
||||
this.usePooling = true;
|
||||
return this;
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see org.springframework.data.redis.connection.jedis.JedisClientConfiguration.JedisClientConfigurationBuilder#useUnpooledConnections()
|
||||
*/
|
||||
@Override
|
||||
public JedisClientConfigurationBuilder useUnpooledConnections() {
|
||||
|
||||
this.usePooling = false;
|
||||
return this;
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
/*
|
||||
* (non-Javadoc)
|
||||
* @see org.springframework.data.redis.connection.jedis.JedisClientConfiguration.JedisPoolingClientConfigurationBuilder#poolConfig(org.apache.commons.pool2.impl.GenericObjectPoolConfig)
|
||||
*/
|
||||
@Override
|
||||
public DefaultJedisClientConfigurationBuilder poolConfig(GenericObjectPoolConfig poolConfig) {
|
||||
public JedisPoolingClientConfigurationBuilder poolConfig(GenericObjectPoolConfig poolConfig) {
|
||||
|
||||
Assert.notNull(poolConfig, "GenericObjectPoolConfig must not be null!");
|
||||
|
||||
@@ -356,7 +348,8 @@ public interface JedisClientConfiguration {
|
||||
return this;
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
/*
|
||||
* (non-Javadoc)
|
||||
* @see org.springframework.data.redis.connection.jedis.JedisClientConfiguration.JedisPoolingClientConfigurationBuilder#and()
|
||||
*/
|
||||
@Override
|
||||
@@ -364,7 +357,8 @@ public interface JedisClientConfiguration {
|
||||
return this;
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
/*
|
||||
* (non-Javadoc)
|
||||
* @see org.springframework.data.redis.connection.jedis.JedisClientConfiguration.JedisClientConfigurationBuilder#clientName(java.lang.String)
|
||||
*/
|
||||
@Override
|
||||
@@ -376,7 +370,8 @@ public interface JedisClientConfiguration {
|
||||
return this;
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
/*
|
||||
* (non-Javadoc)
|
||||
* @see org.springframework.data.redis.connection.jedis.JedisClientConfiguration.JedisClientConfigurationBuilder#readTimeout(java.time.Duration)
|
||||
*/
|
||||
@Override
|
||||
@@ -388,7 +383,8 @@ public interface JedisClientConfiguration {
|
||||
return this;
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
/*
|
||||
* (non-Javadoc)
|
||||
* @see org.springframework.data.redis.connection.jedis.JedisClientConfiguration.JedisClientConfigurationBuilder#connectTimeout(java.time.Duration)
|
||||
*/
|
||||
@Override
|
||||
@@ -400,7 +396,8 @@ public interface JedisClientConfiguration {
|
||||
return this;
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
/*
|
||||
* (non-Javadoc)
|
||||
* @see org.springframework.data.redis.connection.jedis.JedisClientConfiguration.JedisClientConfigurationBuilder#build()
|
||||
*/
|
||||
@Override
|
||||
|
||||
@@ -26,7 +26,6 @@ import redis.clients.jedis.JedisShardInfo;
|
||||
import redis.clients.jedis.Protocol;
|
||||
import redis.clients.util.Pool;
|
||||
|
||||
import java.lang.reflect.Method;
|
||||
import java.time.Duration;
|
||||
import java.util.Collection;
|
||||
import java.util.Collections;
|
||||
@@ -50,11 +49,19 @@ import org.springframework.dao.InvalidDataAccessResourceUsageException;
|
||||
import org.springframework.data.redis.ExceptionTranslationStrategy;
|
||||
import org.springframework.data.redis.PassThroughExceptionTranslationStrategy;
|
||||
import org.springframework.data.redis.RedisConnectionFailureException;
|
||||
import org.springframework.data.redis.connection.*;
|
||||
import org.springframework.data.redis.connection.ClusterCommandExecutor;
|
||||
import org.springframework.data.redis.connection.RedisClusterConfiguration;
|
||||
import org.springframework.data.redis.connection.RedisClusterConnection;
|
||||
import org.springframework.data.redis.connection.RedisConnection;
|
||||
import org.springframework.data.redis.connection.RedisConnectionFactory;
|
||||
import org.springframework.data.redis.connection.RedisNode;
|
||||
import org.springframework.data.redis.connection.RedisPassword;
|
||||
import org.springframework.data.redis.connection.RedisSentinelConfiguration;
|
||||
import org.springframework.data.redis.connection.RedisSentinelConnection;
|
||||
import org.springframework.data.redis.connection.RedisStandaloneConfiguration;
|
||||
import org.springframework.util.Assert;
|
||||
import org.springframework.util.ClassUtils;
|
||||
import org.springframework.util.CollectionUtils;
|
||||
import org.springframework.util.ReflectionUtils;
|
||||
import org.springframework.util.StringUtils;
|
||||
|
||||
/**
|
||||
@@ -82,19 +89,6 @@ public class JedisConnectionFactory implements InitializingBean, DisposableBean,
|
||||
private static final ExceptionTranslationStrategy EXCEPTION_TRANSLATION = new PassThroughExceptionTranslationStrategy(
|
||||
JedisConverters.exceptionConverter());
|
||||
|
||||
private static final Method SET_TIMEOUT_METHOD;
|
||||
|
||||
static {
|
||||
|
||||
// We need to configure Jedis socket timeout via reflection since the method-name was changed between releases.
|
||||
Method setTimeoutMethodCandidate = ReflectionUtils.findMethod(JedisShardInfo.class, "setTimeout", int.class);
|
||||
if (setTimeoutMethodCandidate == null) {
|
||||
// Jedis V 2.7.x changed the setTimeout method to setSoTimeout
|
||||
setTimeoutMethodCandidate = ReflectionUtils.findMethod(JedisShardInfo.class, "setSoTimeout", int.class);
|
||||
}
|
||||
SET_TIMEOUT_METHOD = setTimeoutMethodCandidate;
|
||||
}
|
||||
|
||||
private final JedisClientConfiguration clientConfiguration;
|
||||
private JedisShardInfo shardInfo;
|
||||
private boolean providedShardInfo = false;
|
||||
@@ -169,7 +163,7 @@ public class JedisConnectionFactory implements InitializingBean, DisposableBean,
|
||||
* Constructs a new {@link JedisConnectionFactory} instance using the given {@link JedisPoolConfig} applied to
|
||||
* {@link JedisSentinelPool}.
|
||||
*
|
||||
* @param sentinelConfig
|
||||
* @param sentinelConfig the sentinel configuration to use.
|
||||
* @param poolConfig pool configuration. Defaulted to new instance if {@literal null}.
|
||||
* @since 1.4
|
||||
*/
|
||||
@@ -314,7 +308,7 @@ public class JedisConnectionFactory implements InitializingBean, DisposableBean,
|
||||
* Post process a newly retrieved connection. Useful for decorating or executing initialization commands on a new
|
||||
* connection. This implementation simply returns the connection.
|
||||
*
|
||||
* @param connection
|
||||
* @param connection the jedis connection.
|
||||
* @return processed connection
|
||||
*/
|
||||
protected JedisConnection postProcessConnection(JedisConnection connection) {
|
||||
@@ -340,7 +334,7 @@ public class JedisConnectionFactory implements InitializingBean, DisposableBean,
|
||||
int readTimeout = getReadTimeout();
|
||||
|
||||
if (readTimeout > 0) {
|
||||
setTimeoutOn(shardInfo, readTimeout);
|
||||
shardInfo.setSoTimeout(readTimeout);
|
||||
}
|
||||
|
||||
getMutableConfiguration().setShardInfo(shardInfo);
|
||||
@@ -366,8 +360,8 @@ public class JedisConnectionFactory implements InitializingBean, DisposableBean,
|
||||
/**
|
||||
* Creates {@link JedisSentinelPool}.
|
||||
*
|
||||
* @param config
|
||||
* @return
|
||||
* @param config the actual {@link RedisSentinelConfiguration}. Never {@literal null}.
|
||||
* @return the {@link Pool} to use. Never {@literal null}.
|
||||
* @since 1.4
|
||||
*/
|
||||
protected Pool<Jedis> createRedisSentinelPool(RedisSentinelConfiguration config) {
|
||||
@@ -380,7 +374,7 @@ public class JedisConnectionFactory implements InitializingBean, DisposableBean,
|
||||
/**
|
||||
* Creates {@link JedisPool}.
|
||||
*
|
||||
* @return
|
||||
* @return the {@link Pool} to use. Never {@literal null}.
|
||||
* @since 1.4
|
||||
*/
|
||||
protected Pool<Jedis> createRedisPool() {
|
||||
@@ -406,7 +400,7 @@ public class JedisConnectionFactory implements InitializingBean, DisposableBean,
|
||||
*
|
||||
* @param clusterConfig must not be {@literal null}.
|
||||
* @param poolConfig can be {@literal null}.
|
||||
* @return
|
||||
* @return the actual {@link JedisCluster}.
|
||||
* @since 1.7
|
||||
*/
|
||||
protected JedisCluster createCluster(RedisClusterConfiguration clusterConfig, GenericObjectPoolConfig poolConfig) {
|
||||
@@ -526,7 +520,7 @@ public class JedisConnectionFactory implements InitializingBean, DisposableBean,
|
||||
* @since 1.8
|
||||
*/
|
||||
public boolean isUseSsl() {
|
||||
return clientConfiguration.useSsl();
|
||||
return clientConfiguration.isUseSsl();
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -663,7 +657,7 @@ public class JedisConnectionFactory implements InitializingBean, DisposableBean,
|
||||
* @return the use of connection pooling.
|
||||
*/
|
||||
public boolean getUsePool() {
|
||||
return clientConfiguration.usePooling();
|
||||
return clientConfiguration.isUsePooling();
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -876,10 +870,6 @@ public class JedisConnectionFactory implements InitializingBean, DisposableBean,
|
||||
clientConfiguration.getClientName().ifPresent(jedis::clientSetname);
|
||||
}
|
||||
|
||||
private void setTimeoutOn(JedisShardInfo shardInfo, int timeout) {
|
||||
ReflectionUtils.invokeMethod(SET_TIMEOUT_METHOD, shardInfo, timeout);
|
||||
}
|
||||
|
||||
private int getReadTimeout() {
|
||||
return Math.toIntExact(clientConfiguration.getReadTimeout().toMillis());
|
||||
}
|
||||
@@ -897,6 +887,11 @@ public class JedisConnectionFactory implements InitializingBean, DisposableBean,
|
||||
return (MutableJedisClientConfiguration) clientConfiguration;
|
||||
}
|
||||
|
||||
/**
|
||||
* Mutable implementation of {@link JedisClientConfiguration}.
|
||||
*
|
||||
* @author Mark Paluch
|
||||
*/
|
||||
static class MutableJedisClientConfiguration implements JedisClientConfiguration {
|
||||
|
||||
private boolean useSsl;
|
||||
@@ -912,26 +907,22 @@ public class JedisConnectionFactory implements InitializingBean, DisposableBean,
|
||||
public static JedisClientConfiguration create(JedisShardInfo shardInfo) {
|
||||
|
||||
MutableJedisClientConfiguration configuration = new MutableJedisClientConfiguration();
|
||||
|
||||
configuration.setShardInfo(shardInfo);
|
||||
|
||||
return configuration;
|
||||
}
|
||||
|
||||
public static JedisClientConfiguration create(GenericObjectPoolConfig jedisPoolConfig) {
|
||||
|
||||
MutableJedisClientConfiguration configuration = new MutableJedisClientConfiguration();
|
||||
|
||||
configuration.setPoolConfig(jedisPoolConfig);
|
||||
|
||||
return configuration;
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see org.springframework.data.redis.connection.jedis.JedisClientConfiguration#useSsl()
|
||||
* @see org.springframework.data.redis.connection.jedis.JedisClientConfiguration#isUseSsl()
|
||||
*/
|
||||
@Override
|
||||
public boolean useSsl() {
|
||||
public boolean isUseSsl() {
|
||||
return useSsl;
|
||||
}
|
||||
|
||||
@@ -939,7 +930,8 @@ public class JedisConnectionFactory implements InitializingBean, DisposableBean,
|
||||
this.useSsl = useSsl;
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
/*
|
||||
* (non-Javadoc)
|
||||
* @see org.springframework.data.redis.connection.jedis.JedisClientConfiguration#getSslSocketFactory()
|
||||
*/
|
||||
@Override
|
||||
@@ -951,7 +943,8 @@ public class JedisConnectionFactory implements InitializingBean, DisposableBean,
|
||||
this.sslSocketFactory = sslSocketFactory;
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
/*
|
||||
* (non-Javadoc)
|
||||
* @see org.springframework.data.redis.connection.jedis.JedisClientConfiguration#getSslParameters()
|
||||
*/
|
||||
@Override
|
||||
@@ -963,7 +956,8 @@ public class JedisConnectionFactory implements InitializingBean, DisposableBean,
|
||||
this.sslParameters = sslParameters;
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
/*
|
||||
* (non-Javadoc)
|
||||
* @see org.springframework.data.redis.connection.jedis.JedisClientConfiguration#getHostnameVerifier()
|
||||
*/
|
||||
@Override
|
||||
@@ -975,11 +969,12 @@ public class JedisConnectionFactory implements InitializingBean, DisposableBean,
|
||||
this.hostnameVerifier = hostnameVerifier;
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see org.springframework.data.redis.connection.jedis.JedisClientConfiguration#usePooling()
|
||||
/*
|
||||
* (non-Javadoc)
|
||||
* @see org.springframework.data.redis.connection.jedis.JedisClientConfiguration#isUsePooling()
|
||||
*/
|
||||
@Override
|
||||
public boolean usePooling() {
|
||||
public boolean isUsePooling() {
|
||||
return usePooling;
|
||||
}
|
||||
|
||||
@@ -987,7 +982,8 @@ public class JedisConnectionFactory implements InitializingBean, DisposableBean,
|
||||
this.usePooling = usePooling;
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
/*
|
||||
* (non-Javadoc)
|
||||
* @see org.springframework.data.redis.connection.jedis.JedisClientConfiguration#getPoolConfig()
|
||||
*/
|
||||
@Override
|
||||
@@ -999,7 +995,8 @@ public class JedisConnectionFactory implements InitializingBean, DisposableBean,
|
||||
this.poolConfig = poolConfig;
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
/*
|
||||
* (non-Javadoc)
|
||||
* @see org.springframework.data.redis.connection.jedis.JedisClientConfiguration#getClientName()
|
||||
*/
|
||||
@Override
|
||||
@@ -1011,7 +1008,8 @@ public class JedisConnectionFactory implements InitializingBean, DisposableBean,
|
||||
this.clientName = clientName;
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
/*
|
||||
* (non-Javadoc)
|
||||
* @see org.springframework.data.redis.connection.jedis.JedisClientConfiguration#getReadTimeout()
|
||||
*/
|
||||
@Override
|
||||
@@ -1023,7 +1021,8 @@ public class JedisConnectionFactory implements InitializingBean, DisposableBean,
|
||||
this.readTimeout = readTimeout;
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
/*
|
||||
* (non-Javadoc)
|
||||
* @see org.springframework.data.redis.connection.jedis.JedisClientConfiguration#getConnectTimeout()
|
||||
*/
|
||||
@Override
|
||||
|
||||
@@ -53,7 +53,7 @@ class DefaultLettuceClientConfiguration implements LettuceClientConfiguration {
|
||||
* @see org.springframework.data.redis.connection.lettuce.LettuceClientConfiguration#useSsl()
|
||||
*/
|
||||
@Override
|
||||
public boolean useSsl() {
|
||||
public boolean isUseSsl() {
|
||||
return useSsl;
|
||||
}
|
||||
|
||||
@@ -93,7 +93,7 @@ class DefaultLettuceClientConfiguration implements LettuceClientConfiguration {
|
||||
* @see org.springframework.data.redis.connection.lettuce.LettuceClientConfiguration#getTimeout()
|
||||
*/
|
||||
@Override
|
||||
public Duration getTimeout() {
|
||||
public Duration getCommandTimeout() {
|
||||
return timeout;
|
||||
}
|
||||
|
||||
|
||||
@@ -41,6 +41,7 @@ import org.springframework.util.Assert;
|
||||
* </ul>
|
||||
*
|
||||
* @author Mark Paluch
|
||||
* @author Christoph Strobl
|
||||
* @since 2.0
|
||||
* @see org.springframework.data.redis.connection.RedisStandaloneConfiguration
|
||||
* @see org.springframework.data.redis.connection.RedisSentinelConfiguration
|
||||
@@ -51,10 +52,10 @@ public interface LettuceClientConfiguration {
|
||||
/**
|
||||
* @return {@literal true} to use SSL, {@literal false} to use unencrypted connections.
|
||||
*/
|
||||
boolean useSsl();
|
||||
boolean isUseSsl();
|
||||
|
||||
/**
|
||||
* @return {@literal true} to verify peers when using {@link #useSsl() SSL}.
|
||||
* @return {@literal true} to verify peers when using {@link #isUseSsl() SSL}.
|
||||
*/
|
||||
boolean isVerifyPeer();
|
||||
|
||||
@@ -76,7 +77,7 @@ public interface LettuceClientConfiguration {
|
||||
/**
|
||||
* @return the timeout.
|
||||
*/
|
||||
Duration getTimeout();
|
||||
Duration getCommandTimeout();
|
||||
|
||||
/**
|
||||
* @return the shutdown timeout used to close the client.
|
||||
@@ -95,11 +96,27 @@ public interface LettuceClientConfiguration {
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates an empty {@link LettuceClientConfiguration}.
|
||||
* Creates a default {@link LettuceClientConfiguration} with:
|
||||
* <dl>
|
||||
* <dt>SSL</dt>
|
||||
* <dd>no</dd>
|
||||
* <dt>Peer Verification</dt>
|
||||
* <dd>yes</dd>
|
||||
* <dt>Start TLS</dt>
|
||||
* <dd>no</dd>
|
||||
* <dt>Client Options</dt>
|
||||
* <dd>none</dd>
|
||||
* <dt>Client Resources</dt>
|
||||
* <dd>none</dd>
|
||||
* <dt>Connect Timeout</dt>
|
||||
* <dd>60 Seconds</dd>
|
||||
* <dt>Shutdown Timeout</dt>
|
||||
* <dd>2 Seconds</dd>
|
||||
* </dl>
|
||||
*
|
||||
* @return an empty {@link LettuceClientConfiguration}.
|
||||
* @return a {@link LettuceClientConfiguration} with defaults.
|
||||
*/
|
||||
static LettuceClientConfiguration create() {
|
||||
static LettuceClientConfiguration defaultConfiguration() {
|
||||
return builder().build();
|
||||
}
|
||||
|
||||
@@ -115,18 +132,12 @@ public interface LettuceClientConfiguration {
|
||||
*/
|
||||
LettuceSslClientConfigurationBuilder useSsl();
|
||||
|
||||
/**
|
||||
* Use plaintext connections instead of SSL.
|
||||
*
|
||||
* @return {@link LettuceClientConfigurationBuilder}.
|
||||
*/
|
||||
LettuceClientConfigurationBuilder usePlaintext();
|
||||
|
||||
/**
|
||||
* Configure {@link ClientResources}.
|
||||
*
|
||||
* @param clientResources must not be {@literal null}.
|
||||
* @return {@literal this} builder.
|
||||
* @throws IllegalArgumentException if clientResources is {@literal null}.
|
||||
*/
|
||||
LettuceClientConfigurationBuilder clientResources(ClientResources clientResources);
|
||||
|
||||
@@ -135,24 +146,25 @@ public interface LettuceClientConfiguration {
|
||||
*
|
||||
* @param clientOptions must not be {@literal null}.
|
||||
* @return {@literal this} builder.
|
||||
* @see ClientOptions
|
||||
* @see io.lettuce.core.cluster.ClusterClientOptions
|
||||
* @throws IllegalArgumentException if clientOptions is {@literal null}.
|
||||
*/
|
||||
LettuceClientConfigurationBuilder clientOptions(ClientOptions clientOptions);
|
||||
|
||||
/**
|
||||
* Configure a timeout.
|
||||
* Configure a command timeout.
|
||||
*
|
||||
* @param timeout must not be {@literal null}.
|
||||
* @return {@literal this} builder.
|
||||
* @throws IllegalArgumentException if timeout is {@literal null}.
|
||||
*/
|
||||
LettuceClientConfigurationBuilder timeout(Duration timeout);
|
||||
LettuceClientConfigurationBuilder commandTimeout(Duration timeout);
|
||||
|
||||
/**
|
||||
* Configure a shutdown timeout.
|
||||
*
|
||||
* @param shutdownTimeout must not be {@literal null}.
|
||||
* @return {@literal this} builder.
|
||||
* @throws IllegalArgumentException if shutdownTimeout is {@literal null}.
|
||||
*/
|
||||
LettuceClientConfigurationBuilder shutdownTimeout(Duration shutdownTimeout);
|
||||
|
||||
@@ -170,19 +182,11 @@ public interface LettuceClientConfiguration {
|
||||
interface LettuceSslClientConfigurationBuilder {
|
||||
|
||||
/**
|
||||
* Enable peer verification.
|
||||
* Disable peer verification.
|
||||
*
|
||||
* @return {@literal this} builder.
|
||||
*/
|
||||
LettuceSslClientConfigurationBuilder verifyPeer();
|
||||
|
||||
/**
|
||||
* Enable/disable peer verification.
|
||||
*
|
||||
* @param verifyPeer {@literal true} to enable peer verification, {@literal false} to skip peer verification.
|
||||
* @return {@literal this} builder.
|
||||
*/
|
||||
LettuceSslClientConfigurationBuilder verifyPeer(boolean verifyPeer);
|
||||
LettuceSslClientConfigurationBuilder disablePeerVerification();
|
||||
|
||||
/**
|
||||
* Enable Start TLS to send the first bytes unencrypted.
|
||||
@@ -223,7 +227,8 @@ public interface LettuceClientConfiguration {
|
||||
|
||||
private DefaultLettuceClientConfigurationBuilder() {}
|
||||
|
||||
/* (non-Javadoc)
|
||||
/*d
|
||||
* (non-Javadoc)
|
||||
* @see org.springframework.data.redis.connection.lettuce.LettuceClientConfiguration.LettuceClientConfigurationBuilder#useSsl()
|
||||
*/
|
||||
@Override
|
||||
@@ -233,35 +238,19 @@ public interface LettuceClientConfiguration {
|
||||
return this;
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see org.springframework.data.redis.connection.lettuce.LettuceClientConfiguration.LettuceClientConfigurationBuilder#usePlaintext()
|
||||
/*
|
||||
*(non-Javadoc)
|
||||
* @see org.springframework.data.redis.connection.lettuce.LettuceClientConfiguration.LettuceSslClientConfigurationBuilder#disablePeerVerification()
|
||||
*/
|
||||
@Override
|
||||
public LettuceClientConfigurationBuilder usePlaintext() {
|
||||
public LettuceSslClientConfigurationBuilder disablePeerVerification() {
|
||||
|
||||
this.useSsl = false;
|
||||
this.verifyPeer = false;
|
||||
return this;
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see org.springframework.data.redis.connection.lettuce.LettuceClientConfiguration.LettuceSslClientConfigurationBuilder#verifyPeer()
|
||||
*/
|
||||
@Override
|
||||
public LettuceSslClientConfigurationBuilder verifyPeer() {
|
||||
return verifyPeer(true);
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see org.springframework.data.redis.connection.lettuce.LettuceClientConfiguration.LettuceSslClientConfigurationBuilder#verifyPeer(boolean)
|
||||
*/
|
||||
@Override
|
||||
public LettuceSslClientConfigurationBuilder verifyPeer(boolean verifyPeer) {
|
||||
|
||||
this.verifyPeer = verifyPeer;
|
||||
return this;
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
/*
|
||||
* (non-Javadoc)
|
||||
* @see org.springframework.data.redis.connection.lettuce.LettuceClientConfiguration.LettuceSslClientConfigurationBuilder#startTls()
|
||||
*/
|
||||
@Override
|
||||
@@ -271,7 +260,8 @@ public interface LettuceClientConfiguration {
|
||||
return this;
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
/*
|
||||
* (non-Javadoc)
|
||||
* @see org.springframework.data.redis.connection.lettuce.LettuceClientConfiguration.LettuceSslClientConfigurationBuilder#and()
|
||||
*/
|
||||
@Override
|
||||
@@ -279,7 +269,8 @@ public interface LettuceClientConfiguration {
|
||||
return this;
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
/*
|
||||
* (non-Javadoc)
|
||||
* @see org.springframework.data.redis.connection.lettuce.LettuceClientConfiguration.LettuceClientConfigurationBuilder#clientResources(io.lettuce.core.resource.ClientResources)
|
||||
*/
|
||||
@Override
|
||||
@@ -291,7 +282,8 @@ public interface LettuceClientConfiguration {
|
||||
return this;
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
/*
|
||||
* (non-Javadoc)
|
||||
* @see org.springframework.data.redis.connection.lettuce.LettuceClientConfiguration.LettuceClientConfigurationBuilder#clientOptions(io.lettuce.core.ClientOptions)
|
||||
*/
|
||||
@Override
|
||||
@@ -303,11 +295,12 @@ public interface LettuceClientConfiguration {
|
||||
return this;
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
/*
|
||||
* (non-Javadoc)
|
||||
* @see org.springframework.data.redis.connection.lettuce.LettuceClientConfiguration.LettuceClientConfigurationBuilder#timeout(java.time.Duration)
|
||||
*/
|
||||
@Override
|
||||
public LettuceClientConfigurationBuilder timeout(Duration timeout) {
|
||||
public LettuceClientConfigurationBuilder commandTimeout(Duration timeout) {
|
||||
|
||||
Assert.notNull(timeout, "Duration must not be null!");
|
||||
|
||||
@@ -315,7 +308,8 @@ public interface LettuceClientConfiguration {
|
||||
return this;
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
/*
|
||||
* (non-Javadoc)
|
||||
* @see org.springframework.data.redis.connection.lettuce.LettuceClientConfiguration.LettuceClientConfigurationBuilder#shutdownTimeout(java.time.Duration)
|
||||
*/
|
||||
@Override
|
||||
@@ -327,7 +321,8 @@ public interface LettuceClientConfiguration {
|
||||
return this;
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
/*
|
||||
* (non-Javadoc)
|
||||
* @see org.springframework.data.redis.connection.lettuce.LettuceClientConfiguration.LettuceClientConfigurationBuilder#build()
|
||||
*/
|
||||
@Override
|
||||
|
||||
@@ -41,7 +41,18 @@ import org.springframework.dao.InvalidDataAccessResourceUsageException;
|
||||
import org.springframework.data.redis.ExceptionTranslationStrategy;
|
||||
import org.springframework.data.redis.PassThroughExceptionTranslationStrategy;
|
||||
import org.springframework.data.redis.RedisConnectionFailureException;
|
||||
import org.springframework.data.redis.connection.*;
|
||||
import org.springframework.data.redis.connection.ClusterCommandExecutor;
|
||||
import org.springframework.data.redis.connection.Pool;
|
||||
import org.springframework.data.redis.connection.ReactiveRedisConnectionFactory;
|
||||
import org.springframework.data.redis.connection.RedisClusterConfiguration;
|
||||
import org.springframework.data.redis.connection.RedisClusterConnection;
|
||||
import org.springframework.data.redis.connection.RedisConnection;
|
||||
import org.springframework.data.redis.connection.RedisConnectionFactory;
|
||||
import org.springframework.data.redis.connection.RedisNode;
|
||||
import org.springframework.data.redis.connection.RedisPassword;
|
||||
import org.springframework.data.redis.connection.RedisSentinelConfiguration;
|
||||
import org.springframework.data.redis.connection.RedisSentinelConnection;
|
||||
import org.springframework.data.redis.connection.RedisStandaloneConfiguration;
|
||||
import org.springframework.util.Assert;
|
||||
import org.springframework.util.ClassUtils;
|
||||
|
||||
@@ -75,8 +86,6 @@ import org.springframework.util.ClassUtils;
|
||||
public class LettuceConnectionFactory
|
||||
implements InitializingBean, DisposableBean, RedisConnectionFactory, ReactiveRedisConnectionFactory {
|
||||
|
||||
public static final String PING_REPLY = "PONG";
|
||||
|
||||
private static final ExceptionTranslationStrategy EXCEPTION_TRANSLATION = new PassThroughExceptionTranslationStrategy(
|
||||
LettuceConverters.exceptionConverter());
|
||||
|
||||
@@ -409,7 +418,7 @@ public class LettuceConnectionFactory
|
||||
* @return use of SSL.
|
||||
*/
|
||||
public boolean isUseSsl() {
|
||||
return clientConfiguration.useSsl();
|
||||
return clientConfiguration.isUseSsl();
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -800,10 +809,10 @@ public class LettuceConnectionFactory
|
||||
|
||||
getRedisPassword().toOptional().ifPresent(builder::withPassword);
|
||||
|
||||
builder.withSsl(clientConfiguration.useSsl());
|
||||
builder.withSsl(clientConfiguration.isUseSsl());
|
||||
builder.withVerifyPeer(clientConfiguration.isVerifyPeer());
|
||||
builder.withStartTls(clientConfiguration.isStartTls());
|
||||
builder.withTimeout(clientConfiguration.getTimeout().toMillis(), TimeUnit.MILLISECONDS);
|
||||
builder.withTimeout(clientConfiguration.getCommandTimeout().toMillis(), TimeUnit.MILLISECONDS);
|
||||
|
||||
return builder.build();
|
||||
}
|
||||
@@ -827,9 +836,14 @@ public class LettuceConnectionFactory
|
||||
}
|
||||
|
||||
private long getClientTimeout() {
|
||||
return clientConfiguration.getTimeout().toMillis();
|
||||
return clientConfiguration.getCommandTimeout().toMillis();
|
||||
}
|
||||
|
||||
/**
|
||||
* Mutable implementation of {@link LettuceClientConfiguration}.
|
||||
*
|
||||
* @author Mark Paluch
|
||||
*/
|
||||
static class MutableLettuceClientConfiguration implements LettuceClientConfiguration {
|
||||
|
||||
private boolean useSsl;
|
||||
@@ -840,10 +854,10 @@ public class LettuceConnectionFactory
|
||||
private Duration shutdownTimeout = Duration.ofSeconds(RedisURI.DEFAULT_TIMEOUT);
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see org.springframework.data.redis.connection.lettuce.LettuceClientConfiguration#useSsl()
|
||||
* @see org.springframework.data.redis.connection.lettuce.LettuceClientConfiguration#isUseSsl()
|
||||
*/
|
||||
@Override
|
||||
public boolean useSsl() {
|
||||
public boolean isUseSsl() {
|
||||
return useSsl;
|
||||
}
|
||||
|
||||
@@ -899,7 +913,7 @@ public class LettuceConnectionFactory
|
||||
* @see org.springframework.data.redis.connection.lettuce.LettuceClientConfiguration#getTimeout()
|
||||
*/
|
||||
@Override
|
||||
public Duration getTimeout() {
|
||||
public Duration getCommandTimeout() {
|
||||
return timeout;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user