예제 #1
0
            public override void Run()
            {
                int lastResponseID = 0;

                while (!this._enclosing.stopT)
                {
                    try
                    {
                        NodeStatus nodeStatus = TestNMExpiry.recordFactory.NewRecordInstance <NodeStatus>(
                            );
                        nodeStatus.SetNodeId(this._enclosing.request3.GetNodeId());
                        nodeStatus.SetResponseId(lastResponseID);
                        nodeStatus.SetNodeHealthStatus(TestNMExpiry.recordFactory.NewRecordInstance <NodeHealthStatus
                                                                                                     >());
                        nodeStatus.GetNodeHealthStatus().SetIsNodeHealthy(true);
                        NodeHeartbeatRequest request = TestNMExpiry.recordFactory.NewRecordInstance <NodeHeartbeatRequest
                                                                                                     >();
                        request.SetNodeStatus(nodeStatus);
                        lastResponseID = this._enclosing.resourceTrackerService.NodeHeartbeat(request).GetResponseId
                                             ();
                        Sharpen.Thread.Sleep(1000);
                    }
                    catch (Exception e)
                    {
                        TestNMExpiry.Log.Info("failed to heartbeat ", e);
                    }
                }
            }
예제 #2
0
        private NodeStatus GetNodeStatus()
        {
            NodeStatus status = recordFactory.NewRecordInstance <NodeStatus>();

            status.SetContainersStatuses(new AList <ContainerStatus>());
            status.SetKeepAliveApplications(new AList <ApplicationId>());
            status.SetNodeHealthStatus(GetNodeHealthStatus());
            status.SetNodeId(GetNodeId());
            status.SetResponseId(1);
            return(status);
        }
예제 #3
0
        public static NodeStatus CreateNodeStatus(NodeId nodeId, IList <ContainerStatus> containers
                                                  )
        {
            RecordFactory recordFactory = RecordFactoryProvider.GetRecordFactory(null);
            NodeStatus    nodeStatus    = recordFactory.NewRecordInstance <NodeStatus>();

            nodeStatus.SetNodeId(nodeId);
            nodeStatus.SetContainersStatuses(containers);
            NodeHealthStatus nodeHealthStatus = recordFactory.NewRecordInstance <NodeHealthStatus
                                                                                 >();

            nodeHealthStatus.SetIsNodeHealthy(true);
            nodeStatus.SetNodeHealthStatus(nodeHealthStatus);
            return(nodeStatus);
        }
예제 #4
0
        public virtual void TestRPCResponseId()
        {
            string   node       = "localhost";
            Resource capability = BuilderUtils.NewResource(1024, 1);
            RegisterNodeManagerRequest request = recordFactory.NewRecordInstance <RegisterNodeManagerRequest
                                                                                  >();

            nodeId = NodeId.NewInstance(node, 1234);
            request.SetNodeId(nodeId);
            request.SetHttpPort(0);
            request.SetResource(capability);
            RegisterNodeManagerRequest request1 = recordFactory.NewRecordInstance <RegisterNodeManagerRequest
                                                                                   >();

            request1.SetNodeId(nodeId);
            request1.SetHttpPort(0);
            request1.SetResource(capability);
            resourceTrackerService.RegisterNodeManager(request1);
            NodeStatus nodeStatus = recordFactory.NewRecordInstance <NodeStatus>();

            nodeStatus.SetNodeId(nodeId);
            NodeHealthStatus nodeHealthStatus = recordFactory.NewRecordInstance <NodeHealthStatus
                                                                                 >();

            nodeHealthStatus.SetIsNodeHealthy(true);
            nodeStatus.SetNodeHealthStatus(nodeHealthStatus);
            NodeHeartbeatRequest nodeHeartBeatRequest = recordFactory.NewRecordInstance <NodeHeartbeatRequest
                                                                                         >();

            nodeHeartBeatRequest.SetNodeStatus(nodeStatus);
            nodeStatus.SetResponseId(0);
            NodeHeartbeatResponse response = resourceTrackerService.NodeHeartbeat(nodeHeartBeatRequest
                                                                                  );

            NUnit.Framework.Assert.IsTrue(response.GetResponseId() == 1);
            nodeStatus.SetResponseId(response.GetResponseId());
            response = resourceTrackerService.NodeHeartbeat(nodeHeartBeatRequest);
            NUnit.Framework.Assert.IsTrue(response.GetResponseId() == 2);
            /* try calling with less response id */
            response = resourceTrackerService.NodeHeartbeat(nodeHeartBeatRequest);
            NUnit.Framework.Assert.IsTrue(response.GetResponseId() == 2);
            nodeStatus.SetResponseId(0);
            response = resourceTrackerService.NodeHeartbeat(nodeHeartBeatRequest);
            NUnit.Framework.Assert.IsTrue(NodeAction.Resync.Equals(response.GetNodeAction()));
            NUnit.Framework.Assert.AreEqual("Too far behind rm response id:2 nm response id:0"
                                            , response.GetDiagnosticsMessage());
        }
예제 #5
0
        /// <exception cref="System.Exception"/>
        public virtual NodeHeartbeatResponse NodeHeartbeat(IDictionary <ApplicationId, IList
                                                                        <Org.Apache.Hadoop.Yarn.Api.Records.ContainerStatus> > conts, bool isHealthy, int
                                                           resId)
        {
            NodeHeartbeatRequest req = Org.Apache.Hadoop.Yarn.Util.Records.NewRecord <NodeHeartbeatRequest
                                                                                      >();
            NodeStatus status = Org.Apache.Hadoop.Yarn.Util.Records.NewRecord <NodeStatus>();

            status.SetResponseId(resId);
            status.SetNodeId(nodeId);
            foreach (KeyValuePair <ApplicationId, IList <Org.Apache.Hadoop.Yarn.Api.Records.ContainerStatus
                                                         > > entry in conts)
            {
                Org.Mortbay.Log.Log.Info("entry.getValue() " + entry.Value);
                status.SetContainersStatuses(entry.Value);
            }
            NodeHealthStatus healthStatus = Org.Apache.Hadoop.Yarn.Util.Records.NewRecord <NodeHealthStatus
                                                                                           >();

            healthStatus.SetHealthReport(string.Empty);
            healthStatus.SetIsNodeHealthy(isHealthy);
            healthStatus.SetLastHealthReportTime(1);
            status.SetNodeHealthStatus(healthStatus);
            req.SetNodeStatus(status);
            req.SetLastKnownContainerTokenMasterKey(this.currentContainerTokenMasterKey);
            req.SetLastKnownNMTokenMasterKey(this.currentNMTokenMasterKey);
            NodeHeartbeatResponse heartbeatResponse = resourceTracker.NodeHeartbeat(req);
            MasterKey             masterKeyFromRM   = heartbeatResponse.GetContainerTokenMasterKey();

            if (masterKeyFromRM != null && masterKeyFromRM.GetKeyId() != this.currentContainerTokenMasterKey
                .GetKeyId())
            {
                this.currentContainerTokenMasterKey = masterKeyFromRM;
            }
            masterKeyFromRM = heartbeatResponse.GetNMTokenMasterKey();
            if (masterKeyFromRM != null && masterKeyFromRM.GetKeyId() != this.currentNMTokenMasterKey
                .GetKeyId())
            {
                this.currentNMTokenMasterKey = masterKeyFromRM;
            }
            return(heartbeatResponse);
        }