Example #1
0
 private YarnProtos.ContainerResourceDecreaseProto ConvertToProtoFormat(ContainerResourceDecrease
                                                                        t)
 {
     lock (this)
     {
         return(((ContainerResourceDecreasePBImpl)t).GetProto());
     }
 }
Example #2
0
        public virtual void TestResourceDecreaseContextWithNull()
        {
            ContainerResourceDecrease ctx = ContainerResourceDecrease.NewInstance(null, null);

            // get proto and recover to ctx;
            YarnProtos.ContainerResourceDecreaseProto proto = ((ContainerResourceDecreasePBImpl
                                                                )ctx).GetProto();
            ctx = new ContainerResourceDecreasePBImpl(proto);
            // check values
            NUnit.Framework.Assert.IsNull(ctx.GetCapability());
            NUnit.Framework.Assert.IsNull(ctx.GetContainerId());
        }
Example #3
0
        public virtual void TestResourceDecreaseContext()
        {
            ContainerId containerId = ContainerId.NewContainerId(ApplicationAttemptId.NewInstance
                                                                     (ApplicationId.NewInstance(1234, 3), 3), 7);
            Resource resource             = Resource.NewInstance(1023, 3);
            ContainerResourceDecrease ctx = ContainerResourceDecrease.NewInstance(containerId
                                                                                  , resource);

            // get proto and recover to ctx
            YarnProtos.ContainerResourceDecreaseProto proto = ((ContainerResourceDecreasePBImpl
                                                                )ctx).GetProto();
            ctx = new ContainerResourceDecreasePBImpl(proto);
            // check values
            NUnit.Framework.Assert.AreEqual(ctx.GetCapability(), resource);
            NUnit.Framework.Assert.AreEqual(ctx.GetContainerId(), containerId);
        }
Example #4
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());
            }
        }