YARN-6970. Add PoolInitializationException as retriable exception in FederationFacade. (Giovanni Matteo Fumarola via Subru).

This commit is contained in:
Subru Krishnan 2017-08-08 16:48:29 -07:00
parent 1db4788b7d
commit ad2a350662
2 changed files with 26 additions and 0 deletions

View File

@ -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);

View File

@ -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);
}
}