/// <exception cref="Org.Apache.Hadoop.Yarn.Exceptions.YarnException"/> public override KillApplicationResponse ForceKillApplication(KillApplicationRequest request) { this._enclosing.ResetStartFailoverFlag(true); // make sure failover has been triggered NUnit.Framework.Assert.IsTrue(this._enclosing.WaittingForFailOver()); return(KillApplicationResponse.NewInstance(true)); }
// don't do anything /// <exception cref="Org.Apache.Hadoop.Yarn.Exceptions.YarnException"/> public override KillApplicationResponse ForceKillApplication(KillApplicationRequest request) { ApplicationId applicationId = request.GetApplicationId(); RMApp application = this.rmContext.GetRMApps()[applicationId]; if (application.IsAppFinalStateStored()) { return(KillApplicationResponse.NewInstance(true)); } else { return(KillApplicationResponse.NewInstance(false)); } }
/// <exception cref="System.Exception"/> private void KillApplication(MockRM rm, ApplicationId appId, ApplicationAttemptId appAttemptId, RMAppState rmAppState) { KillApplicationResponse response = rm.KillApp(appId); NUnit.Framework.Assert.IsTrue(response.GetIsKillCompleted() == IsFinalState(rmAppState )); RMApp loadedApp0 = rm.GetRMContext().GetRMApps()[appId]; rm.WaitForState(appId, RMAppState.Killed); if (appAttemptId != null) { rm.WaitForState(appAttemptId, RMAppAttemptState.Killed); } // no new attempt is created. NUnit.Framework.Assert.AreEqual(1, loadedApp0.GetAppAttempts().Count); }
/// <exception cref="Com.Google.Protobuf.ServiceException"/> public virtual YarnServiceProtos.KillApplicationResponseProto ForceKillApplication (RpcController arg0, YarnServiceProtos.KillApplicationRequestProto proto) { KillApplicationRequestPBImpl request = new KillApplicationRequestPBImpl(proto); try { KillApplicationResponse response = real.ForceKillApplication(request); return(((KillApplicationResponsePBImpl)response).GetProto()); } catch (YarnException e) { throw new ServiceException(e); } catch (IOException e) { throw new ServiceException(e); } }
/// <exception cref="Org.Apache.Hadoop.Yarn.Exceptions.YarnException"/> /// <exception cref="System.IO.IOException"/> public override void KillApplication(ApplicationId applicationId) { KillApplicationRequest request = Org.Apache.Hadoop.Yarn.Util.Records.NewRecord <KillApplicationRequest >(); request.SetApplicationId(applicationId); try { int pollCount = 0; long startTime = Runtime.CurrentTimeMillis(); while (true) { KillApplicationResponse response = rmClient.ForceKillApplication(request); if (response.GetIsKillCompleted()) { Log.Info("Killed application " + applicationId); break; } long elapsedMillis = Runtime.CurrentTimeMillis() - startTime; if (EnforceAsyncAPITimeout() && elapsedMillis >= this.asyncApiPollTimeoutMillis) { throw new YarnException("Timed out while waiting for application " + applicationId + " to be killed."); } if (++pollCount % 10 == 0) { Log.Info("Waiting for application " + applicationId + " to be killed."); } Sharpen.Thread.Sleep(asyncApiPollIntervalMillis); } } catch (Exception) { Log.Error("Interrupted while waiting for application " + applicationId + " to be killed." ); } }
/// <exception cref="System.Exception"/> public virtual void TestResourceMgrDelegate() { /* we not want a mock of resource mgr delegate */ ApplicationClientProtocol clientRMProtocol = Org.Mockito.Mockito.Mock <ApplicationClientProtocol >(); ResourceMgrDelegate delegate_ = new _ResourceMgrDelegate_256(clientRMProtocol, conf ); /* make sure kill calls finish application master */ Org.Mockito.Mockito.When(clientRMProtocol.ForceKillApplication(Matchers.Any <KillApplicationRequest >())).ThenReturn(KillApplicationResponse.NewInstance(true)); delegate_.KillApplication(appId); Org.Mockito.Mockito.Verify(clientRMProtocol).ForceKillApplication(Matchers.Any <KillApplicationRequest >()); /* make sure getalljobs calls get all applications */ Org.Mockito.Mockito.When(clientRMProtocol.GetApplications(Matchers.Any <GetApplicationsRequest >())).ThenReturn(recordFactory.NewRecordInstance <GetApplicationsResponse>()); delegate_.GetAllJobs(); Org.Mockito.Mockito.Verify(clientRMProtocol).GetApplications(Matchers.Any <GetApplicationsRequest >()); /* make sure getapplication report is called */ Org.Mockito.Mockito.When(clientRMProtocol.GetApplicationReport(Matchers.Any <GetApplicationReportRequest >())).ThenReturn(recordFactory.NewRecordInstance <GetApplicationReportResponse>() ); delegate_.GetApplicationReport(appId); Org.Mockito.Mockito.Verify(clientRMProtocol).GetApplicationReport(Matchers.Any <GetApplicationReportRequest >()); /* make sure metrics is called */ GetClusterMetricsResponse clusterMetricsResponse = recordFactory.NewRecordInstance <GetClusterMetricsResponse>(); clusterMetricsResponse.SetClusterMetrics(recordFactory.NewRecordInstance <YarnClusterMetrics >()); Org.Mockito.Mockito.When(clientRMProtocol.GetClusterMetrics(Matchers.Any <GetClusterMetricsRequest >())).ThenReturn(clusterMetricsResponse); delegate_.GetClusterMetrics(); Org.Mockito.Mockito.Verify(clientRMProtocol).GetClusterMetrics(Matchers.Any <GetClusterMetricsRequest >()); Org.Mockito.Mockito.When(clientRMProtocol.GetClusterNodes(Matchers.Any <GetClusterNodesRequest >())).ThenReturn(recordFactory.NewRecordInstance <GetClusterNodesResponse>()); delegate_.GetActiveTrackers(); Org.Mockito.Mockito.Verify(clientRMProtocol).GetClusterNodes(Matchers.Any <GetClusterNodesRequest >()); GetNewApplicationResponse newAppResponse = recordFactory.NewRecordInstance <GetNewApplicationResponse >(); newAppResponse.SetApplicationId(appId); Org.Mockito.Mockito.When(clientRMProtocol.GetNewApplication(Matchers.Any <GetNewApplicationRequest >())).ThenReturn(newAppResponse); delegate_.GetNewJobID(); Org.Mockito.Mockito.Verify(clientRMProtocol).GetNewApplication(Matchers.Any <GetNewApplicationRequest >()); GetQueueInfoResponse queueInfoResponse = recordFactory.NewRecordInstance <GetQueueInfoResponse >(); queueInfoResponse.SetQueueInfo(recordFactory.NewRecordInstance <QueueInfo>()); Org.Mockito.Mockito.When(clientRMProtocol.GetQueueInfo(Matchers.Any <GetQueueInfoRequest >())).ThenReturn(queueInfoResponse); delegate_.GetQueues(); Org.Mockito.Mockito.Verify(clientRMProtocol).GetQueueInfo(Matchers.Any <GetQueueInfoRequest >()); GetQueueUserAclsInfoResponse aclResponse = recordFactory.NewRecordInstance <GetQueueUserAclsInfoResponse >(); Org.Mockito.Mockito.When(clientRMProtocol.GetQueueUserAcls(Matchers.Any <GetQueueUserAclsInfoRequest >())).ThenReturn(aclResponse); delegate_.GetQueueAclsForCurrentUser(); Org.Mockito.Mockito.Verify(clientRMProtocol).GetQueueUserAcls(Matchers.Any <GetQueueUserAclsInfoRequest >()); }
/// <exception cref="System.IO.IOException"/> public virtual KillApplicationResponse ForceKillApplication(KillApplicationRequest request) { return(KillApplicationResponse.NewInstance(true)); }