*
* @return Partitions
*/
protected Partitions loadPartitions() {
String clusterNodes = null;
RedisURI nodeUri = null;
Exception lastException = null;
for (RedisURI initialUri : initialUris) {
try {
RedisAsyncConnectionImpl<String, String> connection = connectAsyncImpl(initialUri.getResolvedAddress());
nodeUri = initialUri;
clusterNodes = connection.clusterNodes().get();
connection.close();
break;
} catch (Exception e) {
lastException = e;
}
}
if (clusterNodes == null) {
if (lastException == null) {
throw new RedisException("Cannot retrieve initial cluster partitions from initial URIs " + initialUris);
}
throw new RedisException("Cannot retrieve initial cluster partitions from initial URIs " + initialUris,
lastException);
}
Partitions partitions = ClusterPartitionParser.parse(clusterNodes);
for (RedisClusterNode partition : partitions) {
if (partition.getFlags().contains(RedisClusterNode.NodeFlag.MYSELF)) {
partition.setUri(nodeUri);
}
if (nodeUri != null && nodeUri.getPassword() != null) {
partition.getUri().setPassword(new String(nodeUri.getPassword()));
}
}
return partitions;
}