public class RedisSentinelConfiguration extends Object implements RedisConfiguration, RedisConfiguration.SentinelConfiguration
RedisConnection
via RedisConnectionFactory
using connecting
to Redis Sentinel(s). Useful when setting up a high availability Redis
environment.RedisConfiguration.ClusterConfiguration, RedisConfiguration.DomainSocketConfiguration, RedisConfiguration.SentinelConfiguration, RedisConfiguration.StaticMasterReplicaConfiguration, RedisConfiguration.WithAuthentication, RedisConfiguration.WithDatabaseIndex, RedisConfiguration.WithDomainSocket, RedisConfiguration.WithHostAndPort, RedisConfiguration.WithPassword
Constructor and Description |
---|
RedisSentinelConfiguration()
Creates new
RedisSentinelConfiguration . |
RedisSentinelConfiguration(PropertySource<?> propertySource)
Creates
RedisSentinelConfiguration looking up values in given PropertySource . |
RedisSentinelConfiguration(String master,
Set<String> sentinelHostAndPorts)
Creates
RedisSentinelConfiguration for given hostPort combinations. |
Modifier and Type | Method and Description |
---|---|
void |
addSentinel(RedisNode sentinel)
Add sentinel.
|
boolean |
equals(Object o) |
int |
getDatabase()
Get the database index to use.
|
NamedNode |
getMaster()
Get the Sentinel master node.
|
RedisPassword |
getPassword()
Get the RedisPassword to use when connecting.
|
RedisPassword |
getSentinelPassword()
Returns the
RedisPassword to use when connecting to a Redis Sentinel. |
Set<RedisNode> |
getSentinels()
Returns an
Collections.unmodifiableSet(Set) of Sentinels. |
String |
getUsername()
Get the username to use when connecting.
|
int |
hashCode() |
RedisSentinelConfiguration |
master(NamedNode master) |
RedisSentinelConfiguration |
master(String master) |
RedisSentinelConfiguration |
sentinel(RedisNode sentinel) |
RedisSentinelConfiguration |
sentinel(String host,
Integer port) |
void |
setDatabase(int index)
Set the database index to use.
|
void |
setMaster(NamedNode master)
Set the master node.
|
void |
setPassword(RedisPassword password)
Create and set a
RedisPassword for given String . |
void |
setSentinelPassword(RedisPassword sentinelPassword)
Set a
RedisPassword to be used when authenticating with Redis Sentinel. |
void |
setSentinels(Iterable<RedisNode> sentinels)
Set Sentinels to connect to.
|
void |
setUsername(String username)
Create and set a username with the given
String . |
clone, finalize, getClass, notify, notifyAll, toString, wait, wait, wait
getDatabaseOrElse, getDatabaseOrElse, getHostOrElse, getPasswordOrElse, getPasswordOrElse, getPortOrElse, getUsernameOrElse, isAuthenticationAware, isClusterConfiguration, isDatabaseIndexAware, isDomainSocketConfiguration, isHostAndPortAware, isSentinelConfiguration, isStaticMasterReplicaConfiguration
getDataNodePassword, getDataNodeUsername, setMaster, setSentinelPassword, setSentinelPassword
setPassword, setPassword
public RedisSentinelConfiguration()
RedisSentinelConfiguration
.public RedisSentinelConfiguration(String master, Set<String> sentinelHostAndPorts)
RedisSentinelConfiguration
for given hostPort combinations.
sentinelHostAndPorts[0] = 127.0.0.1:23679 sentinelHostAndPorts[1] = 127.0.0.1:23680 ...
sentinelHostAndPorts
- must not be null.public RedisSentinelConfiguration(PropertySource<?> propertySource)
RedisSentinelConfiguration
looking up values in given PropertySource
.
spring.redis.sentinel.master=myMaster
spring.redis.sentinel.nodes=127.0.0.1:23679,127.0.0.1:23680,127.0.0.1:23681
propertySource
- must not be null.public void setSentinels(Iterable<RedisNode> sentinels)
sentinels
- must not be null.public Set<RedisNode> getSentinels()
RedisConfiguration.SentinelConfiguration
Collections.unmodifiableSet(Set)
of Sentinels.getSentinels
in interface RedisConfiguration.SentinelConfiguration
Set
of sentinels. Never null.public void addSentinel(RedisNode sentinel)
sentinel
- must not be null.public void setMaster(NamedNode master)
RedisConfiguration.SentinelConfiguration
setMaster
in interface RedisConfiguration.SentinelConfiguration
master
- must not be null.public NamedNode getMaster()
RedisConfiguration.SentinelConfiguration
getMaster
in interface RedisConfiguration.SentinelConfiguration
public RedisSentinelConfiguration master(String master)
master
- The master node name.RedisConfiguration.SentinelConfiguration.setMaster(String)
public RedisSentinelConfiguration master(NamedNode master)
master
- the master nodesetMaster(NamedNode)
public RedisSentinelConfiguration sentinel(RedisNode sentinel)
sentinel
- the node to add as sentinel.addSentinel(RedisNode)
public RedisSentinelConfiguration sentinel(String host, Integer port)
host
- redis sentinel node host name or ip.port
- redis sentinel port.sentinel(RedisNode)
public int getDatabase()
RedisConfiguration.WithDatabaseIndex
getDatabase
in interface RedisConfiguration.WithDatabaseIndex
zero
by default.public void setDatabase(int index)
RedisConfiguration.WithDatabaseIndex
setDatabase
in interface RedisConfiguration.WithDatabaseIndex
public void setUsername(@Nullable String username)
RedisConfiguration.WithAuthentication
String
. Requires Redis 6 or newer.setUsername
in interface RedisConfiguration.WithAuthentication
username
- the username.@Nullable public String getUsername()
RedisConfiguration.WithAuthentication
getUsername
in interface RedisConfiguration.WithAuthentication
public RedisPassword getPassword()
RedisConfiguration.WithAuthentication
getPassword
in interface RedisConfiguration.WithAuthentication
RedisPassword.none()
if none set.public void setPassword(RedisPassword password)
RedisConfiguration.WithAuthentication
RedisPassword
for given String
.setPassword
in interface RedisConfiguration.WithAuthentication
password
- must not be null use RedisPassword.none()
instead.public void setSentinelPassword(RedisPassword sentinelPassword)
RedisConfiguration.SentinelConfiguration
RedisPassword
to be used when authenticating with Redis Sentinel.setSentinelPassword
in interface RedisConfiguration.SentinelConfiguration
sentinelPassword
- must not be null use RedisPassword.none()
instead.public RedisPassword getSentinelPassword()
RedisConfiguration.SentinelConfiguration
RedisPassword
to use when connecting to a Redis Sentinel. RedisConfiguration.SentinelConfiguration.setSentinelPassword(RedisPassword)
or RedisPassword.none()
if no password has
been set.getSentinelPassword
in interface RedisConfiguration.SentinelConfiguration
RedisPassword
for authenticating with Redis Sentinel.Copyright © 2011–2021 Pivotal Software, Inc.. All rights reserved.