Skip to content

Commit

Permalink
Not all slots are covered error should be more informative
Browse files Browse the repository at this point in the history
  • Loading branch information
Nikita committed Sep 22, 2016
1 parent 5091f3d commit 7fd29a2
Showing 1 changed file with 14 additions and 3 deletions.
Expand Up @@ -76,7 +76,8 @@ public ClusterConnectionManager(ClusterServersConfig cfg, Config config) {
this.config = create(cfg);
init(this.config);

Exception lastException = null;
Throwable lastException = null;
List<String> failedMasters = new ArrayList<String>();
for (URI addr : cfg.getNodeAddresses()) {
RFuture<RedisConnection> connectionFuture = connect(cfg, addr);
try {
Expand All @@ -97,6 +98,7 @@ public ClusterConnectionManager(ClusterServersConfig cfg, Config config) {
List<RFuture<Collection<RFuture<Void>>>> futures = new ArrayList<RFuture<Collection<RFuture<Void>>>>();
for (ClusterPartition partition : partitions) {
if (partition.isMasterFail()) {
failedMasters.add(partition.getMasterAddr().toString());
continue;
}
RFuture<Collection<RFuture<Void>>> masterFuture = addMasterEntry(partition, cfg);
Expand All @@ -106,6 +108,7 @@ public ClusterConnectionManager(ClusterServersConfig cfg, Config config) {
for (RFuture<Collection<RFuture<Void>>> masterFuture : futures) {
masterFuture.awaitUninterruptibly();
if (!masterFuture.isSuccess()) {
lastException = masterFuture.cause();
continue;
}
for (RFuture<Void> future : masterFuture.getNow()) {
Expand All @@ -124,12 +127,20 @@ public ClusterConnectionManager(ClusterServersConfig cfg, Config config) {

if (lastPartitions.isEmpty()) {
stopThreads();
throw new RedisConnectionException("Can't connect to servers!", lastException);
if (failedMasters.isEmpty()) {
throw new RedisConnectionException("Can't connect to servers!", lastException);
} else {
throw new RedisConnectionException("Can't connect to servers! Failed masters according to cluster status: " + failedMasters, lastException);
}
}

if (lastPartitions.size() != MAX_SLOT) {
stopThreads();
throw new RedisConnectionException("Not all slots are covered! Only " + lastPartitions.size() + " slots are avaliable", lastException);
if (failedMasters.isEmpty()) {
throw new RedisConnectionException("Not all slots are covered! Only " + lastPartitions.size() + " slots are avaliable", lastException);
} else {
throw new RedisConnectionException("Not all slots are covered! Only " + lastPartitions.size() + " slots are avaliable. Failed masters according to cluster status: " + failedMasters, lastException);
}
}

scheduleClusterChangeCheck(cfg, null);
Expand Down

0 comments on commit 7fd29a2

Please sign in to comment.