yifan-c commented on code in PR #61:
URL: https://github.com/apache/cassandra-sidecar/pull/61#discussion_r1262835413
##########
client/src/main/java/org/apache/cassandra/sidecar/client/RequestExecutor.java:
##########
@@ -305,26 +267,21 @@ private void
applyRetryPolicy(CompletableFuture<HttpResponse> future,
context.retryPolicy()
.onResponse(future, request, response, throwable, attempt,
retryOnNewHost, (nextAttempt, delay) -> {
String statusCode = response != null ?
String.valueOf(response.statusCode()) : "<Not Available>";
+ SidecarInstance nextInstance = sidecarInstance;
if (iterator.hasNext())
{
- if (response == null || response.statusCode() !=
HttpResponseStatus.ACCEPTED.code())
- {
- logger.warn("Retrying request on next instance after {}ms.
Failed on instance={}, " +
- "attempt={}, statusCode={}, request={}",
delay, sidecarInstance, attempt, statusCode,
- request, throwable);
- }
- schedule(delay, () -> executeWithRetries(future, iterator,
context, nextAttempt, throwable));
+ nextInstance = iterator.next();
}
- else
+
+ if (response == null || response.statusCode() !=
HttpResponseStatus.ACCEPTED.code())
{
- if (response == null || response.statusCode() !=
HttpResponseStatus.ACCEPTED.code())
- {
- logger.warn("Retrying request on same instance after {}ms.
Failed on instance={}, " +
- "attempt={}, statusCode={}, request={}",
delay, sidecarInstance, attempt, statusCode,
- request, throwable);
- }
- schedule(delay, () -> executeWithRetries(future, iterator,
sidecarInstance, context, nextAttempt));
+ logger.warn("Retrying request on {} instance after {}ms. " +
+ "Failed on instance={}, attempt={}, statusCode={}",
+ nextInstance == sidecarInstance ? "same" : "next",
delay,
+ nextInstance, attempt, statusCode, throwable);
}
+ SidecarInstance instance = nextInstance;
+ schedule(delay, () -> executeWithRetries(future, iterator,
instance, context, nextAttempt));
Review Comment:
reviewer note: Same effect as the original implementation, but simplified.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]