예제 #1
0
        public virtual void TestRegisterNodeManagerRequest()
        {
            ApplicationId        appId           = ApplicationId.NewInstance(123456789, 1);
            ApplicationAttemptId attemptId       = ApplicationAttemptId.NewInstance(appId, 1);
            ContainerId          containerId     = ContainerId.NewContainerId(attemptId, 1);
            NMContainerStatus    containerReport = NMContainerStatus.NewInstance(containerId, ContainerState
                                                                                 .Running, Resource.NewInstance(1024, 1), "diagnostics", 0, Priority.NewInstance(
                                                                                     10), 1234);
            IList <NMContainerStatus>  reports = Arrays.AsList(containerReport);
            RegisterNodeManagerRequest request = RegisterNodeManagerRequest.NewInstance(NodeId
                                                                                        .NewInstance("1.1.1.1", 1000), 8080, Resource.NewInstance(1024, 1), "NM-version-id"
                                                                                        , reports, Arrays.AsList(appId));
            RegisterNodeManagerRequest requestProto = new RegisterNodeManagerRequestPBImpl(((
                                                                                                RegisterNodeManagerRequestPBImpl)request).GetProto());

            NUnit.Framework.Assert.AreEqual(containerReport, requestProto.GetNMContainerStatuses
                                                ()[0]);
            NUnit.Framework.Assert.AreEqual(8080, requestProto.GetHttpPort());
            NUnit.Framework.Assert.AreEqual("NM-version-id", requestProto.GetNMVersion());
            NUnit.Framework.Assert.AreEqual(NodeId.NewInstance("1.1.1.1", 1000), requestProto
                                            .GetNodeId());
            NUnit.Framework.Assert.AreEqual(Resource.NewInstance(1024, 1), requestProto.GetResource
                                                ());
            NUnit.Framework.Assert.AreEqual(1, requestProto.GetRunningApplications().Count);
            NUnit.Framework.Assert.AreEqual(appId, requestProto.GetRunningApplications()[0]);
        }
예제 #2
0
        public virtual void TestNMContainerStatus()
        {
            ApplicationId        appId       = ApplicationId.NewInstance(123456789, 1);
            ApplicationAttemptId attemptId   = ApplicationAttemptId.NewInstance(appId, 1);
            ContainerId          containerId = ContainerId.NewContainerId(attemptId, 1);
            Resource             resource    = Resource.NewInstance(1000, 200);
            NMContainerStatus    report      = NMContainerStatus.NewInstance(containerId, ContainerState
                                                                             .Complete, resource, "diagnostics", ContainerExitStatus.Aborted, Priority.NewInstance
                                                                                 (10), 1234);
            NMContainerStatus reportProto = new NMContainerStatusPBImpl(((NMContainerStatusPBImpl
                                                                          )report).GetProto());

            NUnit.Framework.Assert.AreEqual("diagnostics", reportProto.GetDiagnostics());
            NUnit.Framework.Assert.AreEqual(resource, reportProto.GetAllocatedResource());
            NUnit.Framework.Assert.AreEqual(ContainerExitStatus.Aborted, reportProto.GetContainerExitStatus
                                                ());
            NUnit.Framework.Assert.AreEqual(ContainerState.Complete, reportProto.GetContainerState
                                                ());
            NUnit.Framework.Assert.AreEqual(containerId, reportProto.GetContainerId());
            NUnit.Framework.Assert.AreEqual(Priority.NewInstance(10), reportProto.GetPriority
                                                ());
            NUnit.Framework.Assert.AreEqual(1234, reportProto.GetCreationTime());
        }
        public virtual void TestRegisterNodeManagerRequest()
        {
            RegisterNodeManagerRequest request = RegisterNodeManagerRequest.NewInstance(NodeId
                                                                                        .NewInstance("host", 1234), 1234, Resource.NewInstance(0, 0), "version", Arrays.
                                                                                        AsList(NMContainerStatus.NewInstance(ContainerId.NewContainerId(ApplicationAttemptId
                                                                                                                                                        .NewInstance(ApplicationId.NewInstance(1234L, 1), 1), 1), ContainerState.Running
                                                                                                                             , Resource.NewInstance(1024, 1), "good", -1, Priority.NewInstance(0), 1234)), Arrays
                                                                                        .AsList(ApplicationId.NewInstance(1234L, 1), ApplicationId.NewInstance(1234L, 2)
                                                                                                ));
            // serialze to proto, and get request from proto
            RegisterNodeManagerRequest request1 = new RegisterNodeManagerRequestPBImpl(((RegisterNodeManagerRequestPBImpl
                                                                                         )request).GetProto());

            // check values
            NUnit.Framework.Assert.AreEqual(request1.GetNMContainerStatuses().Count, request.
                                            GetNMContainerStatuses().Count);
            NUnit.Framework.Assert.AreEqual(request1.GetNMContainerStatuses()[0].GetContainerId
                                                (), request.GetNMContainerStatuses()[0].GetContainerId());
            NUnit.Framework.Assert.AreEqual(request1.GetRunningApplications().Count, request.
                                            GetRunningApplications().Count);
            NUnit.Framework.Assert.AreEqual(request1.GetRunningApplications()[0], request.GetRunningApplications
                                                ()[0]);
            NUnit.Framework.Assert.AreEqual(request1.GetRunningApplications()[1], request.GetRunningApplications
                                                ()[1]);
        }