public UserMetricsInfo(ResourceManager rm, string user) { // JAXB needs this ResourceScheduler rs = rm.GetResourceScheduler(); QueueMetrics metrics = rs.GetRootQueueMetrics(); QueueMetrics userMetrics = metrics.GetUserMetrics(user); this.userMetricsAvailable = false; if (userMetrics != null) { this.userMetricsAvailable = true; this.appsSubmitted = userMetrics.GetAppsSubmitted(); this.appsCompleted = userMetrics.GetAppsCompleted(); this.appsPending = userMetrics.GetAppsPending(); this.appsRunning = userMetrics.GetAppsRunning(); this.appsFailed = userMetrics.GetAppsFailed(); this.appsKilled = userMetrics.GetAppsKilled(); this.runningContainers = userMetrics.GetAllocatedContainers(); this.pendingContainers = userMetrics.GetPendingContainers(); this.reservedContainers = userMetrics.GetReservedContainers(); this.reservedMB = userMetrics.GetReservedMB(); this.pendingMB = userMetrics.GetPendingMB(); this.allocatedMB = userMetrics.GetAllocatedMB(); this.reservedVirtualCores = userMetrics.GetReservedVirtualCores(); this.pendingVirtualCores = userMetrics.GetPendingVirtualCores(); this.allocatedVirtualCores = userMetrics.GetAllocatedVirtualCores(); } }
public ClusterMetricsInfo(ResourceManager rm) { // JAXB needs this ResourceScheduler rs = rm.GetResourceScheduler(); QueueMetrics metrics = rs.GetRootQueueMetrics(); ClusterMetrics clusterMetrics = ClusterMetrics.GetMetrics(); this.appsSubmitted = metrics.GetAppsSubmitted(); this.appsCompleted = metrics.GetAppsCompleted(); this.appsPending = metrics.GetAppsPending(); this.appsRunning = metrics.GetAppsRunning(); this.appsFailed = metrics.GetAppsFailed(); this.appsKilled = metrics.GetAppsKilled(); this.reservedMB = metrics.GetReservedMB(); this.availableMB = metrics.GetAvailableMB(); this.allocatedMB = metrics.GetAllocatedMB(); this.reservedVirtualCores = metrics.GetReservedVirtualCores(); this.availableVirtualCores = metrics.GetAvailableVirtualCores(); this.allocatedVirtualCores = metrics.GetAllocatedVirtualCores(); this.containersAllocated = metrics.GetAllocatedContainers(); this.containersPending = metrics.GetPendingContainers(); this.containersReserved = metrics.GetReservedContainers(); this.totalMB = availableMB + allocatedMB; this.totalVirtualCores = availableVirtualCores + allocatedVirtualCores; this.activeNodes = clusterMetrics.GetNumActiveNMs(); this.lostNodes = clusterMetrics.GetNumLostNMs(); this.unhealthyNodes = clusterMetrics.GetUnhealthyNMs(); this.decommissionedNodes = clusterMetrics.GetNumDecommisionedNMs(); this.rebootedNodes = clusterMetrics.GetNumRebootedNMs(); this.totalNodes = activeNodes + lostNodes + decommissionedNodes + rebootedNodes + unhealthyNodes; }
/// <summary>Validate killing an application when it is at accepted state.</summary> /// <exception cref="System.Exception">exception</exception> public virtual void TestApplicationKillAtAcceptedState() { Dispatcher dispatcher = new _AsyncDispatcher_573(); MockRM rm = new _MockRM_596(dispatcher, conf); // test metrics QueueMetrics metrics = rm.GetResourceScheduler().GetRootQueueMetrics(); int appsKilled = metrics.GetAppsKilled(); int appsSubmitted = metrics.GetAppsSubmitted(); rm.Start(); MockNM nm1 = new MockNM("127.0.0.1:1234", 15120, rm.GetResourceTrackerService()); nm1.RegisterNode(); // a failed app RMApp application = rm.SubmitApp(200); MockAM am = MockRM.LaunchAM(application, rm, nm1); am.WaitForState(RMAppAttemptState.Launched); nm1.NodeHeartbeat(am.GetApplicationAttemptId(), 1, ContainerState.Running); rm.WaitForState(application.GetApplicationId(), RMAppState.Accepted); // Now kill the application before new attempt is launched, the app report // returns the invalid AM host and port. KillApplicationRequest request = KillApplicationRequest.NewInstance(application.GetApplicationId ()); rm.GetClientRMService().ForceKillApplication(request); // Specific test for YARN-1689 follows // Now let's say a race causes AM to register now. This should not crash RM. am.RegisterAppAttempt(false); // We explicitly intercepted the kill-event to RMAppAttempt, so app should // still be in KILLING state. rm.WaitForState(application.GetApplicationId(), RMAppState.Killing); // AM should now be in running rm.WaitForState(am.GetApplicationAttemptId(), RMAppAttemptState.Running); // Simulate that appAttempt is killed. rm.GetRMContext().GetDispatcher().GetEventHandler().Handle(new RMAppEvent(application .GetApplicationId(), RMAppEventType.AttemptKilled)); rm.WaitForState(application.GetApplicationId(), RMAppState.Killed); // test metrics metrics = rm.GetResourceScheduler().GetRootQueueMetrics(); NUnit.Framework.Assert.AreEqual(appsKilled + 1, metrics.GetAppsKilled()); NUnit.Framework.Assert.AreEqual(appsSubmitted + 1, metrics.GetAppsSubmitted()); }