Class RedisSentinelConnectOptions
- java.lang.Object
-
- io.vertx.redis.client.RedisConnectOptions
-
- io.vertx.redis.client.RedisSentinelConnectOptions
-
public class RedisSentinelConnectOptions extends RedisConnectOptions
-
-
Constructor Summary
Constructors Constructor Description RedisSentinelConnectOptions()
RedisSentinelConnectOptions(JsonObject json)
RedisSentinelConnectOptions(RedisOptions options)
RedisSentinelConnectOptions(RedisSentinelConnectOptions other)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description RedisSentinelConnectOptions
addConnectionString(String connectionString)
Adds a connection string (endpoint) to use while connecting to the redis server.String
getMasterName()
Get the name of the master set.RedisRole
getRole()
Get the client role; that is, to which kind of node should the connection be established.boolean
isAutoFailover()
Returns whether automatic failover is enabled.RedisSentinelConnectOptions
setAutoFailover(boolean autoFailover)
Returns whether automatic failover is enabled.RedisSentinelConnectOptions
setConnectionString(String connectionString)
Sets a single connection string (endpoint) to use while connecting to the redis server.RedisSentinelConnectOptions
setEndpoints(List<String> endpoints)
Set the endpoints to use while connecting to the redis server.RedisSentinelConnectOptions
setMasterName(String masterName)
Set the name of the master set.RedisSentinelConnectOptions
setMaxNestedArrays(int maxNestedArrays)
Tune how much nested arrays are allowed on a redis response.RedisSentinelConnectOptions
setMaxWaitingHandlers(int maxWaitingHandlers)
The client will always work on pipeline mode, this means that messages can start queueing.RedisSentinelConnectOptions
setPassword(String password)
Set the default password for Redis connections.RedisSentinelConnectOptions
setPreferredProtocolVersion(ProtocolVersion preferredProtocolVersion)
Sets the preferred protocol version to be used during protocol negotiation.RedisSentinelConnectOptions
setProtocolNegotiation(boolean protocolNegotiation)
Should the client performREST
protocol negotiation during the connection acquire.RedisSentinelConnectOptions
setRole(RedisRole role)
Set the client role; that is, to which kind of node should the connection be established.RedisSentinelConnectOptions
setUser(String user)
Set the default username for Redis connections.JsonObject
toJson()
Converts this object to JSON notation.-
Methods inherited from class io.vertx.redis.client.RedisConnectOptions
getEndpoint, getEndpoints, getMaxNestedArrays, getMaxWaitingHandlers, getPassword, getPreferredProtocolVersion, getUser, isProtocolNegotiation
-
-
-
-
Constructor Detail
-
RedisSentinelConnectOptions
public RedisSentinelConnectOptions()
-
RedisSentinelConnectOptions
public RedisSentinelConnectOptions(RedisOptions options)
-
RedisSentinelConnectOptions
public RedisSentinelConnectOptions(RedisSentinelConnectOptions other)
-
RedisSentinelConnectOptions
public RedisSentinelConnectOptions(JsonObject json)
-
-
Method Detail
-
getRole
public RedisRole getRole()
Get the client role; that is, to which kind of node should the connection be established.- Returns:
- the role
-
setRole
public RedisSentinelConnectOptions setRole(RedisRole role)
Set the client role; that is, to which kind of node should the connection be established.- Parameters:
role
- the role- Returns:
- fluent self
-
getMasterName
public String getMasterName()
Get the name of the master set.- Returns:
- the master set name
-
setMasterName
public RedisSentinelConnectOptions setMasterName(String masterName)
Set the name of the master set.- Parameters:
masterName
- the master set name- Returns:
- fluent self
-
isAutoFailover
public boolean isAutoFailover()
Returns whether automatic failover is enabled. This only makes sense for sentinel clients with role ofRedisRole.MASTER
and is ignored otherwise.If enabled, the sentinel client will additionally create a connection to one sentinel node and watch for failover events. When new master is elected, all connections to the old master are automatically closed and new connections to the new master are created. Note that these new connections will not have the same event handlers (
handler()
,exceptionHandler()
andendHandler()
), will not be in the same streaming mode (pause()
,resume()
andfetch()
), and will not watch the same subscriptions (SUBSCRIBE
,PSUBSCRIBE
, etc.) as the old ones. In other words, automatic failover makes sense for connections executing regular commands, but not for connections used to subscribe to Redis pub/sub channels.Note that there is a brief period of time between the old master failing and the new master being elected when the existing connections will temporarily fail all operations. After the new master is elected, the connections will automatically fail over and start working again.
- Returns:
- whether automatic failover is enabled
-
setAutoFailover
public RedisSentinelConnectOptions setAutoFailover(boolean autoFailover)
Returns whether automatic failover is enabled. This only makes sense for sentinel clients with role ofRedisRole.MASTER
and is ignored otherwise.If enabled, the sentinel client will additionally create a connection to one sentinel node and watch for failover events. When new master is elected, all connections to the old master are automatically closed and new connections to the new master are created. Note that these new connections will not have the same event handlers (
handler()
,exceptionHandler()
andendHandler()
), will not be in the same streaming mode (pause()
,resume()
andfetch()
), and will not watch the same subscriptions (SUBSCRIBE
,PSUBSCRIBE
, etc.) as the old ones. In other words, automatic failover makes sense for connections executing regular commands, but not for connections used to subscribe to Redis pub/sub channels.Note that there is a brief period of time between the old master failing and the new master being elected when the existing connections will temporarily fail all operations. After the new master is elected, the connections will automatically fail over and start working again.
- Parameters:
autoFailover
- whether automatic failover should be enabled- Returns:
- fluent self
-
setMaxNestedArrays
public RedisSentinelConnectOptions setMaxNestedArrays(int maxNestedArrays)
Description copied from class:RedisConnectOptions
Tune how much nested arrays are allowed on a redis response. This affects the parser performance.- Overrides:
setMaxNestedArrays
in classRedisConnectOptions
- Parameters:
maxNestedArrays
- the configured max nested arrays allowance.- Returns:
- fluent self.
-
setProtocolNegotiation
public RedisSentinelConnectOptions setProtocolNegotiation(boolean protocolNegotiation)
Description copied from class:RedisConnectOptions
Should the client performREST
protocol negotiation during the connection acquire. By default this istrue
, but there are situations when using broken servers it may be useful to skip this and always fallback toRESP2
without using theHELLO
command.- Overrides:
setProtocolNegotiation
in classRedisConnectOptions
- Parameters:
protocolNegotiation
- false to disableHELLO
(not recommended) unless reasons...- Returns:
- fluent self
-
setPreferredProtocolVersion
public RedisSentinelConnectOptions setPreferredProtocolVersion(ProtocolVersion preferredProtocolVersion)
Description copied from class:RedisConnectOptions
Sets the preferred protocol version to be used during protocol negotiation. When not set, defaults to RESP 3. When protocol negotiation is disabled, this setting has no effect.- Overrides:
setPreferredProtocolVersion
in classRedisConnectOptions
- Parameters:
preferredProtocolVersion
- preferred protocol version- Returns:
- fluent self
-
setUser
public RedisSentinelConnectOptions setUser(String user)
Description copied from class:RedisConnectOptions
Set the default username for Redis connections.- Overrides:
setUser
in classRedisConnectOptions
- Parameters:
user
- the default username- Returns:
- fluent self
-
setPassword
public RedisSentinelConnectOptions setPassword(String password)
Description copied from class:RedisConnectOptions
Set the default password for Redis connections.- Overrides:
setPassword
in classRedisConnectOptions
- Parameters:
password
- the default password- Returns:
- fluent self
-
setEndpoints
public RedisSentinelConnectOptions setEndpoints(List<String> endpoints)
Description copied from class:RedisConnectOptions
Set the endpoints to use while connecting to the redis server. Only the cluster mode will consider more than 1 element. If more are provided, they are not considered by the client when in single server mode.- Overrides:
setEndpoints
in classRedisConnectOptions
- Parameters:
endpoints
- list of socket addresses.- Returns:
- fluent self.
-
addConnectionString
public RedisSentinelConnectOptions addConnectionString(String connectionString)
Description copied from class:RedisConnectOptions
Adds a connection string (endpoint) to use while connecting to the redis server. Only the cluster mode will consider more than 1 element. If more are provided, they are not considered by the client when in single server mode.- Overrides:
addConnectionString
in classRedisConnectOptions
- Parameters:
connectionString
- a string URI following the scheme: redis://[username:password@][host][:port][/database]- Returns:
- fluent self.
- See Also:
- Redis scheme on iana.org
-
setConnectionString
public RedisSentinelConnectOptions setConnectionString(String connectionString)
Description copied from class:RedisConnectOptions
Sets a single connection string (endpoint) to use while connecting to the redis server. Will replace the previously configured connection strings.- Overrides:
setConnectionString
in classRedisConnectOptions
- Parameters:
connectionString
- a string following the scheme: redis://[username:password@][host][:port][/[database].- Returns:
- fluent self.
- See Also:
- Redis scheme on iana.org
-
setMaxWaitingHandlers
public RedisSentinelConnectOptions setMaxWaitingHandlers(int maxWaitingHandlers)
Description copied from class:RedisConnectOptions
The client will always work on pipeline mode, this means that messages can start queueing. You can control how much backlog you're willing to accept. This methods sets how much handlers is the client willing to queue.- Overrides:
setMaxWaitingHandlers
in classRedisConnectOptions
- Parameters:
maxWaitingHandlers
- max allowed queued waiting handlers.- Returns:
- fluent self.
-
toJson
public JsonObject toJson()
Converts this object to JSON notation.- Overrides:
toJson
in classRedisConnectOptions
- Returns:
- JSON
-
-