Class LettuceSentinelConnection
java.lang.Object
org.springframework.data.redis.connection.lettuce.LettuceSentinelConnection
- All Implemented Interfaces:
Closeable
,AutoCloseable
,RedisSentinelCommands
,RedisSentinelConnection
- Since:
- 1.5
- Author:
- Christoph Strobl, Mark Paluch
-
Constructor Summary
ModifierConstructorDescriptionLettuceSentinelConnection
(io.lettuce.core.RedisClient redisClient) Creates aLettuceSentinelConnection
using a suppliedRedisClient
.protected
LettuceSentinelConnection
(io.lettuce.core.sentinel.api.StatefulRedisSentinelConnection<String, String> connection) Creates aLettuceSentinelConnection
using a supplied redis connection.LettuceSentinelConnection
(String host, int port) LettuceSentinelConnection
(String host, int port, io.lettuce.core.resource.ClientResources clientResources) Creates aLettuceSentinelConnection
with a client for the suppliedhost
andport
and reuse existingClientResources
.LettuceSentinelConnection
(LettuceConnectionProvider connectionProvider) Creates aLettuceSentinelConnection
using aLettuceConnectionProvider
.LettuceSentinelConnection
(RedisNode sentinel) Creates aLettuceSentinelConnection
with a dedicated client for a suppliedRedisNode
. -
Method Summary
Modifier and TypeMethodDescriptionvoid
close()
void
Force a failover as if the master was not reachable.boolean
isOpen()
masters()
Get aCollection
of monitored masters and their state.void
monitor
(RedisServer server) Tell sentinel to start monitoring a new master with the specifiedRedisNode.getName()
,RedisNode.getHost()
,RedisNode.getPort()
, andRedisServer.getQuorum()
.void
void
Removes given master.Show list of replicas for given master.
-
Constructor Details
-
LettuceSentinelConnection
Creates aLettuceSentinelConnection
with a dedicated client for a suppliedRedisNode
.- Parameters:
sentinel
- The sentinel to connect to.
-
LettuceSentinelConnection
- Parameters:
host
- must not be null.port
- sentinel port.
-
LettuceSentinelConnection
public LettuceSentinelConnection(String host, int port, io.lettuce.core.resource.ClientResources clientResources) Creates aLettuceSentinelConnection
with a client for the suppliedhost
andport
and reuse existingClientResources
.- Parameters:
host
- must not be null.port
- sentinel port.clientResources
- must not be null.
-
LettuceSentinelConnection
public LettuceSentinelConnection(io.lettuce.core.RedisClient redisClient) Creates aLettuceSentinelConnection
using a suppliedRedisClient
.- Parameters:
redisClient
- must not be null.
-
LettuceSentinelConnection
protected LettuceSentinelConnection(io.lettuce.core.sentinel.api.StatefulRedisSentinelConnection<String, String> connection) Creates aLettuceSentinelConnection
using a supplied redis connection.- Parameters:
connection
- native Lettuce connection, must not be null
-
LettuceSentinelConnection
Creates aLettuceSentinelConnection
using aLettuceConnectionProvider
.- Parameters:
connectionProvider
- must not be null.- Since:
- 2.0
-
-
Method Details
-
failover
Description copied from interface:RedisSentinelCommands
Force a failover as if the master was not reachable.- Specified by:
failover
in interfaceRedisSentinelCommands
- Parameters:
master
- must not be null.
-
masters
Description copied from interface:RedisSentinelCommands
Get aCollection
of monitored masters and their state.- Specified by:
masters
in interfaceRedisSentinelCommands
- Returns:
- Collection of
RedisServer
s. Never null.
-
replicas
Description copied from interface:RedisSentinelCommands
Show list of replicas for given master.- Specified by:
replicas
in interfaceRedisSentinelCommands
- Parameters:
master
- must not be null.- Returns:
- Collection of
RedisServer
s. Never null.
-
slaves
- Parameters:
masterName
-- Returns:
- See Also:
-
remove
Description copied from interface:RedisSentinelCommands
Removes given master. The server will no longer be monitored and will no longer be returned byRedisSentinelCommands.masters()
.- Specified by:
remove
in interfaceRedisSentinelCommands
- Parameters:
master
- must not be null.
-
remove
- Parameters:
masterName
-- See Also:
-
monitor
Description copied from interface:RedisSentinelCommands
Tell sentinel to start monitoring a new master with the specifiedRedisNode.getName()
,RedisNode.getHost()
,RedisNode.getPort()
, andRedisServer.getQuorum()
.- Specified by:
monitor
in interfaceRedisSentinelCommands
- Parameters:
server
- must not be null.
-
close
- Specified by:
close
in interfaceAutoCloseable
- Specified by:
close
in interfaceCloseable
- Throws:
IOException
-
isOpen
public boolean isOpen()- Specified by:
isOpen
in interfaceRedisSentinelConnection
- Returns:
- true if connected to server
-