From ad2a3506626728a6be47af0db3ca60610a568734 Mon Sep 17 00:00:00 2001 From: Subru Krishnan Date: Tue, 8 Aug 2017 16:48:29 -0700 Subject: [PATCH] YARN-6970. Add PoolInitializationException as retriable exception in FederationFacade. (Giovanni Matteo Fumarola via Subru). --- .../utils/FederationStateStoreFacade.java | 2 ++ .../TestFederationStateStoreFacadeRetry.java | 24 +++++++++++++++++++ 2 files changed, 26 insertions(+) diff --git a/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-common/src/main/java/org/apache/hadoop/yarn/server/federation/utils/FederationStateStoreFacade.java b/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-common/src/main/java/org/apache/hadoop/yarn/server/federation/utils/FederationStateStoreFacade.java index 389c7694275..682eb1457d9 100644 --- a/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-common/src/main/java/org/apache/hadoop/yarn/server/federation/utils/FederationStateStoreFacade.java +++ b/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-common/src/main/java/org/apache/hadoop/yarn/server/federation/utils/FederationStateStoreFacade.java @@ -70,6 +70,7 @@ import org.slf4j.Logger; import org.slf4j.LoggerFactory; import com.google.common.annotations.VisibleForTesting; +import com.zaxxer.hikari.pool.HikariPool.PoolInitializationException; /** * @@ -162,6 +163,7 @@ public final class FederationStateStoreFacade { exceptionToPolicyMap.put(FederationStateStoreRetriableException.class, basePolicy); exceptionToPolicyMap.put(CacheLoaderException.class, basePolicy); + exceptionToPolicyMap.put(PoolInitializationException.class, basePolicy); RetryPolicy retryPolicy = RetryPolicies.retryByException( RetryPolicies.TRY_ONCE_THEN_FAIL, exceptionToPolicyMap); diff --git a/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-common/src/test/java/org/apache/hadoop/yarn/server/federation/utils/TestFederationStateStoreFacadeRetry.java b/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-common/src/test/java/org/apache/hadoop/yarn/server/federation/utils/TestFederationStateStoreFacadeRetry.java index 304910eb364..ea43268c804 100644 --- a/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-common/src/test/java/org/apache/hadoop/yarn/server/federation/utils/TestFederationStateStoreFacadeRetry.java +++ b/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-common/src/test/java/org/apache/hadoop/yarn/server/federation/utils/TestFederationStateStoreFacadeRetry.java @@ -30,6 +30,8 @@ import org.apache.hadoop.yarn.server.federation.store.exception.FederationStateS import org.junit.Assert; import org.junit.Test; +import com.zaxxer.hikari.pool.HikariPool.PoolInitializationException; + /** * Test class to validate FederationStateStoreFacade retry policy. */ @@ -119,4 +121,26 @@ public class TestFederationStateStoreFacadeRetry { policy.shouldRetry(new CacheLoaderException(""), maxRetries, 0, false); Assert.assertEquals(RetryAction.FAIL.action, action.action); } + + /* + * Test to validate that PoolInitializationException is a retriable exception. + */ + @Test + public void testFacadePoolInitRetriableException() throws Exception { + // PoolInitializationException is a retriable exception + conf = new Configuration(); + conf.setInt(YarnConfiguration.CLIENT_FAILOVER_RETRIES, maxRetries); + RetryPolicy policy = FederationStateStoreFacade.createRetryPolicy(conf); + RetryAction action = policy.shouldRetry( + new PoolInitializationException(new YarnException()), 0, 0, false); + // We compare only the action, delay and the reason are random value + // during this test + Assert.assertEquals(RetryAction.RETRY.action, action.action); + + // After maxRetries we stop to retry + action = + policy.shouldRetry(new PoolInitializationException(new YarnException()), + maxRetries, 0, false); + Assert.assertEquals(RetryAction.FAIL.action, action.action); + } }