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 389c769427..682eb1457d 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.LoggerFactory; import com.google.common.annotations.VisibleForTesting; +import com.zaxxer.hikari.pool.HikariPool.PoolInitializationException; /** * @@ -162,6 +163,7 @@ public static RetryPolicy createRetryPolicy(Configuration conf) { 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 304910eb36..ea43268c80 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.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 void testFacadeCacheRetriableException() throws Exception { 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); + } }