Feature - checkSlotsCoverage setting added to cluster config. #2284

pull/2450/head
Nikita Koksharov 5 years ago
parent 35204d0ccf
commit 2621b4c768

@ -168,12 +168,12 @@ public class ClusterConnectionManager extends MasterSlaveConnectionManager {
} }
} }
if (lastPartitions.size() != MAX_SLOT) { if (cfg.isCheckSlotsCoverage() && lastPartitions.size() != MAX_SLOT) {
stopThreads(); stopThreads();
if (failedMasters.isEmpty()) { if (failedMasters.isEmpty()) {
throw new RedisConnectionException("Not all slots are covered! Only " + lastPartitions.size() + " slots are avaliable", lastException); throw new RedisConnectionException("Not all slots covered! Only " + lastPartitions.size() + " slots are available", lastException);
} else { } else {
throw new RedisConnectionException("Not all slots are covered! Only " + lastPartitions.size() + " slots are avaliable. Failed masters according to cluster status: " + failedMasters, lastException); throw new RedisConnectionException("Not all slots covered! Only " + lastPartitions.size() + " slots are available. Failed masters according to cluster status: " + failedMasters, lastException);
} }
} }

@ -41,6 +41,8 @@ public class ClusterServersConfig extends BaseMasterSlaveServersConfig<ClusterSe
*/ */
private int scanInterval = 5000; private int scanInterval = 5000;
private boolean checkSlotsCoverage;
public ClusterServersConfig() { public ClusterServersConfig() {
} }
@ -49,6 +51,7 @@ public class ClusterServersConfig extends BaseMasterSlaveServersConfig<ClusterSe
setNodeAddresses(config.getNodeAddresses()); setNodeAddresses(config.getNodeAddresses());
setScanInterval(config.getScanInterval()); setScanInterval(config.getScanInterval());
setNatMap(new HashMap<>(config.getNatMap())); setNatMap(new HashMap<>(config.getNatMap()));
setCheckSlotsCoverage(config.isCheckSlotsCoverage());
} }
/** /**
@ -84,6 +87,23 @@ public class ClusterServersConfig extends BaseMasterSlaveServersConfig<ClusterSe
return this; return this;
} }
public boolean isCheckSlotsCoverage() {
return checkSlotsCoverage;
}
/**
* Enables cluster slots check during Redisson startup.
* <p>
* Default is <code>false</code>
*
* @param checkSlotsCoverage - boolean value
* @return config
*/
public ClusterServersConfig setCheckSlotsCoverage(boolean checkSlotsCoverage) {
this.checkSlotsCoverage = checkSlotsCoverage;
return this;
}
public Map<String, String> getNatMap() { public Map<String, String> getNatMap() {
return natMap; return natMap;
} }

Loading…
Cancel
Save