|
@@ -19,6 +19,7 @@
|
|
|
package org.apache.hadoop.mapreduce.v2.app;
|
|
|
|
|
|
import static org.mockito.Mockito.doNothing;
|
|
|
+import static org.mockito.Mockito.doThrow;
|
|
|
import static org.mockito.Mockito.mock;
|
|
|
import static org.mockito.Mockito.spy;
|
|
|
import static org.mockito.Mockito.when;
|
|
@@ -30,6 +31,7 @@ import java.io.PrintStream;
|
|
|
import java.net.Proxy;
|
|
|
import java.net.URI;
|
|
|
import java.net.URISyntaxException;
|
|
|
+import java.nio.channels.ClosedChannelException;
|
|
|
|
|
|
import javax.servlet.ServletException;
|
|
|
import javax.servlet.http.HttpServlet;
|
|
@@ -53,6 +55,7 @@ import org.apache.hadoop.mapreduce.v2.app.rm.ContainerAllocatorEvent;
|
|
|
import org.apache.hadoop.mapreduce.v2.app.rm.RMCommunicator;
|
|
|
import org.apache.hadoop.mapreduce.v2.app.rm.RMHeartbeatHandler;
|
|
|
import org.apache.hadoop.yarn.exceptions.YarnException;
|
|
|
+import org.apache.hadoop.yarn.exceptions.YarnRuntimeException;
|
|
|
import org.junit.Assert;
|
|
|
import org.junit.Test;
|
|
|
|
|
@@ -197,8 +200,8 @@ public class TestJobEndNotifier extends JobEndNotifier {
|
|
|
|
|
|
}
|
|
|
|
|
|
- @Test
|
|
|
- public void testNotificationOnLastRetryNormalShutdown() throws Exception {
|
|
|
+ private void testNotificationOnLastRetry(boolean withRuntimeException)
|
|
|
+ throws Exception {
|
|
|
HttpServer2 server = startHttpServer();
|
|
|
// Act like it is the second attempt. Default max attempts is 2
|
|
|
MRApp app = spy(new MRAppWithCustomContainerAllocator(
|
|
@@ -210,16 +213,32 @@ public class TestJobEndNotifier extends JobEndNotifier {
|
|
|
JobImpl job = (JobImpl)app.submit(conf);
|
|
|
app.waitForInternalState(job, JobStateInternal.SUCCEEDED);
|
|
|
// Unregistration succeeds: successfullyUnregistered is set
|
|
|
+ if (withRuntimeException) {
|
|
|
+ YarnRuntimeException runtimeException = new YarnRuntimeException(
|
|
|
+ new ClosedChannelException());
|
|
|
+ doThrow(runtimeException).when(app).stop();
|
|
|
+ }
|
|
|
app.shutDownJob();
|
|
|
Assert.assertTrue(app.isLastAMRetry());
|
|
|
Assert.assertEquals(1, JobEndServlet.calledTimes);
|
|
|
Assert.assertEquals("jobid=" + job.getID() + "&status=SUCCEEDED",
|
|
|
JobEndServlet.requestUri.getQuery());
|
|
|
Assert.assertEquals(JobState.SUCCEEDED.toString(),
|
|
|
- JobEndServlet.foundJobState);
|
|
|
+ JobEndServlet.foundJobState);
|
|
|
server.stop();
|
|
|
}
|
|
|
|
|
|
+ @Test
|
|
|
+ public void testNotificationOnLastRetryNormalShutdown() throws Exception {
|
|
|
+ testNotificationOnLastRetry(false);
|
|
|
+ }
|
|
|
+
|
|
|
+ @Test
|
|
|
+ public void testNotificationOnLastRetryShutdownWithRuntimeException()
|
|
|
+ throws Exception {
|
|
|
+ testNotificationOnLastRetry(true);
|
|
|
+ }
|
|
|
+
|
|
|
@Test
|
|
|
public void testAbsentNotificationOnNotLastRetryUnregistrationFailure()
|
|
|
throws Exception {
|