// No valid end points means no healthy end points.
return aggregate;
}
while (!endPoints.isEmpty()) {
ServiceEndPoint endPoint;
try {
// Prefer end points in the order the load balancer recommends.
endPoint = chooseEndPoint(endPoints, PartitionContextBuilder.empty());
} catch (Exception e) {
// Load balancer didn't like our end points, so just go sequentially.
endPoint = endPoints.iterator().next();
}
HealthCheckResult result = checkHealth(endPoint);
aggregate.addHealthCheckResult(result);
if (!result.isHealthy()) {
Exception exception = ((FailedHealthCheckResult) result).getException();
if (exception == null || isRetriableException(exception)) {
LOG.debug("Unhealthy end point discovered. End point ID: {}", endPoint.getId());
endPoints.remove(endPoint);
markEndPointAsBad(endPoint);
continue;
}
}