Exemple #1
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);
        }
        public virtual void TestStartContainerFailureWithUnknownAuxService()
        {
            conf.SetStrings(YarnConfiguration.NmAuxServices, new string[] { "existService" });
            conf.SetClass(string.Format(YarnConfiguration.NmAuxServiceFmt, "existService"), typeof(
                              TestAuxServices.ServiceA), typeof(Org.Apache.Hadoop.Service.Service));
            containerManager.Start();
            IList <StartContainerRequest> startRequest           = new AList <StartContainerRequest>();
            ContainerLaunchContext        containerLaunchContext = recordFactory.NewRecordInstance <ContainerLaunchContext
                                                                                                    >();
            IDictionary <string, ByteBuffer> serviceData = new Dictionary <string, ByteBuffer>(
                );
            string serviceName = "non_exist_auxService";

            serviceData[serviceName] = ByteBuffer.Wrap(Sharpen.Runtime.GetBytesForString(serviceName
                                                                                         ));
            containerLaunchContext.SetServiceData(serviceData);
            ContainerId cId            = CreateContainerId(0);
            string      user           = "******";
            Token       containerToken = CreateContainerToken(cId, DummyRmIdentifier, context.GetNodeId
                                                                  (), user, context.GetContainerTokenSecretManager());
            StartContainerRequest request = StartContainerRequest.NewInstance(containerLaunchContext
                                                                              , containerToken);

            // start containers
            startRequest.AddItem(request);
            StartContainersRequest requestList = StartContainersRequest.NewInstance(startRequest
                                                                                    );
            StartContainersResponse response = containerManager.StartContainers(requestList);

            NUnit.Framework.Assert.IsTrue(response.GetFailedRequests().Count == 1);
            NUnit.Framework.Assert.IsTrue(response.GetSuccessfullyStartedContainers().Count ==
                                          0);
            NUnit.Framework.Assert.IsTrue(response.GetFailedRequests().Contains(cId));
            NUnit.Framework.Assert.IsTrue(response.GetFailedRequests()[cId].GetMessage().Contains
                                              ("The auxService:" + serviceName + " does not exist"));
        }