Feature - checkSentinelsList setting added

pull/2563/head
Nikita Koksharov 5 years ago
parent 9aef684f63
commit 7bf7e52906

@ -47,6 +47,8 @@ public class SentinelServersConfig extends BaseMasterSlaveServersConfig<Sentinel
*/ */
private int scanInterval = 1000; private int scanInterval = 1000;
private boolean checkSentinelsList = true;
public SentinelServersConfig() { public SentinelServersConfig() {
} }
@ -57,6 +59,7 @@ public class SentinelServersConfig extends BaseMasterSlaveServersConfig<Sentinel
setDatabase(config.getDatabase()); setDatabase(config.getDatabase());
setScanInterval(config.getScanInterval()); setScanInterval(config.getScanInterval());
setNatMapper(config.getNatMapper()); setNatMapper(config.getNatMapper());
setCheckSentinelsList(config.isCheckSentinelsList());
} }
/** /**
@ -150,4 +153,20 @@ public class SentinelServersConfig extends BaseMasterSlaveServersConfig<Sentinel
return this; return this;
} }
public boolean isCheckSentinelsList() {
return checkSentinelsList;
}
/**
* Enables sentinels list check during Redisson startup.
* <p>
* Default is <code>true</code>
*
* @param checkSentinelsList - boolean value
* @return config
*/
public SentinelServersConfig setCheckSentinelsList(boolean checkSentinelsList) {
this.checkSentinelsList = checkSentinelsList;
return this;
}
} }

@ -166,9 +166,14 @@ public class SentinelConnectionManager extends MasterSlaveConnectionManager {
} }
} }
if (sentinels.isEmpty()) { if (cfg.isCheckSentinelsList()) {
stopThreads(); if (sentinels.isEmpty()) {
throw new RedisConnectionException("At least two sentinels should be defined in Redis configuration! SENTINEL SENTINELS command returns empty result!"); stopThreads();
throw new RedisConnectionException("SENTINEL SENTINELS command returns empty result! Set checkSentinelsList = false to avoid this check.");
} else if (sentinels.size() < 2) {
stopThreads();
throw new RedisConnectionException("SENTINEL SENTINELS command returns less than 2 nodes! At least two sentinels should be defined in Redis configuration. Set checkSentinelsList = false to avoid this check.");
}
} }
if (currentMaster.get() == null) { if (currentMaster.get() == null) {

Loading…
Cancel
Save