Ejemplo n.º 1
0
        /// <exception cref="System.Exception"/>
        private ApplicationId SubmitAppAndGetAppId(AccessControlList viewACL, AccessControlList
                                                   modifyACL)
        {
            SubmitApplicationRequest submitRequest = recordFactory.NewRecordInstance <SubmitApplicationRequest
                                                                                      >();
            ApplicationSubmissionContext context = recordFactory.NewRecordInstance <ApplicationSubmissionContext
                                                                                    >();
            ApplicationId applicationId = rmClient.GetNewApplication(recordFactory.NewRecordInstance
                                                                     <GetNewApplicationRequest>()).GetApplicationId();

            context.SetApplicationId(applicationId);
            IDictionary <ApplicationAccessType, string> acls = new Dictionary <ApplicationAccessType
                                                                               , string>();

            acls[ApplicationAccessType.ViewApp]   = viewACL.GetAclString();
            acls[ApplicationAccessType.ModifyApp] = modifyACL.GetAclString();
            ContainerLaunchContext amContainer = recordFactory.NewRecordInstance <ContainerLaunchContext
                                                                                  >();
            Resource resource = BuilderUtils.NewResource(1024, 1);

            context.SetResource(resource);
            amContainer.SetApplicationACLs(acls);
            context.SetAMContainerSpec(amContainer);
            submitRequest.SetApplicationSubmissionContext(context);
            rmClient.SubmitApplication(submitRequest);
            resourceManager.WaitForState(applicationId, RMAppState.Accepted);
            return(applicationId);
        }
Ejemplo n.º 2
0
        private static ContainerLaunchContext MockContainerLaunchContext(RecordFactory recordFactory
                                                                         )
        {
            ContainerLaunchContext amContainer = recordFactory.NewRecordInstance <ContainerLaunchContext
                                                                                  >();

            amContainer.SetApplicationACLs(new Dictionary <ApplicationAccessType, string>());
            return(amContainer);
        }
Ejemplo n.º 3
0
        public static ContainerLaunchContext NewContainerLaunchContext(IDictionary <string
                                                                                    , LocalResource> localResources, IDictionary <string, string> environment, IList <
                                                                           string> commands, IDictionary <string, ByteBuffer> serviceData, ByteBuffer tokens
                                                                       , IDictionary <ApplicationAccessType, string> acls)
        {
            ContainerLaunchContext container = recordFactory.NewRecordInstance <ContainerLaunchContext
                                                                                >();

            container.SetLocalResources(localResources);
            container.SetEnvironment(environment);
            container.SetCommands(commands);
            container.SetServiceData(serviceData);
            container.SetTokens(tokens);
            container.SetApplicationACLs(acls);
            return(container);
        }
Ejemplo n.º 4
0
        /// <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);
        }