HADOOP-18191. Log retry count while handling exceptions in RetryInvocationHandler (#4133)
(cherry picked from commit b69ede7154
)
This commit is contained in:
parent
9da7d80c4e
commit
e5516cdfaf
|
@ -387,12 +387,12 @@ public class RetryInvocationHandler<T> implements RpcInvocationHandler {
|
||||||
throw retryInfo.getFailException();
|
throw retryInfo.getFailException();
|
||||||
}
|
}
|
||||||
|
|
||||||
log(method, retryInfo.isFailover(), counters.failovers, retryInfo.delay, e);
|
log(method, retryInfo.isFailover(), counters.failovers, counters.retries, retryInfo.delay, e);
|
||||||
return retryInfo;
|
return retryInfo;
|
||||||
}
|
}
|
||||||
|
|
||||||
private void log(final Method method, final boolean isFailover,
|
private void log(final Method method, final boolean isFailover, final int failovers,
|
||||||
final int failovers, final long delay, final Exception ex) {
|
final int retries, final long delay, final Exception ex) {
|
||||||
boolean info = true;
|
boolean info = true;
|
||||||
// If this is the first failover to this proxy, skip logging at INFO level
|
// If this is the first failover to this proxy, skip logging at INFO level
|
||||||
if (!failedAtLeastOnce.contains(proxyDescriptor.getProxyInfo().toString()))
|
if (!failedAtLeastOnce.contains(proxyDescriptor.getProxyInfo().toString()))
|
||||||
|
@ -408,13 +408,15 @@ public class RetryInvocationHandler<T> implements RpcInvocationHandler {
|
||||||
}
|
}
|
||||||
|
|
||||||
final StringBuilder b = new StringBuilder()
|
final StringBuilder b = new StringBuilder()
|
||||||
.append(ex + ", while invoking ")
|
.append(ex)
|
||||||
|
.append(", while invoking ")
|
||||||
.append(proxyDescriptor.getProxyInfo().getString(method.getName()));
|
.append(proxyDescriptor.getProxyInfo().getString(method.getName()));
|
||||||
if (failovers > 0) {
|
if (failovers > 0) {
|
||||||
b.append(" after ").append(failovers).append(" failover attempts");
|
b.append(" after ").append(failovers).append(" failover attempts");
|
||||||
}
|
}
|
||||||
b.append(isFailover? ". Trying to failover ": ". Retrying ");
|
b.append(isFailover? ". Trying to failover ": ". Retrying ");
|
||||||
b.append(delay > 0? "after sleeping for " + delay + "ms.": "immediately.");
|
b.append(delay > 0? "after sleeping for " + delay + "ms.": "immediately.");
|
||||||
|
b.append(" Current retry count: ").append(retries).append(".");
|
||||||
|
|
||||||
if (info) {
|
if (info) {
|
||||||
LOG.info(b.toString());
|
LOG.info(b.toString());
|
||||||
|
|
Loading…
Reference in New Issue