Skip to content

Commit 8d24aba

Browse files
hanishakonerutasanuma
authored andcommitted
HADOOP-17116. Skip Retry INFO logging on first failover from a proxy
(cherry picked from commit e62d8f8)
1 parent 0fdcfe2 commit 8d24aba

File tree

1 file changed

+15
-6
lines changed

1 file changed

+15
-6
lines changed

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

Lines changed: 15 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,7 @@
3535
import java.lang.reflect.Proxy;
3636
import java.util.Arrays;
3737
import java.util.Collections;
38+
import java.util.HashSet;
3839
import java.util.Map;
3940

4041
/**
@@ -312,6 +313,8 @@ public String toString() {
312313

313314
private volatile boolean hasSuccessfulCall = false;
314315

316+
private HashSet<String> failedAtLeastOnce = new HashSet<>();
317+
315318
private final RetryPolicy defaultPolicy;
316319
private final Map<String,RetryPolicy> methodNameToPolicyMap;
317320

@@ -390,12 +393,18 @@ private RetryInfo handleException(final Method method, final int callId,
390393

391394
private void log(final Method method, final boolean isFailover,
392395
final int failovers, final long delay, final Exception ex) {
393-
// log info if this has made some successful calls or
394-
// this is not the first failover
395-
final boolean info = hasSuccessfulCall || failovers != 0
396-
|| asyncCallHandler.hasSuccessfulCall();
397-
if (!info && !LOG.isDebugEnabled()) {
398-
return;
396+
boolean info = true;
397+
// If this is the first failover to this proxy, skip logging at INFO level
398+
if (!failedAtLeastOnce.contains(proxyDescriptor.getProxyInfo().toString()))
399+
{
400+
failedAtLeastOnce.add(proxyDescriptor.getProxyInfo().toString());
401+
402+
// If successful calls were made to this proxy, log info even for first
403+
// failover
404+
info = hasSuccessfulCall || asyncCallHandler.hasSuccessfulCall();
405+
if (!info && !LOG.isDebugEnabled()) {
406+
return;
407+
}
399408
}
400409

401410
final StringBuilder b = new StringBuilder()

0 commit comments

Comments
 (0)