Return-Path: X-Original-To: archive-asf-public-internal@cust-asf2.ponee.io Delivered-To: archive-asf-public-internal@cust-asf2.ponee.io Received: from cust-asf.ponee.io (cust-asf.ponee.io [163.172.22.183]) by cust-asf2.ponee.io (Postfix) with ESMTP id F2837200B25 for ; Wed, 8 Jun 2016 19:58:24 +0200 (CEST) Received: by cust-asf.ponee.io (Postfix) id F1598160A2E; Wed, 8 Jun 2016 17:58:24 +0000 (UTC) Delivered-To: archive-asf-public@cust-asf.ponee.io Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by cust-asf.ponee.io (Postfix) with SMTP id EFC9D160A0E for ; Wed, 8 Jun 2016 19:58:23 +0200 (CEST) Received: (qmail 88024 invoked by uid 500); 8 Jun 2016 17:58:23 -0000 Mailing-List: contact common-commits-help@hadoop.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Delivered-To: mailing list common-commits@hadoop.apache.org Received: (qmail 88012 invoked by uid 99); 8 Jun 2016 17:58:23 -0000 Received: from git1-us-west.apache.org (HELO git1-us-west.apache.org) (140.211.11.23) by apache.org (qpsmtpd/0.29) with ESMTP; Wed, 08 Jun 2016 17:58:23 +0000 Received: by git1-us-west.apache.org (ASF Mail Server at git1-us-west.apache.org, from userid 33) id F3DCDDFC4F; Wed, 8 Jun 2016 17:58:22 +0000 (UTC) Content-Type: text/plain; charset="us-ascii" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit From: jlowe@apache.org To: common-commits@hadoop.apache.org Message-Id: <080d61c378b3411782caa9da006fe3b8@git.apache.org> X-Mailer: ASF-Git Admin Mailer Subject: hadoop git commit: YARN-4288. Fixed RMProxy to retry on IOException from local host. Contributed by Junping Du (cherry picked from commit c41699965e78ce5e87669d17923ab84e494c4188) Date: Wed, 8 Jun 2016 17:58:22 +0000 (UTC) archived-at: Wed, 08 Jun 2016 17:58:25 -0000 Repository: hadoop Updated Branches: refs/heads/branch-2.7 fdea6ee0d -> ab0679ed3 YARN-4288. Fixed RMProxy to retry on IOException from local host. Contributed by Junping Du (cherry picked from commit c41699965e78ce5e87669d17923ab84e494c4188) Conflicts: hadoop-yarn-project/CHANGES.txt Project: http://git-wip-us.apache.org/repos/asf/hadoop/repo Commit: http://git-wip-us.apache.org/repos/asf/hadoop/commit/ab0679ed Tree: http://git-wip-us.apache.org/repos/asf/hadoop/tree/ab0679ed Diff: http://git-wip-us.apache.org/repos/asf/hadoop/diff/ab0679ed Branch: refs/heads/branch-2.7 Commit: ab0679ed3f6aa06c5572e0018a09cb403c96471d Parents: fdea6ee Author: Jason Lowe Authored: Wed Jun 8 17:57:59 2016 +0000 Committer: Jason Lowe Committed: Wed Jun 8 17:57:59 2016 +0000 ---------------------------------------------------------------------- .../apache/hadoop/io/retry/RetryPolicies.java | 44 +++++++++++++++++++- .../apache/hadoop/io/retry/TestRetryProxy.java | 27 +++++++++++- .../io/retry/UnreliableImplementation.java | 17 ++++++++ .../hadoop/io/retry/UnreliableInterface.java | 3 ++ hadoop-yarn-project/CHANGES.txt | 3 ++ .../org/apache/hadoop/yarn/client/RMProxy.java | 6 ++- 6 files changed, 94 insertions(+), 6 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/hadoop/blob/ab0679ed/hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/io/retry/RetryPolicies.java ---------------------------------------------------------------------- diff --git a/hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/io/retry/RetryPolicies.java b/hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/io/retry/RetryPolicies.java index 5668ad1..3c9cda8 100644 --- a/hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/io/retry/RetryPolicies.java +++ b/hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/io/retry/RetryPolicies.java @@ -134,7 +134,17 @@ public class RetryPolicies { Map, RetryPolicy> exceptionToPolicyMap) { return new RemoteExceptionDependentRetry(defaultPolicy, exceptionToPolicyMap); } - + + /** + * A retry policy for exceptions other than RemoteException. + */ + public static final RetryPolicy retryOtherThanRemoteException( + RetryPolicy defaultPolicy, + Map, RetryPolicy> exceptionToPolicyMap) { + return new OtherThanRemoteExceptionDependentRetry(defaultPolicy, + exceptionToPolicyMap); + } + public static final RetryPolicy failoverOnNetworkException(int maxFailovers) { return failoverOnNetworkException(TRY_ONCE_THEN_FAIL, maxFailovers); } @@ -483,7 +493,37 @@ public class RetryPolicies { return policy.shouldRetry(e, retries, failovers, isIdempotentOrAtMostOnce); } } - + + static class OtherThanRemoteExceptionDependentRetry implements RetryPolicy { + + private RetryPolicy defaultPolicy; + private Map, RetryPolicy> exceptionToPolicyMap; + + public OtherThanRemoteExceptionDependentRetry(RetryPolicy defaultPolicy, + Map, + RetryPolicy> exceptionToPolicyMap) { + this.defaultPolicy = defaultPolicy; + this.exceptionToPolicyMap = exceptionToPolicyMap; + } + + @Override + public RetryAction shouldRetry(Exception e, int retries, int failovers, + boolean isIdempotentOrAtMostOnce) throws Exception { + RetryPolicy policy = null; + // ignore Remote Exception + if (e instanceof RemoteException) { + // do nothing + } else { + policy = exceptionToPolicyMap.get(e.getClass()); + } + if (policy == null) { + policy = defaultPolicy; + } + return policy.shouldRetry( + e, retries, failovers, isIdempotentOrAtMostOnce); + } + } + static class ExponentialBackoffRetry extends RetryLimited { public ExponentialBackoffRetry( http://git-wip-us.apache.org/repos/asf/hadoop/blob/ab0679ed/hadoop-common-project/hadoop-common/src/test/java/org/apache/hadoop/io/retry/TestRetryProxy.java ---------------------------------------------------------------------- diff --git a/hadoop-common-project/hadoop-common/src/test/java/org/apache/hadoop/io/retry/TestRetryProxy.java b/hadoop-common-project/hadoop-common/src/test/java/org/apache/hadoop/io/retry/TestRetryProxy.java index 79ea1b9..4ea93a8 100644 --- a/hadoop-common-project/hadoop-common/src/test/java/org/apache/hadoop/io/retry/TestRetryProxy.java +++ b/hadoop-common-project/hadoop-common/src/test/java/org/apache/hadoop/io/retry/TestRetryProxy.java @@ -22,12 +22,14 @@ import static org.apache.hadoop.io.retry.RetryPolicies.RETRY_FOREVER; import static org.apache.hadoop.io.retry.RetryPolicies.TRY_ONCE_THEN_FAIL; import static org.apache.hadoop.io.retry.RetryPolicies.retryByException; import static org.apache.hadoop.io.retry.RetryPolicies.retryByRemoteException; +import static org.apache.hadoop.io.retry.RetryPolicies.retryOtherThanRemoteException; import static org.apache.hadoop.io.retry.RetryPolicies.retryUpToMaximumCountWithFixedSleep; import static org.apache.hadoop.io.retry.RetryPolicies.retryUpToMaximumCountWithProportionalSleep; import static org.apache.hadoop.io.retry.RetryPolicies.retryUpToMaximumTimeWithFixedSleep; import static org.apache.hadoop.io.retry.RetryPolicies.exponentialBackoffRetry; import static org.junit.Assert.*; +import java.io.IOException; import java.util.Collections; import java.util.Map; import java.util.concurrent.Callable; @@ -202,8 +204,29 @@ public class TestRetryProxy { } catch (RemoteException e) { // expected } - } - + } + + @Test + public void testRetryOtherThanRemoteException() throws Throwable { + Map, RetryPolicy> exceptionToPolicyMap = + Collections., RetryPolicy>singletonMap( + IOException.class, RETRY_FOREVER); + + UnreliableInterface unreliable = (UnreliableInterface) + RetryProxy.create(UnreliableInterface.class, unreliableImpl, + retryOtherThanRemoteException(TRY_ONCE_THEN_FAIL, + exceptionToPolicyMap)); + // should retry with local IOException. + unreliable.failsOnceWithIOException(); + try { + // won't get retry on remote exception + unreliable.failsOnceWithRemoteException(); + fail("Should fail"); + } catch (RemoteException e) { + // expected + } + } + @Test public void testRetryInterruptible() throws Throwable { final UnreliableInterface unreliable = (UnreliableInterface) http://git-wip-us.apache.org/repos/asf/hadoop/blob/ab0679ed/hadoop-common-project/hadoop-common/src/test/java/org/apache/hadoop/io/retry/UnreliableImplementation.java ---------------------------------------------------------------------- diff --git a/hadoop-common-project/hadoop-common/src/test/java/org/apache/hadoop/io/retry/UnreliableImplementation.java b/hadoop-common-project/hadoop-common/src/test/java/org/apache/hadoop/io/retry/UnreliableImplementation.java index ce9c16e..9387772 100644 --- a/hadoop-common-project/hadoop-common/src/test/java/org/apache/hadoop/io/retry/UnreliableImplementation.java +++ b/hadoop-common-project/hadoop-common/src/test/java/org/apache/hadoop/io/retry/UnreliableImplementation.java @@ -26,6 +26,8 @@ class UnreliableImplementation implements UnreliableInterface { private int failsOnceInvocationCount, failsOnceWithValueInvocationCount, + failsOnceIOExceptionInvocationCount, + failsOnceRemoteExceptionInvocationCount, failsTenTimesInvocationCount, succeedsOnceThenFailsCount, succeedsOnceThenFailsIdempotentCount, @@ -90,6 +92,21 @@ class UnreliableImplementation implements UnreliableInterface { } @Override + public void failsOnceWithIOException() throws IOException { + if (failsOnceIOExceptionInvocationCount++ == 0) { + throw new IOException("test exception for failsOnceWithIOException"); + } + } + + @Override + public void failsOnceWithRemoteException() throws RemoteException { + if (failsOnceRemoteExceptionInvocationCount++ == 0) { + throw new RemoteException(IOException.class.getName(), + "test exception for failsOnceWithRemoteException"); + } + } + + @Override public void failsTenTimesThenSucceeds() throws UnreliableException { if (failsTenTimesInvocationCount++ < 10) { throw new UnreliableException(); http://git-wip-us.apache.org/repos/asf/hadoop/blob/ab0679ed/hadoop-common-project/hadoop-common/src/test/java/org/apache/hadoop/io/retry/UnreliableInterface.java ---------------------------------------------------------------------- diff --git a/hadoop-common-project/hadoop-common/src/test/java/org/apache/hadoop/io/retry/UnreliableInterface.java b/hadoop-common-project/hadoop-common/src/test/java/org/apache/hadoop/io/retry/UnreliableInterface.java index 3fbe11a..6c9c153 100644 --- a/hadoop-common-project/hadoop-common/src/test/java/org/apache/hadoop/io/retry/UnreliableInterface.java +++ b/hadoop-common-project/hadoop-common/src/test/java/org/apache/hadoop/io/retry/UnreliableInterface.java @@ -54,6 +54,9 @@ public interface UnreliableInterface { void alwaysFailsWithFatalException() throws FatalException; void alwaysFailsWithRemoteFatalException() throws RemoteException; + void failsOnceWithIOException() throws IOException; + void failsOnceWithRemoteException() throws RemoteException; + void failsOnceThenSucceeds() throws UnreliableException; boolean failsOnceThenSucceedsWithReturnValue() throws UnreliableException; http://git-wip-us.apache.org/repos/asf/hadoop/blob/ab0679ed/hadoop-yarn-project/CHANGES.txt ---------------------------------------------------------------------- diff --git a/hadoop-yarn-project/CHANGES.txt b/hadoop-yarn-project/CHANGES.txt index 374848f..f4ee662 100644 --- a/hadoop-yarn-project/CHANGES.txt +++ b/hadoop-yarn-project/CHANGES.txt @@ -148,6 +148,9 @@ Release 2.7.3 - UNRELEASED YARN-5206. RegistrySecurity includes id:pass in exception text if considered invalid (Steve Loughran via jlowe) + YARN-4288. Fixed RMProxy to retry on IOException from local host. + (Junping Du via jianhe) + Release 2.7.2 - 2016-01-25 INCOMPATIBLE CHANGES http://git-wip-us.apache.org/repos/asf/hadoop/blob/ab0679ed/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-common/src/main/java/org/apache/hadoop/yarn/client/RMProxy.java ---------------------------------------------------------------------- diff --git a/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-common/src/main/java/org/apache/hadoop/yarn/client/RMProxy.java b/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-common/src/main/java/org/apache/hadoop/yarn/client/RMProxy.java index 28628f3..f381b33 100644 --- a/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-common/src/main/java/org/apache/hadoop/yarn/client/RMProxy.java +++ b/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-common/src/main/java/org/apache/hadoop/yarn/client/RMProxy.java @@ -249,8 +249,10 @@ public class RMProxy { exceptionToPolicyMap.put(ConnectTimeoutException.class, retryPolicy); exceptionToPolicyMap.put(RetriableException.class, retryPolicy); exceptionToPolicyMap.put(SocketException.class, retryPolicy); - - return RetryPolicies.retryByException( + // YARN-4288: local IOException is also possible. + exceptionToPolicyMap.put(IOException.class, retryPolicy); + // Not retry on remote IO exception. + return RetryPolicies.retryOtherThanRemoteException( RetryPolicies.TRY_ONCE_THEN_FAIL, exceptionToPolicyMap); } } --------------------------------------------------------------------- To unsubscribe, e-mail: common-commits-unsubscribe@hadoop.apache.org For additional commands, e-mail: common-commits-help@hadoop.apache.org