Package io.lettuce.core.sentinel
Class RedisSentinelAsyncCommandsImpl<K,V>
- java.lang.Object
-
- io.lettuce.core.sentinel.RedisSentinelAsyncCommandsImpl<K,V>
-
- Type Parameters:
K
- Key type.V
- Value type.
- All Implemented Interfaces:
RedisSentinelAsyncCommands<K,V>
public class RedisSentinelAsyncCommandsImpl<K,V> extends Object implements RedisSentinelAsyncCommands<K,V>
An asynchronous and thread-safe API for a Redis Sentinel connection.- Since:
- 3.0
- Author:
- Mark Paluch
-
-
Constructor Summary
Constructors Constructor Description RedisSentinelAsyncCommandsImpl(StatefulConnection<K,V> connection, RedisCodec<K,V> codec)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description RedisFuture<K>
clientGetname()
Get the current connection name.RedisFuture<String>
clientInfo()
Get the list of the current client connection.RedisFuture<Long>
clientKill(KillArgs killArgs)
Kill connections of clients which are filtered bykillArgs
.RedisFuture<String>
clientKill(String addr)
Kill the connection of a client identified by ip:port.RedisFuture<String>
clientList()
Get the list of client connections.RedisFuture<String>
clientList(ClientListArgs clientListArgs)
Get the list of client connections which are filtered byclientListArgs
.RedisFuture<String>
clientPause(long timeout)
Stop processing commands from clients for some time.RedisFuture<String>
clientSetinfo(String key, String value)
Assign various info attributes to the current connection.RedisFuture<String>
clientSetname(K name)
Set the current connection name.void
close()
<T> RedisFuture<T>
dispatch(ProtocolKeyword type, CommandOutput<K,V,T> output)
Dispatch a command to the Redis Server.<T> RedisFuture<T>
dispatch(ProtocolKeyword type, CommandOutput<K,V,T> output, CommandArgs<K,V> args)
Dispatch a command to the Redis Server.<T> AsyncCommand<K,V,T>
dispatch(RedisCommand<K,V,T> cmd)
RedisFuture<String>
failover(K key)
Perform a failover.RedisFuture<SocketAddress>
getMasterAddrByName(K key)
Return the ip and port number of the master with that name.StatefulRedisSentinelConnection<K,V>
getStatefulConnection()
RedisFuture<String>
info()
Get information and statistics about the server.RedisFuture<String>
info(String section)
Get information and statistics about the server.boolean
isOpen()
RedisFuture<Map<K,V>>
master(K key)
Show the state and info of the specified master.RedisFuture<List<Map<K,V>>>
masters()
Enumerates all the monitored masters and their states.RedisFuture<String>
monitor(K key, String ip, int port, int quorum)
This command tells the Sentinel to start monitoring a new master with the specified name, ip, port, and quorum.RedisFuture<String>
ping()
Ping the server.RedisFuture<String>
remove(K key)
remove the specified master.RedisFuture<List<Map<K,V>>>
replicas(K key)
Provides a list of replicas for the master with the specified name.RedisFuture<Long>
reset(K key)
This command will reset all the masters with matching name.RedisFuture<String>
set(K key, String option, V value)
Multiple option / value pairs can be specified (or none at all).RedisFuture<List<Map<K,V>>>
slaves(K key)
Provides a list of replicas for the master with the specified name.
-
-
-
Constructor Detail
-
RedisSentinelAsyncCommandsImpl
public RedisSentinelAsyncCommandsImpl(StatefulConnection<K,V> connection, RedisCodec<K,V> codec)
-
-
Method Detail
-
getMasterAddrByName
public RedisFuture<SocketAddress> getMasterAddrByName(K key)
Description copied from interface:RedisSentinelAsyncCommands
Return the ip and port number of the master with that name.- Specified by:
getMasterAddrByName
in interfaceRedisSentinelAsyncCommands<K,V>
- Parameters:
key
- the key.- Returns:
- SocketAddress.
-
masters
public RedisFuture<List<Map<K,V>>> masters()
Description copied from interface:RedisSentinelAsyncCommands
Enumerates all the monitored masters and their states.- Specified by:
masters
in interfaceRedisSentinelAsyncCommands<K,V>
- Returns:
- Map<K, V>>.
-
master
public RedisFuture<Map<K,V>> master(K key)
Description copied from interface:RedisSentinelAsyncCommands
Show the state and info of the specified master.- Specified by:
master
in interfaceRedisSentinelAsyncCommands<K,V>
- Parameters:
key
- the key.- Returns:
- Map<K, V>.
-
slaves
public RedisFuture<List<Map<K,V>>> slaves(K key)
Description copied from interface:RedisSentinelAsyncCommands
Provides a list of replicas for the master with the specified name.- Specified by:
slaves
in interfaceRedisSentinelAsyncCommands<K,V>
- Parameters:
key
- the key.- Returns:
- List<Map<K, V>>.
-
replicas
public RedisFuture<List<Map<K,V>>> replicas(K key)
Description copied from interface:RedisSentinelAsyncCommands
Provides a list of replicas for the master with the specified name.- Specified by:
replicas
in interfaceRedisSentinelAsyncCommands<K,V>
- Parameters:
key
- the key.- Returns:
- List<Map<K, V>>.
-
reset
public RedisFuture<Long> reset(K key)
Description copied from interface:RedisSentinelAsyncCommands
This command will reset all the masters with matching name.- Specified by:
reset
in interfaceRedisSentinelAsyncCommands<K,V>
- Parameters:
key
- the key.- Returns:
- Long.
-
failover
public RedisFuture<String> failover(K key)
Description copied from interface:RedisSentinelAsyncCommands
Perform a failover.- Specified by:
failover
in interfaceRedisSentinelAsyncCommands<K,V>
- Parameters:
key
- the master id.- Returns:
- String.
-
monitor
public RedisFuture<String> monitor(K key, String ip, int port, int quorum)
Description copied from interface:RedisSentinelAsyncCommands
This command tells the Sentinel to start monitoring a new master with the specified name, ip, port, and quorum.- Specified by:
monitor
in interfaceRedisSentinelAsyncCommands<K,V>
- Parameters:
key
- the key.ip
- the IP address.port
- the port.quorum
- the quorum count.- Returns:
- String.
-
set
public RedisFuture<String> set(K key, String option, V value)
Description copied from interface:RedisSentinelAsyncCommands
Multiple option / value pairs can be specified (or none at all).- Specified by:
set
in interfaceRedisSentinelAsyncCommands<K,V>
- Parameters:
key
- the key.option
- the option.value
- the value.- Returns:
- String simple-string-reply
OK
ifSET
was executed correctly.
-
remove
public RedisFuture<String> remove(K key)
Description copied from interface:RedisSentinelAsyncCommands
remove the specified master.- Specified by:
remove
in interfaceRedisSentinelAsyncCommands<K,V>
- Parameters:
key
- the key.- Returns:
- String.
-
ping
public RedisFuture<String> ping()
Description copied from interface:RedisSentinelAsyncCommands
Ping the server.- Specified by:
ping
in interfaceRedisSentinelAsyncCommands<K,V>
- Returns:
- String simple-string-reply.
-
clientGetname
public RedisFuture<K> clientGetname()
Description copied from interface:RedisSentinelAsyncCommands
Get the current connection name.- Specified by:
clientGetname
in interfaceRedisSentinelAsyncCommands<K,V>
- Returns:
- K bulk-string-reply The connection name, or a null bulk reply if no name is set.
-
clientSetname
public RedisFuture<String> clientSetname(K name)
Description copied from interface:RedisSentinelAsyncCommands
Set the current connection name.- Specified by:
clientSetname
in interfaceRedisSentinelAsyncCommands<K,V>
- Parameters:
name
- the client name.- Returns:
- simple-string-reply
OK
if the connection name was successfully set.
-
clientSetinfo
public RedisFuture<String> clientSetinfo(String key, String value)
Description copied from interface:RedisSentinelAsyncCommands
Assign various info attributes to the current connection.- Specified by:
clientSetinfo
in interfaceRedisSentinelAsyncCommands<K,V>
- Parameters:
key
- the key.value
- the value.- Returns:
- simple-string-reply
OK
if the connection name was successfully set.
-
clientKill
public RedisFuture<String> clientKill(String addr)
Description copied from interface:RedisSentinelAsyncCommands
Kill the connection of a client identified by ip:port.- Specified by:
clientKill
in interfaceRedisSentinelAsyncCommands<K,V>
- Parameters:
addr
- ip:port.- Returns:
- String simple-string-reply
OK
if the connection exists and has been closed.
-
clientKill
public RedisFuture<Long> clientKill(KillArgs killArgs)
Description copied from interface:RedisSentinelAsyncCommands
Kill connections of clients which are filtered bykillArgs
.- Specified by:
clientKill
in interfaceRedisSentinelAsyncCommands<K,V>
- Parameters:
killArgs
- args for the kill operation.- Returns:
- Long integer-reply number of killed connections.
-
clientPause
public RedisFuture<String> clientPause(long timeout)
Description copied from interface:RedisSentinelAsyncCommands
Stop processing commands from clients for some time.- Specified by:
clientPause
in interfaceRedisSentinelAsyncCommands<K,V>
- Parameters:
timeout
- the timeout value in milliseconds.- Returns:
- String simple-string-reply The command returns OK or an error if the timeout is invalid.
-
clientList
public RedisFuture<String> clientList()
Description copied from interface:RedisSentinelAsyncCommands
Get the list of client connections.- Specified by:
clientList
in interfaceRedisSentinelAsyncCommands<K,V>
- Returns:
- String bulk-string-reply a unique string, formatted as follows: One client connection per line (separated by LF), each line is composed of a succession of property=value fields separated by a space character.
-
clientList
public RedisFuture<String> clientList(ClientListArgs clientListArgs)
Description copied from interface:RedisSentinelAsyncCommands
Get the list of client connections which are filtered byclientListArgs
.- Specified by:
clientList
in interfaceRedisSentinelAsyncCommands<K,V>
- Returns:
- String bulk-string-reply a unique string, formatted as follows: One client connection per line (separated by LF), each line is composed of a succession of property=value fields separated by a space character.
-
clientInfo
public RedisFuture<String> clientInfo()
Description copied from interface:RedisSentinelAsyncCommands
Get the list of the current client connection.- Specified by:
clientInfo
in interfaceRedisSentinelAsyncCommands<K,V>
- Returns:
- String bulk-string-reply a unique string, formatted as a succession of property=value fields separated by a space character.
-
info
public RedisFuture<String> info()
Description copied from interface:RedisSentinelAsyncCommands
Get information and statistics about the server.- Specified by:
info
in interfaceRedisSentinelAsyncCommands<K,V>
- Returns:
- String bulk-string-reply as a collection of text lines.
-
info
public RedisFuture<String> info(String section)
Description copied from interface:RedisSentinelAsyncCommands
Get information and statistics about the server.- Specified by:
info
in interfaceRedisSentinelAsyncCommands<K,V>
- Parameters:
section
- the section type: string.- Returns:
- String bulk-string-reply as a collection of text lines.
-
dispatch
public <T> RedisFuture<T> dispatch(ProtocolKeyword type, CommandOutput<K,V,T> output)
Description copied from interface:RedisSentinelAsyncCommands
Dispatch a command to the Redis Server. Please note the command output type must fit to the command response.- Specified by:
dispatch
in interfaceRedisSentinelAsyncCommands<K,V>
- Type Parameters:
T
- response type.- Parameters:
type
- the command, must not benull
.output
- the command output, must not benull
.- Returns:
- the command response.
-
dispatch
public <T> RedisFuture<T> dispatch(ProtocolKeyword type, CommandOutput<K,V,T> output, CommandArgs<K,V> args)
Description copied from interface:RedisSentinelAsyncCommands
Dispatch a command to the Redis Server. Please note the command output type must fit to the command response.- Specified by:
dispatch
in interfaceRedisSentinelAsyncCommands<K,V>
- Type Parameters:
T
- response type.- Parameters:
type
- the command, must not benull
.output
- the command output, must not benull
.args
- the command arguments, must not benull
.- Returns:
- the command response.
-
dispatch
public <T> AsyncCommand<K,V,T> dispatch(RedisCommand<K,V,T> cmd)
-
close
public void close()
-
isOpen
public boolean isOpen()
- Specified by:
isOpen
in interfaceRedisSentinelAsyncCommands<K,V>
- Returns:
true
if the connection is open (connected and not closed).
-
getStatefulConnection
public StatefulRedisSentinelConnection<K,V> getStatefulConnection()
- Specified by:
getStatefulConnection
in interfaceRedisSentinelAsyncCommands<K,V>
- Returns:
- the underlying connection.
-
-