YARN-8910. Fixed misleading log statement when container max retries is infinite.
Contributed by Chandni Singh
This commit is contained in:
parent
88cce32551
commit
47ad98b2e1
|
@ -1653,10 +1653,17 @@ public class ContainerImpl implements Container {
|
|||
|
||||
private void doRelaunch(final ContainerImpl container,
|
||||
int remainingRetryAttempts, final int retryInterval) {
|
||||
LOG.info("Relaunching Container " + container.getContainerId()
|
||||
+ ". Remaining retry attempts(after relaunch) : "
|
||||
+ remainingRetryAttempts + ". Interval between retries is "
|
||||
+ retryInterval + "ms");
|
||||
if (remainingRetryAttempts == ContainerRetryContext.RETRY_FOREVER) {
|
||||
LOG.info("Relaunching Container {}. " +
|
||||
"retry interval {} ms", container.getContainerId(),
|
||||
retryInterval);
|
||||
} else {
|
||||
LOG.info("Relaunching Container {}. " +
|
||||
"remaining retry attempts(after relaunch) {}, " +
|
||||
"retry interval {} ms", container.getContainerId(),
|
||||
remainingRetryAttempts, retryInterval);
|
||||
}
|
||||
|
||||
container.wasLaunched = false;
|
||||
container.metrics.endRunningContainer();
|
||||
if (retryInterval == 0) {
|
||||
|
|
|
@ -153,6 +153,10 @@ public class SlidingWindowRetryPolicy {
|
|||
}
|
||||
|
||||
int getRemainingRetries() {
|
||||
if (containerRetryContext.getMaxRetries() ==
|
||||
ContainerRetryContext.RETRY_FOREVER) {
|
||||
return ContainerRetryContext.RETRY_FOREVER;
|
||||
}
|
||||
return remainingRetries;
|
||||
}
|
||||
|
||||
|
|
|
@ -43,8 +43,12 @@ public class TestSlidingWindowRetryPolicy {
|
|||
public void testNeverRetry() {
|
||||
ContainerRetryContext retryContext =
|
||||
ContainerRetryContext.NEVER_RETRY_CONTEXT;
|
||||
Assert.assertFalse("never retry", retryPolicy.shouldRetry(
|
||||
new SlidingWindowRetryPolicy.RetryContext(retryContext), 12));
|
||||
SlidingWindowRetryPolicy.RetryContext windowContext = new
|
||||
SlidingWindowRetryPolicy.RetryContext(retryContext);
|
||||
Assert.assertFalse("never retry", retryPolicy.shouldRetry(windowContext,
|
||||
12));
|
||||
Assert.assertEquals("remaining retries", 0,
|
||||
windowContext.getRemainingRetries());
|
||||
}
|
||||
|
||||
@Test
|
||||
|
@ -52,8 +56,13 @@ public class TestSlidingWindowRetryPolicy {
|
|||
ContainerRetryContext retryContext = ContainerRetryContext.newInstance(
|
||||
ContainerRetryPolicy.RETRY_ON_ALL_ERRORS, null, -1,
|
||||
0, 10);
|
||||
Assert.assertTrue("always retry", retryPolicy.shouldRetry(
|
||||
new SlidingWindowRetryPolicy.RetryContext(retryContext), 12));
|
||||
SlidingWindowRetryPolicy.RetryContext windowContext = new
|
||||
SlidingWindowRetryPolicy.RetryContext(retryContext);
|
||||
Assert.assertTrue("always retry", retryPolicy.shouldRetry(windowContext,
|
||||
12));
|
||||
Assert.assertEquals("remaining retries",
|
||||
ContainerRetryContext.RETRY_FOREVER,
|
||||
windowContext.getRemainingRetries());
|
||||
}
|
||||
|
||||
@Test
|
||||
|
@ -65,19 +74,28 @@ public class TestSlidingWindowRetryPolicy {
|
|||
Assert.assertTrue("retry 1",
|
||||
retryPolicy.shouldRetry(windowRetryContext, 12));
|
||||
retryPolicy.updateRetryContext(windowRetryContext);
|
||||
Assert.assertEquals("remaining retries", 1,
|
||||
windowRetryContext.getRemainingRetries());
|
||||
|
||||
clock.setTime(20);
|
||||
Assert.assertTrue("retry 2",
|
||||
retryPolicy.shouldRetry(windowRetryContext, 12));
|
||||
retryPolicy.updateRetryContext(windowRetryContext);
|
||||
Assert.assertEquals("remaining retries", 1,
|
||||
windowRetryContext.getRemainingRetries());
|
||||
|
||||
clock.setTime(40);
|
||||
Assert.assertTrue("retry 3",
|
||||
retryPolicy.shouldRetry(windowRetryContext, 12));
|
||||
retryPolicy.updateRetryContext(windowRetryContext);
|
||||
Assert.assertEquals("remaining retries", 1,
|
||||
windowRetryContext.getRemainingRetries());
|
||||
|
||||
clock.setTime(45);
|
||||
Assert.assertFalse("retry failed",
|
||||
retryPolicy.shouldRetry(windowRetryContext, 12));
|
||||
retryPolicy.updateRetryContext(windowRetryContext);
|
||||
Assert.assertEquals("remaining retries", 0,
|
||||
windowRetryContext.getRemainingRetries());
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue