/// <exception cref="Org.Apache.Hadoop.Yarn.Exceptions.YarnException"/> /// <exception cref="System.IO.IOException"/> /// <exception cref="System.Exception"/> protected internal virtual void FetchData() { reqAppStates = EnumSet.NoneOf <YarnApplicationState>(); string reqStateString = $(YarnWebParams.AppState); if (reqStateString != null && !reqStateString.IsEmpty()) { string[] appStateStrings = reqStateString.Split(","); foreach (string stateString in appStateStrings) { reqAppStates.AddItem(YarnApplicationState.ValueOf(stateString.Trim())); } } callerUGI = GetCallerUGI(); GetApplicationsRequest request = GetApplicationsRequest.NewInstance(reqAppStates); string appsNumStr = $(YarnWebParams.AppsNum); if (appsNumStr != null && !appsNumStr.IsEmpty()) { long appsNum = long.Parse(appsNumStr); request.SetLimit(appsNum); } if (callerUGI == null) { appReports = appBaseProt.GetApplications(request).GetApplicationList(); } else { appReports = callerUGI.DoAs(new _PrivilegedExceptionAction_87(this, request)); } }
public async Task <GetApplicationsQueryResult> Handle(GetApplicationsQuery request, CancellationToken cancellationToken) { var apiRequest = new GetApplicationsRequest { PledgeId = request.PledgeId }; var response = await _levyTransferMatchingApiClient.Get <GetApplicationsResponse>(apiRequest); return(new GetApplicationsQueryResult { Applications = response.Applications .Where(a => a.Status == ApplicationStatus.Accepted || a.Status == ApplicationStatus.Approved) .Select(a => new GetApplicationsQueryResult.Application { Id = a.Id, PledgeId = a.PledgeId, EmployerAccountId = a.EmployerAccountId, StandardId = a.StandardId, StandardTitle = a.StandardTitle, StandardLevel = a.StandardLevel, StandardDuration = a.StandardDuration, StandardMaxFunding = a.StandardMaxFunding, StartDate = a.StartDate, NumberOfApprentices = a.NumberOfApprentices, NumberOfApprenticesUsed = a.NumberOfApprenticesUsed, Status = a.Status }) }); }
public virtual void TestGetApplicationsRequest() { GetApplicationsRequest request = GetApplicationsRequest.NewInstance(); EnumSet <YarnApplicationState> appStates = EnumSet.Of(YarnApplicationState.Accepted ); request.SetApplicationStates(appStates); ICollection <string> tags = new HashSet <string>(); tags.AddItem("tag1"); request.SetApplicationTags(tags); ICollection <string> types = new HashSet <string>(); types.AddItem("type1"); request.SetApplicationTypes(types); long startBegin = Runtime.CurrentTimeMillis(); long startEnd = Runtime.CurrentTimeMillis() + 1; request.SetStartRange(startBegin, startEnd); long finishBegin = Runtime.CurrentTimeMillis() + 2; long finishEnd = Runtime.CurrentTimeMillis() + 3; request.SetFinishRange(finishBegin, finishEnd); long limit = 100L; request.SetLimit(limit); ICollection <string> queues = new HashSet <string>(); queues.AddItem("queue1"); request.SetQueues(queues); ICollection <string> users = new HashSet <string>(); users.AddItem("user1"); request.SetUsers(users); ApplicationsRequestScope scope = ApplicationsRequestScope.All; request.SetScope(scope); GetApplicationsRequest requestFromProto = new GetApplicationsRequestPBImpl(((GetApplicationsRequestPBImpl )request).GetProto()); // verify the whole record equals with original record NUnit.Framework.Assert.AreEqual(requestFromProto, request); // verify all properties are the same as original request NUnit.Framework.Assert.AreEqual("ApplicationStates from proto is not the same with original request" , requestFromProto.GetApplicationStates(), appStates); NUnit.Framework.Assert.AreEqual("ApplicationTags from proto is not the same with original request" , requestFromProto.GetApplicationTags(), tags); NUnit.Framework.Assert.AreEqual("ApplicationTypes from proto is not the same with original request" , requestFromProto.GetApplicationTypes(), types); NUnit.Framework.Assert.AreEqual("StartRange from proto is not the same with original request" , requestFromProto.GetStartRange(), new LongRange(startBegin, startEnd)); NUnit.Framework.Assert.AreEqual("FinishRange from proto is not the same with original request" , requestFromProto.GetFinishRange(), new LongRange(finishBegin, finishEnd)); NUnit.Framework.Assert.AreEqual("Limit from proto is not the same with original request" , requestFromProto.GetLimit(), limit); NUnit.Framework.Assert.AreEqual("Queues from proto is not the same with original request" , requestFromProto.GetQueues(), queues); NUnit.Framework.Assert.AreEqual("Users from proto is not the same with original request" , requestFromProto.GetUsers(), users); }
public virtual void TestApplications() { ApplicationId appId = null; appId = ApplicationId.NewInstance(0, 1); ApplicationId appId1 = ApplicationId.NewInstance(0, 2); GetApplicationsRequest request = GetApplicationsRequest.NewInstance(); GetApplicationsResponse response = clientService.GetApplications(request); IList <ApplicationReport> appReport = response.GetApplicationList(); NUnit.Framework.Assert.IsNotNull(appReport); NUnit.Framework.Assert.AreEqual(appId, appReport[1].GetApplicationId()); NUnit.Framework.Assert.AreEqual(appId1, appReport[0].GetApplicationId()); // Create a historyManager, and set the max_apps can be loaded // as 1. Configuration conf = new YarnConfiguration(); conf.SetLong(YarnConfiguration.ApplicationHistoryMaxApps, 1); ApplicationHistoryManagerOnTimelineStore historyManager2 = new ApplicationHistoryManagerOnTimelineStore (dataManager, new ApplicationACLsManager(conf)); historyManager2.Init(conf); historyManager2.Start(); ApplicationHistoryClientService clientService2 = new ApplicationHistoryClientService (historyManager2); response = clientService2.GetApplications(request); appReport = response.GetApplicationList(); NUnit.Framework.Assert.IsNotNull(appReport); NUnit.Framework.Assert.IsTrue(appReport.Count == 1); // Expected to get the appReport for application with appId1 NUnit.Framework.Assert.AreEqual(appId1, appReport[0].GetApplicationId()); }
/// <exception cref="Org.Apache.Hadoop.Yarn.Exceptions.YarnException"/> /// <exception cref="System.IO.IOException"/> public override IList <ApplicationReport> GetApplications() { GetApplicationsRequest request = GetApplicationsRequest.NewInstance(null, null); GetApplicationsResponse response = ahsClient.GetApplications(request); return(response.GetApplicationList()); }
/// <exception cref="Org.Apache.Hadoop.Yarn.Exceptions.YarnException"/> /// <exception cref="System.IO.IOException"/> public virtual GetApplicationsResponse GetApplications(GetApplicationsRequest request ) { GetApplicationsResponse response = GetApplicationsResponse.NewInstance(new AList < ApplicationReport>(history.GetApplications(request.GetLimit()).Values)); return(response); }
/// <exception cref="Org.Apache.Hadoop.Yarn.Exceptions.YarnException"/> /// <exception cref="System.IO.IOException"/> public override IList <ApplicationReport> GetApplications(ICollection <string> applicationTypes , EnumSet <YarnApplicationState> applicationStates) { GetApplicationsRequest request = GetApplicationsRequest.NewInstance(applicationTypes , applicationStates); GetApplicationsResponse response = rmClient.GetApplications(request); return(response.GetApplicationList()); }
public void Then_The_GetUrl_Is_Correctly_Built(long accountId, long accountLegalEntityId, string baseUrl) { var actual = new GetApplicationsRequest(accountId, accountLegalEntityId) { BaseUrl = baseUrl }; actual.GetUrl.Should().Be($"{baseUrl}accounts/{accountId}/legalentity/{accountLegalEntityId}/applications"); }
/// <exception cref="Org.Apache.Hadoop.Yarn.Exceptions.YarnException"/> public override GetApplicationsResponse GetApplications(GetApplicationsRequest request ) { this._enclosing.ResetStartFailoverFlag(true); // make sure failover has been triggered NUnit.Framework.Assert.IsTrue(this._enclosing.WaittingForFailOver()); // create GetApplicationsResponse with fake applicationList GetApplicationsResponse response = GetApplicationsResponse.NewInstance(this._enclosing .CreateFakeAppReports()); return(response); }
public async Task <IActionResult> GetApplications(long accountId, long accountLegalEntityId) { var request = new GetApplicationsRequest(accountId, accountLegalEntityId); var response = await QueryAsync <GetApplicationsRequest, GetApplicationsResponse>(request); if (response?.ApprenticeApplications != null) { return(Ok(response)); } return(NotFound()); }
// This is to test AM Host and rpc port are invalidated after the am attempt // is killed or failed, so that client doesn't get the wrong information. /// <exception cref="System.Exception"/> public virtual void TestInvalidateAMHostPortWhenAMFailedOrKilled() { conf.SetInt(YarnConfiguration.RmAmMaxAttempts, 1); MockRM rm1 = new MockRM(conf); rm1.Start(); // a succeeded app RMApp app1 = rm1.SubmitApp(200); MockNM nm1 = new MockNM("127.0.0.1:1234", 15120, rm1.GetResourceTrackerService()); nm1.RegisterNode(); MockAM am1 = MockRM.LaunchAndRegisterAM(app1, rm1, nm1); MockRM.FinishAMAndVerifyAppState(app1, rm1, nm1, am1); // a failed app RMApp app2 = rm1.SubmitApp(200); MockAM am2 = MockRM.LaunchAndRegisterAM(app2, rm1, nm1); nm1.NodeHeartbeat(am2.GetApplicationAttemptId(), 1, ContainerState.Complete); am2.WaitForState(RMAppAttemptState.Failed); rm1.WaitForState(app2.GetApplicationId(), RMAppState.Failed); // a killed app RMApp app3 = rm1.SubmitApp(200); MockAM am3 = MockRM.LaunchAndRegisterAM(app3, rm1, nm1); rm1.KillApp(app3.GetApplicationId()); rm1.WaitForState(app3.GetApplicationId(), RMAppState.Killed); rm1.WaitForState(am3.GetApplicationAttemptId(), RMAppAttemptState.Killed); GetApplicationsRequest request1 = GetApplicationsRequest.NewInstance(EnumSet.Of(YarnApplicationState .Finished, YarnApplicationState.Killed, YarnApplicationState.Failed)); GetApplicationsResponse response1 = rm1.GetClientRMService().GetApplications(request1 ); IList <ApplicationReport> appList1 = response1.GetApplicationList(); NUnit.Framework.Assert.AreEqual(3, appList1.Count); foreach (ApplicationReport report in appList1) { // killed/failed apps host and rpc port are invalidated. if (report.GetApplicationId().Equals(app2.GetApplicationId()) || report.GetApplicationId ().Equals(app3.GetApplicationId())) { NUnit.Framework.Assert.AreEqual("N/A", report.GetHost()); NUnit.Framework.Assert.AreEqual(-1, report.GetRpcPort()); } // succeeded app's host and rpc port is not invalidated if (report.GetApplicationId().Equals(app1.GetApplicationId())) { NUnit.Framework.Assert.IsFalse(report.GetHost().Equals("N/A")); NUnit.Framework.Assert.IsTrue(report.GetRpcPort() != -1); } } }
public async Task <List <ApplicationResponse> > Handle(GetApplicationsRequest request, CancellationToken cancellationToken) { List <Domain.Entities.Apply> result; if (!request.CreatedBy) { result = await _applyRepository.GetOrganisationApplications(request.UserId); } else { result = await _applyRepository.GetUserApplications(request.UserId); } return(Mapper.Map <List <Domain.Entities.Apply>, List <ApplicationResponse> >(result)); }
protected override async Task <int> ExecuteAsync(CommandContext context, CancellationToken cancellationToken) { var deviceTypeId = DeviceTypeId.TryParseGuid(); var request = new GetApplicationsRequest { DeviceTypeId = deviceTypeId }; var applications = await context.Client.Applications.GetApplicationsAsync(request, cancellationToken); applications.DisplayEntities(a => $"{a.Id}: {a.Name}"); return(0); }
public Task <Application[]> GetApplicationsAsync(GetApplicationsRequest request, CancellationToken cancellationToken = new CancellationToken()) { dynamic query = new ExpandoObject(); if (request?.DeviceTypeId != null) { query.deviceTypeId = request.DeviceTypeId.Value; } return(_client.MakeJsonRequestAsync <Application[]>( cancellationToken, HttpMethod.Get, ResourceUrls.Applications, (object)query)); }
/// <exception cref="Org.Apache.Hadoop.Yarn.Exceptions.YarnException"/> /// <exception cref="System.IO.IOException"/> public virtual GetApplicationsResponse GetApplications(GetApplicationsRequest request ) { YarnServiceProtos.GetApplicationsRequestProto requestProto = ((GetApplicationsRequestPBImpl )request).GetProto(); try { return(new GetApplicationsResponsePBImpl(proxy.GetApplications(null, requestProto ))); } catch (ServiceException e) { RPCUtil.UnwrapAndThrowException(e); return(null); } }
public async Task <List <ApplicationResponse> > Handle(GetApplicationsRequest request, CancellationToken cancellationToken) { List <ApplySummary> result = null; switch (request.ApplicationType) { case ApplicationTypes.Organisation: result = await _applyRepository.GetOrganisationApplications(request.UserId); break; case ApplicationTypes.Standard: result = await _applyRepository.GetStandardApplications(request.UserId); break; case ApplicationTypes.Withdrawal: result = await _applyRepository.GetWithdrawalApplications(request.UserId); break; case ApplicationTypes.OrganisationWithdrawal: result = await _applyRepository.GetOrganisationWithdrawalApplications(request.UserId); break; case ApplicationTypes.StandardWithdrawal: result = await _applyRepository.GetStandardWithdrawalApplications(request.UserId); break; } return(result != null ? Mapper.Map <List <ApplySummary>, List <ApplicationResponse> >(result) : null); }
public _PrivilegedExceptionAction_87(AppsBlock _enclosing, GetApplicationsRequest request) { this._enclosing = _enclosing; this.request = request; }
/// <exception cref="System.IO.IOException"/> public virtual GetApplicationsResponse GetApplications(GetApplicationsRequest request ) { return(null); }
public _PrivilegedExceptionAction_161(WebServices _enclosing, GetApplicationsRequest request) { this._enclosing = _enclosing; this.request = request; }
public virtual AppsInfo GetApps(HttpServletRequest req, HttpServletResponse res, string stateQuery, ICollection <string> statesQuery, string finalStatusQuery, string userQuery, string queueQuery, string count, string startedBegin, string startedEnd , string finishBegin, string finishEnd, ICollection <string> applicationTypes) { UserGroupInformation callerUGI = GetUser(req); bool checkStart = false; bool checkEnd = false; bool checkAppTypes = false; bool checkAppStates = false; long countNum = long.MaxValue; // set values suitable in case both of begin/end not specified long sBegin = 0; long sEnd = long.MaxValue; long fBegin = 0; long fEnd = long.MaxValue; if (count != null && !count.IsEmpty()) { countNum = long.Parse(count); if (countNum <= 0) { throw new BadRequestException("limit value must be greater then 0"); } } if (startedBegin != null && !startedBegin.IsEmpty()) { checkStart = true; sBegin = long.Parse(startedBegin); if (sBegin < 0) { throw new BadRequestException("startedTimeBegin must be greater than 0"); } } if (startedEnd != null && !startedEnd.IsEmpty()) { checkStart = true; sEnd = long.Parse(startedEnd); if (sEnd < 0) { throw new BadRequestException("startedTimeEnd must be greater than 0"); } } if (sBegin > sEnd) { throw new BadRequestException("startedTimeEnd must be greater than startTimeBegin" ); } if (finishBegin != null && !finishBegin.IsEmpty()) { checkEnd = true; fBegin = long.Parse(finishBegin); if (fBegin < 0) { throw new BadRequestException("finishTimeBegin must be greater than 0"); } } if (finishEnd != null && !finishEnd.IsEmpty()) { checkEnd = true; fEnd = long.Parse(finishEnd); if (fEnd < 0) { throw new BadRequestException("finishTimeEnd must be greater than 0"); } } if (fBegin > fEnd) { throw new BadRequestException("finishTimeEnd must be greater than finishTimeBegin" ); } ICollection <string> appTypes = ParseQueries(applicationTypes, false); if (!appTypes.IsEmpty()) { checkAppTypes = true; } // stateQuery is deprecated. if (stateQuery != null && !stateQuery.IsEmpty()) { statesQuery.AddItem(stateQuery); } ICollection <string> appStates = ParseQueries(statesQuery, true); if (!appStates.IsEmpty()) { checkAppStates = true; } AppsInfo allApps = new AppsInfo(); ICollection <ApplicationReport> appReports = null; GetApplicationsRequest request = GetApplicationsRequest.NewInstance(); request.SetLimit(countNum); try { if (callerUGI == null) { // TODO: the request should take the params like what RMWebServices does // in YARN-1819. appReports = appBaseProt.GetApplications(request).GetApplicationList(); } else { appReports = callerUGI.DoAs(new _PrivilegedExceptionAction_161(this, request)); } } catch (Exception e) { RewrapAndThrowException(e); } foreach (ApplicationReport appReport in appReports) { if (checkAppStates && !appStates.Contains(StringUtils.ToLowerCase(appReport.GetYarnApplicationState ().ToString()))) { continue; } if (finalStatusQuery != null && !finalStatusQuery.IsEmpty()) { FinalApplicationStatus.ValueOf(finalStatusQuery); if (!Sharpen.Runtime.EqualsIgnoreCase(appReport.GetFinalApplicationStatus().ToString (), finalStatusQuery)) { continue; } } if (userQuery != null && !userQuery.IsEmpty()) { if (!appReport.GetUser().Equals(userQuery)) { continue; } } if (queueQuery != null && !queueQuery.IsEmpty()) { if (!appReport.GetQueue().Equals(queueQuery)) { continue; } } if (checkAppTypes && !appTypes.Contains(StringUtils.ToLowerCase(appReport.GetApplicationType ().Trim()))) { continue; } if (checkStart && (appReport.GetStartTime() < sBegin || appReport.GetStartTime() > sEnd)) { continue; } if (checkEnd && (appReport.GetFinishTime() < fBegin || appReport.GetFinishTime() > fEnd)) { continue; } AppInfo app = new AppInfo(appReport); allApps.Add(app); } return(allApps); }
public async Task <GetApplicationsResponse> GetApplications(GetApplicationsRequest request) { return(await _levyTransferMatchingApiClient.Get <GetApplicationsResponse>(request)); }