private void verifyGetClientAMToken(String submitter, String queueAdmin, String queueName, boolean setupACLs) throws Exception { ApplicationId applicationId = submitAppAndGetAppId(submitter, queueName, setupACLs); final GetApplicationReportRequest appReportRequest = GetApplicationReportRequest.newInstance(applicationId); ApplicationClientProtocol submitterClient = getRMClientForUser(submitter); ApplicationClientProtocol adMinUserClient = getRMClientForUser(queueAdmin); GetApplicationReportResponse submitterGetReport = submitterClient.getApplicationReport(appReportRequest); GetApplicationReportResponse adMinUserGetReport = adMinUserClient.getApplicationReport(appReportRequest); Assert.assertEquals(submitterGetReport.getApplicationReport() .getClientToAMToken(), adMinUserGetReport.getApplicationReport() .getClientToAMToken()); }
@Test public void testApplicationReport() throws IOException, YarnException { ApplicationId appId = null; appId = ApplicationId.newInstance(0, 1); GetApplicationReportRequest request = GetApplicationReportRequest.newInstance(appId); GetApplicationReportResponse response = clientService.getApplicationReport(request); ApplicationReport appReport = response.getApplicationReport(); Assert.assertNotNull(appReport); Assert.assertEquals(123, appReport.getApplicationResourceUsageReport() .getMemorySeconds()); Assert.assertEquals(345, appReport.getApplicationResourceUsageReport() .getVcoreSeconds()); Assert.assertEquals(345, appReport.getApplicationResourceUsageReport() .getGcoreSeconds()); Assert.assertEquals("application_0_0001", appReport.getApplicationId() .toString()); Assert.assertEquals("test app type", appReport.getApplicationType().toString()); Assert.assertEquals("test queue", appReport.getQueue().toString()); }
@Override public ApplicationReport getApplicationReport(ApplicationId appId) throws YarnException, IOException { GetApplicationReportResponse response = null; try { GetApplicationReportRequest request = Records .newRecord(GetApplicationReportRequest.class); request.setApplicationId(appId); response = rmClient.getApplicationReport(request); } catch (YarnException e) { if (!historyServiceEnabled) { // Just throw it as usual if historyService is not enabled. throw e; } // Even if history-service is enabled, treat all exceptions still the same // except the following if (!(e.getClass() == ApplicationNotFoundException.class)) { throw e; } return historyClient.getApplicationReport(appId); } return response.getApplicationReport(); }
@Override protected ApplicationHistoryProtocol getAHSProxy(Configuration conf) throws IOException { GetApplicationReportResponse resp = Mockito. mock(GetApplicationReportResponse.class); historyManager = Mockito.mock(ApplicationHistoryProtocol.class); try { Mockito.when(historyManager.getApplicationReport(Mockito .any(GetApplicationReportRequest.class))).thenReturn(resp); } catch (YarnException e) { // TODO Auto-generated catch block e.printStackTrace(); } return historyManager; }
@Test public void testApplicationReport() throws IOException, YarnException { ApplicationId appId = null; appId = ApplicationId.newInstance(0, 1); GetApplicationReportRequest request = GetApplicationReportRequest.newInstance(appId); GetApplicationReportResponse response = clientService.getApplicationReport(request); ApplicationReport appReport = response.getApplicationReport(); Assert.assertNotNull(appReport); Assert.assertEquals(123, appReport.getApplicationResourceUsageReport() .getMemorySeconds()); Assert.assertEquals(345, appReport.getApplicationResourceUsageReport() .getVcoreSeconds()); Assert.assertEquals("application_0_0001", appReport.getApplicationId() .toString()); Assert.assertEquals("test app type", appReport.getApplicationType().toString()); Assert.assertEquals("test queue", appReport.getQueue().toString()); }
@Override public ApplicationReport getApplicationReport(ApplicationId appId) throws YarnException, IOException { GetApplicationReportResponse response = null; try { GetApplicationReportRequest request = Records .newRecord(GetApplicationReportRequest.class); request.setApplicationId(appId); response = rmClient.getApplicationReport(request); } catch (ApplicationNotFoundException e) { if (!historyServiceEnabled) { // Just throw it as usual if historyService is not enabled. throw e; } return historyClient.getApplicationReport(appId); } return response.getApplicationReport(); }
@Test public void testApplicationReport() throws IOException, YarnException { ApplicationId appId = null; appId = ApplicationId.newInstance(0, 1); GetApplicationReportRequest request = GetApplicationReportRequest.newInstance(appId); GetApplicationReportResponse response = clientService.getClientHandler().getApplicationReport(request); ApplicationReport appReport = response.getApplicationReport(); Assert.assertNotNull(appReport); Assert.assertEquals("application_0_0001", appReport.getApplicationId() .toString()); Assert.assertEquals("test app type", appReport.getApplicationType().toString()); Assert.assertEquals("test queue", appReport.getQueue().toString()); }
@Test public void testApplicationReport() throws IOException, YarnException { ApplicationId appId = null; appId = ApplicationId.newInstance(0, 1); GetApplicationReportRequest request = GetApplicationReportRequest.newInstance(appId); GetApplicationReportResponse response = clientService.getApplicationReport(request); ApplicationReport appReport = response.getApplicationReport(); Assert.assertNotNull(appReport); Assert.assertEquals(123, appReport.getApplicationResourceUsageReport() .getMemorySeconds()); Assert.assertEquals(345, appReport.getApplicationResourceUsageReport() .getVcoreSeconds()); Assert.assertEquals(345, appReport.getApplicationResourceUsageReport() .getGPUSeconds()); Assert.assertEquals("application_0_0001", appReport.getApplicationId() .toString()); Assert.assertEquals("test app type", appReport.getApplicationType().toString()); Assert.assertEquals("test queue", appReport.getQueue().toString()); }
@Test public void testApplicationReport() throws IOException, YarnException { ApplicationId appId = null; appId = ApplicationId.newInstance(0, 1); writeApplicationStartData(appId); writeApplicationFinishData(appId); GetApplicationReportRequest request = GetApplicationReportRequest.newInstance(appId); GetApplicationReportResponse response = historyServer.getClientService().getClientHandler() .getApplicationReport(request); ApplicationReport appReport = response.getApplicationReport(); Assert.assertNotNull(appReport); Assert.assertEquals("application_0_0001", appReport.getApplicationId() .toString()); Assert.assertEquals("test type", appReport.getApplicationType().toString()); Assert.assertEquals("test queue", appReport.getQueue().toString()); }
@Override public GetApplicationReportResponse getApplicationReport( GetApplicationReportRequest request) throws YarnException, IOException { GetApplicationReportRequestProto requestProto = ((GetApplicationReportRequestPBImpl) request).getProto(); try { return new GetApplicationReportResponsePBImpl(proxy.getApplicationReport( null, requestProto)); } catch (ServiceException e) { RPCUtil.unwrapAndThrowException(e); return null; } }
private static GetApplicationReportResponse createApplicationReportWithRunningApplication() { ApplicationReport report = mock(ApplicationReport.class); when(report.getYarnApplicationState()).thenReturn( YarnApplicationState.RUNNING); GetApplicationReportResponse response = mock(GetApplicationReportResponse.class); when(response.getApplicationReport()).thenReturn(report); return response; }
private static GetApplicationReportResponse createApplicationReportWithFinishedApplication() { ApplicationReport report = mock(ApplicationReport.class); when(report.getYarnApplicationState()).thenReturn( YarnApplicationState.FINISHED); GetApplicationReportResponse response = mock(GetApplicationReportResponse.class); when(response.getApplicationReport()).thenReturn(report); return response; }
/** * Get a report for the specified app. * @param appId the id of the application to get. * @return the ApplicationReport for that app. * @throws YarnException on any error. * @throws IOException */ public ApplicationReport getApplicationReport(ApplicationId appId) throws YarnException, IOException { GetApplicationReportRequest request = recordFactory .newRecordInstance(GetApplicationReportRequest.class); request.setApplicationId(appId); GetApplicationReportResponse response = applicationsManager .getApplicationReport(request); return response.getApplicationReport(); }
/** * It gives response which includes application report if the application * present otherwise throws ApplicationNotFoundException. */ @Override public GetApplicationReportResponse getApplicationReport( GetApplicationReportRequest request) throws YarnException { ApplicationId applicationId = request.getApplicationId(); UserGroupInformation callerUGI; try { callerUGI = UserGroupInformation.getCurrentUser(); } catch (IOException ie) { LOG.info("Error getting UGI ", ie); throw RPCUtil.getRemoteException(ie); } RMApp application = this.rmContext.getRMApps().get(applicationId); if (application == null) { // If the RM doesn't have the application, throw // ApplicationNotFoundException and let client to handle. throw new ApplicationNotFoundException("Application with id '" + applicationId + "' doesn't exist in RM."); } boolean allowAccess = checkAccess(callerUGI, application.getUser(), ApplicationAccessType.VIEW_APP, application); ApplicationReport report = application.createAndGetApplicationReport(callerUGI.getUserName(), allowAccess); GetApplicationReportResponse response = recordFactory .newRecordInstance(GetApplicationReportResponse.class); response.setApplicationReport(report); return response; }
private ApplicationReport verifyAppReportAfterRMRestart(RMApp app, MockRM rm) throws Exception { GetApplicationReportRequest reportRequest = GetApplicationReportRequest.newInstance(app.getApplicationId()); GetApplicationReportResponse response = rm.getClientRMService().getApplicationReport(reportRequest); ApplicationReport report = response.getApplicationReport(); Assert.assertEquals(app.getStartTime(), report.getStartTime()); Assert.assertEquals(app.getFinishTime(), report.getFinishTime()); Assert.assertEquals(app.createApplicationState(), report.getYarnApplicationState()); Assert.assertTrue(1 == report.getProgress()); return response.getApplicationReport(); }
public ApplicationReport getApplicationReport(ApplicationId appId) throws YarnException, IOException { ApplicationClientProtocol client = getClientRMService(); GetApplicationReportResponse response = client.getApplicationReport(GetApplicationReportRequest .newInstance(appId)); return response.getApplicationReport(); }
@Test public void testGetApplicationReport() throws Exception { YarnScheduler yarnScheduler = mock(YarnScheduler.class); RMContext rmContext = mock(RMContext.class); mockRMContext(yarnScheduler, rmContext); ApplicationId appId1 = getApplicationId(1); ApplicationACLsManager mockAclsManager = mock(ApplicationACLsManager.class); when( mockAclsManager.checkAccess(UserGroupInformation.getCurrentUser(), ApplicationAccessType.VIEW_APP, null, appId1)).thenReturn(true); ClientRMService rmService = new ClientRMService(rmContext, yarnScheduler, null, mockAclsManager, null, null); try { RecordFactory recordFactory = RecordFactoryProvider.getRecordFactory(null); GetApplicationReportRequest request = recordFactory .newRecordInstance(GetApplicationReportRequest.class); request.setApplicationId(appId1); GetApplicationReportResponse response = rmService.getApplicationReport(request); ApplicationReport report = response.getApplicationReport(); ApplicationResourceUsageReport usageReport = report.getApplicationResourceUsageReport(); Assert.assertEquals(10, usageReport.getMemorySeconds()); Assert.assertEquals(3, usageReport.getVcoreSeconds()); Assert.assertEquals(3, usageReport.getGcoreSeconds()); } finally { rmService.close(); } }
@Override public GetApplicationReportResponse getApplicationReport( GetApplicationReportRequest request) throws YarnException, IOException { ApplicationId applicationId = request.getApplicationId(); try { GetApplicationReportResponse response = GetApplicationReportResponse.newInstance(history .getApplication(applicationId)); return response; } catch (IOException e) { LOG.error(e.getMessage(), e); throw e; } }
@Override public ApplicationReport getApplicationReport(ApplicationId appId) throws YarnException, IOException { GetApplicationReportRequest request = GetApplicationReportRequest .newInstance(appId); GetApplicationReportResponse response = ahsClient .getApplicationReport(request); return response.getApplicationReport(); }
@Override public GetApplicationReportResponse getApplicationReport( GetApplicationReportRequest request) throws YarnException { resetStartFailoverFlag(true); // make sure failover has been triggered Assert.assertTrue(waittingForFailOver()); // create a fake application report ApplicationReport report = createFakeAppReport(); GetApplicationReportResponse response = GetApplicationReportResponse.newInstance(report); return response; }
@Override public GetApplicationReportResponse getApplicationReport( GetApplicationReportRequest request) throws IOException { ApplicationId applicationId = request.getApplicationId(); ApplicationReport application = recordFactory .newRecordInstance(ApplicationReport.class); application.setApplicationId(applicationId); application.setFinalApplicationStatus(FinalApplicationStatus.UNDEFINED); if (amRunning) { application.setYarnApplicationState(YarnApplicationState.RUNNING); } else if (amRestarting) { application.setYarnApplicationState(YarnApplicationState.SUBMITTED); } else { application.setYarnApplicationState(YarnApplicationState.FINISHED); application.setFinalApplicationStatus(FinalApplicationStatus.SUCCEEDED); } String[] split = AMHOSTADDRESS.split(":"); application.setHost(split[0]); application.setRpcPort(Integer.parseInt(split[1])); application.setUser("TestClientRedirect-user"); application.setName("N/A"); application.setQueue("N/A"); application.setStartTime(0); application.setFinishTime(0); application.setTrackingUrl("N/A"); application.setDiagnostics("N/A"); GetApplicationReportResponse response = recordFactory .newRecordInstance(GetApplicationReportResponse.class); response.setApplicationReport(application); return response; }
@Override public GetApplicationReportResponse getApplicationReport( GetApplicationReportRequest request) throws YarnException, IOException { ApplicationReport applicationReport = appClient .getApplicationReport(request.getApplicationId()); return GetApplicationReportResponse.newInstance(applicationReport); }