/// <exception cref="System.Exception"/> public virtual RMApp SubmitApp(int masterMemory, string name, string user, IDictionary <ApplicationAccessType, string> acls, bool unmanaged, string queue, int maxAppAttempts , Credentials ts, string appType, bool waitForAccepted, bool keepContainers, bool isAppIdProvided, ApplicationId applicationId, long attemptFailuresValidityInterval , LogAggregationContext logAggregationContext, bool cancelTokensWhenComplete) { ApplicationId appId = isAppIdProvided ? applicationId : null; ApplicationClientProtocol client = GetClientRMService(); if (!isAppIdProvided) { GetNewApplicationResponse resp = client.GetNewApplication(Org.Apache.Hadoop.Yarn.Util.Records .NewRecord <GetNewApplicationRequest>()); appId = resp.GetApplicationId(); } SubmitApplicationRequest req = Org.Apache.Hadoop.Yarn.Util.Records.NewRecord <SubmitApplicationRequest >(); ApplicationSubmissionContext sub = Org.Apache.Hadoop.Yarn.Util.Records.NewRecord < ApplicationSubmissionContext>(); sub.SetKeepContainersAcrossApplicationAttempts(keepContainers); sub.SetApplicationId(appId); sub.SetApplicationName(name); sub.SetMaxAppAttempts(maxAppAttempts); if (unmanaged) { sub.SetUnmanagedAM(true); } if (queue != null) { sub.SetQueue(queue); } sub.SetApplicationType(appType); ContainerLaunchContext clc = Org.Apache.Hadoop.Yarn.Util.Records.NewRecord <ContainerLaunchContext >(); Resource capability = Org.Apache.Hadoop.Yarn.Util.Records.NewRecord <Resource>(); capability.SetMemory(masterMemory); sub.SetResource(capability); clc.SetApplicationACLs(acls); if (ts != null && UserGroupInformation.IsSecurityEnabled()) { DataOutputBuffer dob = new DataOutputBuffer(); ts.WriteTokenStorageToStream(dob); ByteBuffer securityTokens = ByteBuffer.Wrap(dob.GetData(), 0, dob.GetLength()); clc.SetTokens(securityTokens); } sub.SetAMContainerSpec(clc); sub.SetAttemptFailuresValidityInterval(attemptFailuresValidityInterval); if (logAggregationContext != null) { sub.SetLogAggregationContext(logAggregationContext); } sub.SetCancelTokensWhenComplete(cancelTokensWhenComplete); req.SetApplicationSubmissionContext(sub); UserGroupInformation fakeUser = UserGroupInformation.CreateUserForTesting(user, new string[] { "someGroup" }); PrivilegedAction <SubmitApplicationResponse> action = new _PrivilegedAction_415(). SetClientReq(client, req); fakeUser.DoAs(action); // make sure app is immediately available after submit if (waitForAccepted) { WaitForState(appId, RMAppState.Accepted); } RMApp rmApp = GetRMContext().GetRMApps()[appId]; // unmanaged AM won't go to RMAppAttemptState.SCHEDULED. if (waitForAccepted && !unmanaged) { WaitForState(rmApp.GetCurrentAppAttempt().GetAppAttemptId(), RMAppAttemptState.Scheduled ); } return(rmApp); }