Class RedisSentinelConfiguration
java.lang.Object
org.springframework.data.redis.connection.RedisSentinelConfiguration
- All Implemented Interfaces:
RedisConfiguration, RedisConfiguration.SentinelConfiguration, RedisConfiguration.WithAuthentication, RedisConfiguration.WithDatabaseIndex, RedisConfiguration.WithPassword
public class RedisSentinelConfiguration
extends Object
implements RedisConfiguration, RedisConfiguration.SentinelConfiguration
Configuration class used to set up a RedisConnection with
RedisConnectionFactory for connecting to Redis Sentinel(s).
Useful when setting up a highly available Redis environment.- Since:
- 1.4
- Author:
- Christoph Strobl, Thomas Darimont, Mark Paluch, Vikas Garg, John Blum, Samuel Klose, Mustapha Zorgati
-
Nested Class Summary
Nested classes/interfaces inherited from interface RedisConfiguration
RedisConfiguration.ClusterConfiguration, RedisConfiguration.DomainSocketConfiguration, RedisConfiguration.SentinelConfiguration, RedisConfiguration.StaticMasterReplicaConfiguration, RedisConfiguration.WithAuthentication, RedisConfiguration.WithDatabaseIndex, RedisConfiguration.WithDomainSocket, RedisConfiguration.WithHostAndPort, RedisConfiguration.WithPassword -
Constructor Summary
ConstructorsConstructorDescriptionCreates a new, defaultRedisSentinelConfiguration.RedisSentinelConfiguration(String master, Set<String> sentinelHostAndPorts) Creates a newRedisSentinelConfigurationfor givenhostPortcombinations. -
Method Summary
Modifier and TypeMethodDescriptionvoidaddSentinel(RedisNode sentinel) Add sentinel.booleanintGet the database index to use.@Nullable NamedNodeGet the Sentinel master node.Get the RedisPassword to use when connecting.Returns theRedisPasswordto use when connecting to a Redis Sentinel.Returns anCollections.unmodifiableSet(Set)of Sentinels.@Nullable StringGet the username to use when connecting.@Nullable StringGet the username to use when connecting.inthashCode()static RedisSentinelConfigurationof(PropertySource<?> propertySource) Construct a newRedisSentinelConfigurationfrom the givenPropertySource.voidsetDatabase(int index) Set the database index to use.voidSet the master node.voidsetPassword(RedisPassword password) Create and set aRedisPasswordfor givenString.voidsetSentinelPassword(RedisPassword sentinelPassword) Set aRedisPasswordto be used when authenticating with Redis Sentinel.voidsetSentinels(Iterable<RedisNode> sentinels) Set Sentinels to connect to.voidsetSentinelUsername(@Nullable String sentinelUsername) Create and set a username with the givenString.voidsetUsername(@Nullable String username) Create and set a username with the givenString.Methods inherited from class Object
clone, finalize, getClass, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface RedisConfiguration
getDatabaseOrElse, getPasswordOrElseMethods inherited from interface RedisConfiguration.SentinelConfiguration
getDataNodePassword, getDataNodeUsername, setMaster, setSentinelPassword, setSentinelPasswordMethods inherited from interface RedisConfiguration.WithAuthentication
setPassword, setPassword
-
Constructor Details
-
RedisSentinelConfiguration
public RedisSentinelConfiguration()Creates a new, defaultRedisSentinelConfiguration. -
RedisSentinelConfiguration
Creates a newRedisSentinelConfigurationfor givenhostPortcombinations.sentinelHostAndPorts[0] = 127.0.0.1:23679 sentinelHostAndPorts[1] = 127.0.0.1:23680 ...
- Parameters:
sentinelHostAndPorts- must not be null.- Since:
- 1.5
-
-
Method Details
-
of
Construct a newRedisSentinelConfigurationfrom the givenPropertySource.- Parameters:
propertySource- must not be null.- Returns:
- a new
RedisSentinelConfigurationconfigured from the givenPropertySource. - Since:
- 3.3
-
setSentinels
-
getSentinels
Description copied from interface:RedisConfiguration.SentinelConfigurationReturns anCollections.unmodifiableSet(Set)of Sentinels.- Specified by:
getSentinelsin interfaceRedisConfiguration.SentinelConfiguration- Returns:
Setof sentinels. Never null.
-
addSentinel
-
setMaster
Description copied from interface:RedisConfiguration.SentinelConfigurationSet the master node.- Specified by:
setMasterin interfaceRedisConfiguration.SentinelConfiguration- Parameters:
master- must not be null.
-
getMaster
Description copied from interface:RedisConfiguration.SentinelConfigurationGet the Sentinel master node.- Specified by:
getMasterin interfaceRedisConfiguration.SentinelConfiguration- Returns:
- get the master node or null if not set.
-
master
- Parameters:
master- The master node name.- Returns:
- this.
- See Also:
-
master
- Parameters:
master- the master node- Returns:
- this.
- See Also:
-
sentinel
- Parameters:
sentinel- the node to add as sentinel.- Returns:
- this.
- See Also:
-
sentinel
- Parameters:
host- redis sentinel node host name or ip.port- redis sentinel port.- Returns:
- this.
- See Also:
-
getDatabase
public int getDatabase()Description copied from interface:RedisConfiguration.WithDatabaseIndexGet the database index to use.- Specified by:
getDatabasein interfaceRedisConfiguration.WithDatabaseIndex- Returns:
zeroby default.
-
setDatabase
public void setDatabase(int index) Description copied from interface:RedisConfiguration.WithDatabaseIndexSet the database index to use.- Specified by:
setDatabasein interfaceRedisConfiguration.WithDatabaseIndex- Parameters:
index-
-
setUsername
Description copied from interface:RedisConfiguration.WithAuthenticationCreate and set a username with the givenString. Requires Redis 6 or newer.- Specified by:
setUsernamein interfaceRedisConfiguration.WithAuthentication- Parameters:
username- the username.
-
getUsername
Description copied from interface:RedisConfiguration.WithAuthenticationGet the username to use when connecting.- Specified by:
getUsernamein interfaceRedisConfiguration.WithAuthentication- Returns:
- null if none set.
-
getPassword
Description copied from interface:RedisConfiguration.WithAuthenticationGet the RedisPassword to use when connecting.- Specified by:
getPasswordin interfaceRedisConfiguration.WithAuthentication- Returns:
RedisPassword.none()if none set.
-
setPassword
Description copied from interface:RedisConfiguration.WithAuthenticationCreate and set aRedisPasswordfor givenString.- Specified by:
setPasswordin interfaceRedisConfiguration.WithAuthentication- Parameters:
password- must not be null useRedisPassword.none()instead.
-
getSentinelUsername
Description copied from interface:RedisConfiguration.SentinelConfigurationGet the username to use when connecting.- Specified by:
getSentinelUsernamein interfaceRedisConfiguration.SentinelConfiguration- Returns:
- null if none set.
-
setSentinelUsername
Description copied from interface:RedisConfiguration.SentinelConfigurationCreate and set a username with the givenString. Requires Redis 6 or newer.- Specified by:
setSentinelUsernamein interfaceRedisConfiguration.SentinelConfiguration- Parameters:
sentinelUsername- the username for sentinel.
-
setSentinelPassword
Description copied from interface:RedisConfiguration.SentinelConfigurationSet aRedisPasswordto be used when authenticating with Redis Sentinel.- Specified by:
setSentinelPasswordin interfaceRedisConfiguration.SentinelConfiguration- Parameters:
sentinelPassword- must not be null useRedisPassword.none()instead.
-
getSentinelPassword
Description copied from interface:RedisConfiguration.SentinelConfigurationReturns theRedisPasswordto use when connecting to a Redis Sentinel.
Can be set viaRedisConfiguration.SentinelConfiguration.setSentinelPassword(RedisPassword)orRedisPassword.none()if no password has been set.- Specified by:
getSentinelPasswordin interfaceRedisConfiguration.SentinelConfiguration- Returns:
- the
RedisPasswordfor authenticating with Redis Sentinel.
-
equals
-
hashCode
-