Skip to content

Commit 2d2631a

Browse files
virajjasanitasanuma
authored andcommitted
HADOOP-18191. Log retry count while handling exceptions in RetryInvocationHandler (#4133)
(cherry picked from commit b69ede7)
1 parent 9cdf5ca commit 2d2631a

File tree

1 file changed

+6
-4
lines changed

1 file changed

+6
-4
lines changed

hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/io/retry/RetryInvocationHandler.java

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -387,12 +387,12 @@ private RetryInfo handleException(final Method method, final int callId,
387387
throw retryInfo.getFailException();
388388
}
389389

390-
log(method, retryInfo.isFailover(), counters.failovers, retryInfo.delay, e);
390+
log(method, retryInfo.isFailover(), counters.failovers, counters.retries, retryInfo.delay, e);
391391
return retryInfo;
392392
}
393393

394-
private void log(final Method method, final boolean isFailover,
395-
final int failovers, final long delay, final Exception ex) {
394+
private void log(final Method method, final boolean isFailover, final int failovers,
395+
final int retries, final long delay, final Exception ex) {
396396
boolean info = true;
397397
// If this is the first failover to this proxy, skip logging at INFO level
398398
if (!failedAtLeastOnce.contains(proxyDescriptor.getProxyInfo().toString()))
@@ -408,13 +408,15 @@ private void log(final Method method, final boolean isFailover,
408408
}
409409

410410
final StringBuilder b = new StringBuilder()
411-
.append(ex + ", while invoking ")
411+
.append(ex)
412+
.append(", while invoking ")
412413
.append(proxyDescriptor.getProxyInfo().getString(method.getName()));
413414
if (failovers > 0) {
414415
b.append(" after ").append(failovers).append(" failover attempts");
415416
}
416417
b.append(isFailover? ". Trying to failover ": ". Retrying ");
417418
b.append(delay > 0? "after sleeping for " + delay + "ms.": "immediately.");
419+
b.append(" Current retry count: ").append(retries).append(".");
418420

419421
if (info) {
420422
LOG.info(b.toString());

0 commit comments

Comments
 (0)