|
@@ -26,6 +26,7 @@ import org.apache.commons.logging.LogFactory;
|
|
|
import org.apache.hadoop.conf.Configuration;
|
|
|
import org.apache.hadoop.security.UserGroupInformation;
|
|
|
import org.apache.hadoop.yarn.api.protocolrecords.AllocateResponse;
|
|
|
+import org.apache.hadoop.yarn.api.protocolrecords.FinishApplicationMasterRequest;
|
|
|
import org.apache.hadoop.yarn.api.protocolrecords.RegisterApplicationMasterRequest;
|
|
|
import org.apache.hadoop.yarn.api.protocolrecords.RegisterApplicationMasterResponse;
|
|
|
import org.apache.hadoop.yarn.api.protocolrecords.impl.pb.AllocateRequestPBImpl;
|
|
@@ -34,6 +35,7 @@ import org.apache.hadoop.yarn.conf.YarnConfiguration;
|
|
|
import org.apache.hadoop.yarn.event.Dispatcher;
|
|
|
import org.apache.hadoop.yarn.event.EventHandler;
|
|
|
import org.apache.hadoop.yarn.event.InlineDispatcher;
|
|
|
+import org.apache.hadoop.yarn.exceptions.InvalidApplicationMasterRequestException;
|
|
|
import org.apache.hadoop.yarn.exceptions.InvalidContainerReleaseException;
|
|
|
import org.apache.hadoop.yarn.exceptions.YarnException;
|
|
|
import org.apache.hadoop.yarn.security.AMRMTokenIdentifier;
|
|
@@ -246,4 +248,39 @@ public class TestApplicationMasterService {
|
|
|
sleep(100);
|
|
|
}
|
|
|
}
|
|
|
+
|
|
|
+ @Test(timeout=1200000)
|
|
|
+ public void testFinishApplicationMasterBeforeRegistering() throws Exception {
|
|
|
+ MockRM rm = new MockRM(conf);
|
|
|
+ try {
|
|
|
+ rm.start();
|
|
|
+ // Register node1
|
|
|
+ MockNM nm1 = rm.registerNode("127.0.0.1:1234", 6 * GB);
|
|
|
+ // Submit an application
|
|
|
+ RMApp app1 = rm.submitApp(2048);
|
|
|
+ MockAM am1 = MockRM.launchAM(app1, rm, nm1);
|
|
|
+ FinishApplicationMasterRequest req =
|
|
|
+ FinishApplicationMasterRequest.newInstance(
|
|
|
+ FinalApplicationStatus.FAILED, "", "");
|
|
|
+ Throwable cause = null;
|
|
|
+ try {
|
|
|
+ am1.unregisterAppAttempt(req, false);
|
|
|
+ } catch (Exception e) {
|
|
|
+ cause = e.getCause();
|
|
|
+ }
|
|
|
+ Assert.assertNotNull(cause);
|
|
|
+ Assert
|
|
|
+ .assertTrue(cause instanceof InvalidApplicationMasterRequestException);
|
|
|
+ Assert.assertNotNull(cause.getMessage());
|
|
|
+ Assert
|
|
|
+ .assertTrue(cause
|
|
|
+ .getMessage()
|
|
|
+ .contains(
|
|
|
+ "Application Master is trying to unregister before registering for:"));
|
|
|
+ } finally {
|
|
|
+ if (rm != null) {
|
|
|
+ rm.stop();
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
}
|