From 6144e0137bb51bd04b46ea5ce42c59c2d4f7657d Mon Sep 17 00:00:00 2001 From: Kihwal Lee Date: Mon, 19 Oct 2015 10:52:29 -0500 Subject: [PATCH] HADOOP-12464. Interrupted client may try to fail-over and retry. Contributed by Kihwal Lee. --- hadoop-common-project/hadoop-common/CHANGES.txt | 2 ++ .../apache/hadoop/io/retry/RetryInvocationHandler.java | 4 ++++ .../src/main/java/org/apache/hadoop/ipc/Client.java | 10 ++-------- 3 files changed, 8 insertions(+), 8 deletions(-) diff --git a/hadoop-common-project/hadoop-common/CHANGES.txt b/hadoop-common-project/hadoop-common/CHANGES.txt index 1db02d266d..8f403507b1 100644 --- a/hadoop-common-project/hadoop-common/CHANGES.txt +++ b/hadoop-common-project/hadoop-common/CHANGES.txt @@ -1365,6 +1365,8 @@ Release 2.7.2 - UNRELEASED HADOOP-12465. Incorrect javadoc in WritableUtils.java. (Jagadesh Kiran N via aajisaka) + HADOOP-12464. Interrupted client may try to fail-over and retry (kihwal) + Release 2.7.1 - 2015-07-06 INCOMPATIBLE CHANGES diff --git a/hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/io/retry/RetryInvocationHandler.java b/hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/io/retry/RetryInvocationHandler.java index 92563567ba..6864d5dc73 100644 --- a/hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/io/retry/RetryInvocationHandler.java +++ b/hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/io/retry/RetryInvocationHandler.java @@ -104,6 +104,10 @@ public Object invoke(Object proxy, Method method, Object[] args) hasMadeASuccessfulCall = true; return ret; } catch (Exception ex) { + if (Thread.currentThread().isInterrupted()) { + // If interrupted, do not retry. + throw ex; + } boolean isIdempotentOrAtMostOnce = proxyProvider.getInterface() .getMethod(method.getName(), method.getParameterTypes()) .isAnnotationPresent(Idempotent.class); diff --git a/hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/ipc/Client.java b/hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/ipc/Client.java index 7b80740fa1..f067d599be 100644 --- a/hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/ipc/Client.java +++ b/hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/ipc/Client.java @@ -1428,22 +1428,16 @@ public Writable call(RPC.RpcKind rpcKind, Writable rpcRequest, throw new IOException(e); } - boolean interrupted = false; synchronized (call) { while (!call.done) { try { call.wait(); // wait for the result } catch (InterruptedException ie) { - // save the fact that we were interrupted - interrupted = true; + Thread.currentThread().interrupt(); + throw new InterruptedIOException("Call interrupted"); } } - if (interrupted) { - // set the interrupt flag now that we are done waiting - Thread.currentThread().interrupt(); - } - if (call.error != null) { if (call.error instanceof RemoteException) { call.error.fillInStackTrace();