Example #1
0
        public virtual void TestAllocateResponseWithIncDecContainers()
        {
            IList <ContainerResourceIncrease> incContainers = new AList <ContainerResourceIncrease
                                                                         >();
            IList <ContainerResourceDecrease> decContainers = new AList <ContainerResourceDecrease
                                                                         >();

            for (int i = 0; i < 3; i++)
            {
                incContainers.AddItem(ContainerResourceIncrease.NewInstance(null, Resource.NewInstance
                                                                                (1024, i), null));
            }
            for (int i_1 = 0; i_1 < 5; i_1++)
            {
                decContainers.AddItem(ContainerResourceDecrease.NewInstance(null, Resource.NewInstance
                                                                                (1024, i_1)));
            }
            AllocateResponse r = AllocateResponse.NewInstance(3, new AList <ContainerStatus>()
                                                              , new AList <Container>(), new AList <NodeReport>(), null, AMCommand.AmResync, 3,
                                                              null, new AList <NMToken>(), incContainers, decContainers);

            // serde
            YarnServiceProtos.AllocateResponseProto p = ((AllocateResponsePBImpl)r).GetProto(
                );
            r = new AllocateResponsePBImpl(p);
            // check value
            NUnit.Framework.Assert.AreEqual(incContainers.Count, r.GetIncreasedContainers().Count
                                            );
            NUnit.Framework.Assert.AreEqual(decContainers.Count, r.GetDecreasedContainers().Count
                                            );
            for (int i_2 = 0; i_2 < incContainers.Count; i_2++)
            {
                NUnit.Framework.Assert.AreEqual(i_2, r.GetIncreasedContainers()[i_2].GetCapability
                                                    ().GetVirtualCores());
            }
            for (int i_3 = 0; i_3 < decContainers.Count; i_3++)
            {
                NUnit.Framework.Assert.AreEqual(i_3, r.GetDecreasedContainers()[i_3].GetCapability
                                                    ().GetVirtualCores());
            }
        }
Example #2
0
        public virtual void TestAllocateResponseWithoutIncDecContainers()
        {
            AllocateResponse r = AllocateResponse.NewInstance(3, new AList <ContainerStatus>()
                                                              , new AList <Container>(), new AList <NodeReport>(), null, AMCommand.AmResync, 3,
                                                              null, new AList <NMToken>(), null, null);

            // serde
            YarnServiceProtos.AllocateResponseProto p = ((AllocateResponsePBImpl)r).GetProto(
                );
            r = new AllocateResponsePBImpl(p);
            // check value
            NUnit.Framework.Assert.AreEqual(0, r.GetIncreasedContainers().Count);
            NUnit.Framework.Assert.AreEqual(0, r.GetDecreasedContainers().Count);
        }