Source:
public <R> R execute(PartitionContext partitionContext, RetryPolicy retry, ServiceCallback<S, R> callback) { final long start = _ticker.read(); int numAttempts = 0; Exception lastException = null; do { Iterable<ServiceEndPoint> allEndPoints = getAllEndPoints(); if (Iterables.isEmpty(allEndPoints)) { throw (lastException == null) ? new NoAvailableHostsException(String.format("No endpoints discovered for service %s", getServiceName())) : new NoAvailableHostsException(lastException); } Iterable<ServiceEndPoint> validEndPoints = getValidEndPoints(allEndPoints); if (Iterables.isEmpty(validEndPoints)) { throw (lastException == null) ? new OnlyBadHostsException(String.format("No valid endpoints discovered for service %s, all endpoints: %s", getServiceName(), allEndPoints)) : new OnlyBadHostsException(lastException); } ServiceEndPoint endPoint = chooseEndPoint(validEndPoints, partitionContext); if (endPoint == null) { throw (lastException == null) ? new NoSuitableHostsException(String.format("No suitable endpoint discovered for service %s from valid endpoints %s", getServiceName(), validEndPoints)) : new NoSuitableHostsException(lastException); } try { R result = executeOnEndPoint(endPoint, callback); _numExecuteSuccesses.mark(); return result; } catch (Exception e) { _numExecuteAttemptFailures.mark(); if (!isRetriableException(e)) { throw Throwables.propagate(e); } LOG.info("Retriable exception from end point: {}, {}", endPoint, e.toString()); LOG.debug("Exception", e); lastException = e; } } while (retry.allowRetry(++numAttempts, TimeUnit.NANOSECONDS.toMillis(_ticker.read() - start))); throw new MaxRetriesException(lastException); }

Target:
public <R> R execute(PartitionContext partitionContext, RetryPolicy retry, ServiceCallback<S, R> callback) { final long start = _ticker.read(); int numAttempts = 0; Exception lastException = null; do { Iterable<ServiceEndPoint> allEndPoints = getAllEndPoints(); if (Iterables.isEmpty(allEndPoints)) { throw (lastException == null) ? new NoAvailableHostsException(String.format("No endpoints discovered for service %s", getServiceName())) : new NoAvailableHostsException(lastException.getMessage(), lastException); } Iterable<ServiceEndPoint> validEndPoints = getValidEndPoints(allEndPoints); if (Iterables.isEmpty(validEndPoints)) { throw (lastException == null) ? new OnlyBadHostsException(String.format("No valid endpoints discovered for service %s, all endpoints: %s", getServiceName(), allEndPoints)) : new OnlyBadHostsException(lastException.getMessage(), lastException); } ServiceEndPoint endPoint = chooseEndPoint(validEndPoints, partitionContext); if (endPoint == null) { throw (lastException == null) ? new NoSuitableHostsException(String.format("No suitable endpoint discovered for service %s from valid endpoints %s", getServiceName(), validEndPoints)) : new NoSuitableHostsException(lastException); } try { R result = executeOnEndPoint(endPoint, callback); _numExecuteSuccesses.mark(); return result; } catch (Exception e) { _numExecuteAttemptFailures.mark(); if (!isRetriableException(e)) { throw Throwables.propagate(e); } LOG.info("Retriable exception from end point: {}, {}", endPoint, e.toString()); LOG.debug("Exception", e); lastException = e; } } while (retry.allowRetry(++numAttempts, TimeUnit.NANOSECONDS.toMillis(_ticker.read() - start))); throw new MaxRetriesException(lastException); }