ClusterServerNode server = nodes.node(i);
if (!server.isDisabled() || noRetries) {
ListCallResult<T> gotten = server.entryLister().tryList(_clientConfig.getCallConfig(), endOfTime,
_prefix, _lastSeen, _itemType, maxToList, _converter);
if (gotten.failed()) {
CallFailure fail = gotten.getFailure();
if (fail.isRetriable()) {
retries = _add(retries, new NodeFailure(server, fail));
} else {
result.withFailed(new NodeFailure(server, fail));
}
continue;
}
return result.setItems(server, gotten);
}
}
if (noRetries) { // if no retries, bail out quickly
return result.withFailed(retries);
}
final long secondRoundStart = System.currentTimeMillis();
// Do we need any delay in between?
_doDelay(startTime, secondRoundStart, endOfTime);
// Otherwise: go over retry list first, and if that's not enough, try disabled
if (retries == null) {
retries = new LinkedList<NodeFailure>();
} else {
Iterator<NodeFailure> it = retries.iterator();
while (it.hasNext()) {
NodeFailure retry = it.next();
ClusterServerNode server = (ClusterServerNode) retry.getServer();
ListCallResult<T> gotten = server.entryLister().tryList(_clientConfig.getCallConfig(), endOfTime,
_prefix, _lastSeen, _itemType, maxToList, _converter);
if (gotten.succeeded()) {
return result.withFailed(retries).setItems(server, gotten);
}
CallFailure fail = gotten.getFailure();
retry.addFailure(fail);
if (!fail.isRetriable()) {
result.withFailed(retry);
it.remove();
}
}
}
// if no success, add disabled nodes in the mix
for (int i = 0; i < nodeCount; ++i) {
ClusterServerNode server = nodes.node(i);
if (server.isDisabled()) {
if (System.currentTimeMillis() >= lastValidTime) {
return result.withFailed(retries);
}
ListCallResult<T> gotten = server.entryLister().tryList(_clientConfig.getCallConfig(), endOfTime,
_prefix, _lastSeen, _itemType, maxToList, _converter);
if (gotten.succeeded()) {
return result.withFailed(retries).setItems(server, gotten);
}
CallFailure fail = gotten.getFailure();
if (fail.isRetriable()) {
retries.add(new NodeFailure(server, fail));
} else {
result.withFailed(new NodeFailure(server, fail));
}
}
}
long prevStartTime = secondRoundStart;
for (int i = 1; (i <= StoreClientConfig.MAX_RETRIES_FOR_GET) && !retries.isEmpty(); ++i) {
final long currStartTime = System.currentTimeMillis();
_doDelay(prevStartTime, currStartTime, endOfTime);
Iterator<NodeFailure> it = retries.iterator();
while (it.hasNext()) {
if (System.currentTimeMillis() >= lastValidTime) {
return result.withFailed(retries);
}
NodeFailure retry = it.next();
ClusterServerNode server = (ClusterServerNode) retry.getServer();
ListCallResult<T> gotten = server.entryLister().tryList(_clientConfig.getCallConfig(), endOfTime,
_prefix, _lastSeen, _itemType, maxToList, _converter);
if (gotten.succeeded()) {
return result.withFailed(retries).setItems(server, gotten);
}
CallFailure fail = gotten.getFailure();
retry.addFailure(fail);
if (!fail.isRetriable()) {
result.withFailed(retry);
it.remove();
}
}
}