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
ConstructorsModifierConstructorDescriptionLettuceSentinelConnection(io.lettuce.core.RedisClient redisClient) Creates aLettuceSentinelConnectionusing a suppliedRedisClient.protectedLettuceSentinelConnection(io.lettuce.core.sentinel.api.StatefulRedisSentinelConnection<String, String> connection) Creates aLettuceSentinelConnectionusing a supplied redis connection.LettuceSentinelConnection(String host, int port) LettuceSentinelConnection(String host, int port, io.lettuce.core.resource.ClientResources clientResources) Creates aLettuceSentinelConnectionwith a client for the suppliedhostandportand reuse existingClientResources.LettuceSentinelConnection(LettuceConnectionProvider connectionProvider) Creates aLettuceSentinelConnectionusing aLettuceConnectionProvider.LettuceSentinelConnection(RedisNode sentinel) Creates aLettuceSentinelConnectionwith a dedicated client for a suppliedRedisNode. -
Method Summary
Modifier and TypeMethodDescriptionvoidclose()voidForce a failover as if the master was not reachable.booleanisOpen()masters()Get aCollectionof monitored masters and their state.voidmonitor(RedisServer server) Tell sentinel to start monitoring a new master with the specifiedRedisNode.getName(),RedisNode.getHost(),RedisNode.getPort(), andRedisServer.getQuorum().voidvoidRemoves given master.Show list of replicas for given master.
-
Constructor Details
-
LettuceSentinelConnection
Creates aLettuceSentinelConnectionwith 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 aLettuceSentinelConnectionwith a client for the suppliedhostandportand 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 aLettuceSentinelConnectionusing a suppliedRedisClient.- Parameters:
redisClient- must not be null.
-
LettuceSentinelConnection
protected LettuceSentinelConnection(io.lettuce.core.sentinel.api.StatefulRedisSentinelConnection<String, String> connection) Creates aLettuceSentinelConnectionusing a supplied redis connection.- Parameters:
connection- native Lettuce connection, must not be null
-
LettuceSentinelConnection
Creates aLettuceSentinelConnectionusing aLettuceConnectionProvider.- Parameters:
connectionProvider- must not be null.- Since:
- 2.0
-
-
Method Details
-
failover
Description copied from interface:RedisSentinelCommandsForce a failover as if the master was not reachable.- Specified by:
failoverin interfaceRedisSentinelCommands- Parameters:
master- must not be null.
-
masters
Description copied from interface:RedisSentinelCommandsGet aCollectionof monitored masters and their state.- Specified by:
mastersin interfaceRedisSentinelCommands- Returns:
- Collection of
RedisServers. Never null.
-
replicas
Description copied from interface:RedisSentinelCommandsShow list of replicas for given master.- Specified by:
replicasin interfaceRedisSentinelCommands- Parameters:
master- must not be null.- Returns:
- Collection of
RedisServers. Never null.
-
slaves
- Parameters:
masterName-- Returns:
- See Also:
-
remove
Description copied from interface:RedisSentinelCommandsRemoves given master. The server will no longer be monitored and will no longer be returned byRedisSentinelCommands.masters().- Specified by:
removein interfaceRedisSentinelCommands- Parameters:
master- must not be null.
-
remove
- Parameters:
masterName-- See Also:
-
monitor
Description copied from interface:RedisSentinelCommandsTell sentinel to start monitoring a new master with the specifiedRedisNode.getName(),RedisNode.getHost(),RedisNode.getPort(), andRedisServer.getQuorum().- Specified by:
monitorin interfaceRedisSentinelCommands- Parameters:
server- must not be null.
-
close
- Specified by:
closein interfaceAutoCloseable- Specified by:
closein interfaceCloseable- Throws:
IOException
-
isOpen
public boolean isOpen()- Specified by:
isOpenin interfaceRedisSentinelConnection- Returns:
- true if connected to server
-