Feature - sentinelsDiscovery setting added. #3681

pull/3848/head
Nikita Koksharov 3 years ago
parent 4e2f9399a1
commit 2cd4244922

@ -53,6 +53,8 @@ public class SentinelServersConfig extends BaseMasterSlaveServersConfig<Sentinel
private boolean checkSlaveStatusWithSyncing = true;
private boolean sentinelsDiscovery = true;
public SentinelServersConfig() {
}
@ -66,6 +68,7 @@ public class SentinelServersConfig extends BaseMasterSlaveServersConfig<Sentinel
setCheckSentinelsList(config.isCheckSentinelsList());
setSentinelPassword(config.getSentinelPassword());
setCheckSlaveStatusWithSyncing(config.isCheckSlaveStatusWithSyncing());
setSentinelsDiscovery(config.isSentinelsDiscovery());
}
/**
@ -209,4 +212,21 @@ public class SentinelServersConfig extends BaseMasterSlaveServersConfig<Sentinel
this.checkSlaveStatusWithSyncing = checkSlaveStatusWithSyncing;
return this;
}
public boolean isSentinelsDiscovery() {
return sentinelsDiscovery;
}
/**
* Enables sentinels discovery.
* <p>
* Default is <code>true</code>
*
* @param sentinelsDiscovery - boolean value
* @return config
*/
public SentinelServersConfig setSentinelsDiscovery(boolean sentinelsDiscovery) {
this.sentinelsDiscovery = sentinelsDiscovery;
return this;
}
}

@ -70,6 +70,7 @@ public class SentinelConnectionManager extends MasterSlaveConnectionManager {
private boolean usePassword = false;
private String scheme;
private boolean checkSlaveStatusWithSyncing;
private boolean sentinelsDiscovery;
public SentinelConnectionManager(SentinelServersConfig cfg, Config config, UUID id) {
super(config, id);
@ -84,6 +85,7 @@ public class SentinelConnectionManager extends MasterSlaveConnectionManager {
this.config = create(cfg);
this.sentinelPassword = cfg.getSentinelPassword();
this.checkSlaveStatusWithSyncing = cfg.isCheckSlaveStatusWithSyncing();
this.sentinelsDiscovery = cfg.isSentinelsDiscovery();
initTimer(this.config);
this.natMapper = cfg.getNatMapper();
@ -186,7 +188,7 @@ public class SentinelConnectionManager extends MasterSlaveConnectionManager {
}
}
if (cfg.isCheckSentinelsList()) {
if (cfg.isCheckSentinelsList() && cfg.isSentinelsDiscovery()) {
if (sentinels.isEmpty()) {
stopThreads();
throw new RedisConnectionException("SENTINEL SENTINELS command returns empty result! Set checkSentinelsList = false to avoid this check.", lastException);
@ -387,6 +389,10 @@ public class SentinelConnectionManager extends MasterSlaveConnectionManager {
}
private RFuture<List<Map<String, String>>> checkSentinelsChange(SentinelServersConfig cfg, RedisConnection connection) {
if (!sentinelsDiscovery) {
return RedissonPromise.newSucceededFuture(null);
}
RFuture<List<Map<String, String>>> sentinelsFuture = connection.async(StringCodec.INSTANCE, RedisCommands.SENTINEL_SENTINELS, cfg.getMasterName());
sentinelsFuture.onComplete((list, e) -> {
if (e != null || list.isEmpty()) {

Loading…
Cancel
Save