private void assertTimesAtFinish(RMApp application) { assertStartTimeSet(application); Assert.assertTrue("application finish time is not greater than 0", (application.getFinishTime() > 0)); Assert.assertTrue("application finish time is not >= than start time", (application.getFinishTime() >= application.getStartTime())); }
private void assertTimesAtFinish(RMApp application) { assertStartTimeSet(application); Assert.assertTrue("application finish time is not greater than 0", (application.getFinishTime() > 0)); Assert.assertTrue("application finish time is not >= start time", (application.getFinishTime() >= application.getStartTime())); }
private static RMApp createRMApp(ApplicationId appId) { RMApp app = mock(RMApp.class); when(app.getApplicationId()).thenReturn(appId); when(app.getName()).thenReturn("test app"); when(app.getApplicationType()).thenReturn("test app type"); when(app.getUser()).thenReturn("test user"); when(app.getQueue()).thenReturn("test queue"); when(app.getSubmitTime()).thenReturn(0L); when(app.getStartTime()).thenReturn(1L); when(app.getFinishTime()).thenReturn(2L); when(app.getDiagnostics()).thenReturn( new StringBuilder("test diagnostics info")); when(app.getFinalApplicationStatus()).thenReturn( FinalApplicationStatus.UNDEFINED); return app; }
private static RMApp createRMApp(ApplicationId appId) { RMApp app = mock(RMApp.class); when(app.getApplicationId()).thenReturn(appId); when(app.getName()).thenReturn("test app"); when(app.getApplicationType()).thenReturn("test app type"); when(app.getUser()).thenReturn("test user"); when(app.getQueue()).thenReturn("test queue"); when(app.getSubmitTime()).thenReturn(0L); when(app.getStartTime()).thenReturn(1L); when(app.getFinishTime()).thenReturn(2L); when(app.getDiagnostics()).thenReturn( new StringBuilder("test diagnostics info")); when(app.getFinalApplicationStatus()).thenReturn( FinalApplicationStatus.UNDEFINED); return app; }
@SuppressWarnings("unchecked") public void applicationFinished(RMApp app, RMAppState finalState) { if (historyServiceEnabled) { dispatcher.getEventHandler().handle( new WritingApplicationFinishEvent(app.getApplicationId(), ApplicationFinishData.newInstance(app.getApplicationId(), app.getFinishTime(), app.getDiagnostics().toString(), app.getFinalApplicationStatus(), RMServerUtils.createApplicationState(finalState)))); } }
@SuppressWarnings("unchecked") public void applicationFinished(RMApp app, RMAppState finalState) { if (historyServiceEnabled) { dispatcher.getEventHandler().handle( new WritingApplicationFinishEvent(app.getApplicationId(), ApplicationFinishData.newInstance(app.getApplicationId(), app.getFinishTime(), app.getDiagnostics().toString(), app.getFinalApplicationStatus(), RMServerUtils.createApplicationState(finalState)))); } }
private static RMApp createRMApp(ApplicationId appId) { RMApp app = mock(RMApp.class); when(app.getApplicationId()).thenReturn(appId); when(app.getName()).thenReturn("test app"); when(app.getApplicationType()).thenReturn("test app type"); when(app.getUser()).thenReturn("test user"); when(app.getQueue()).thenReturn("test queue"); when(app.getSubmitTime()).thenReturn(Integer.MAX_VALUE + 1L); when(app.getStartTime()).thenReturn(Integer.MAX_VALUE + 2L); when(app.getFinishTime()).thenReturn(Integer.MAX_VALUE + 3L); when(app.getDiagnostics()).thenReturn( new StringBuilder("test diagnostics info")); RMAppAttempt appAttempt = mock(RMAppAttempt.class); when(appAttempt.getAppAttemptId()).thenReturn( ApplicationAttemptId.newInstance(appId, 1)); when(app.getCurrentAppAttempt()).thenReturn(appAttempt); when(app.getFinalApplicationStatus()).thenReturn( FinalApplicationStatus.UNDEFINED); when(app.getRMAppMetrics()).thenReturn( new RMAppMetrics(null, 0, 0, Integer.MAX_VALUE, Long.MAX_VALUE)); return app; }
@SuppressWarnings("unchecked") public void applicationFinished(RMApp app, RMAppState finalState) { if (historyServiceEnabled) { dispatcher.getEventHandler().handle( new WritingApplicationFinishEvent(app.getApplicationId(), ApplicationFinishData.newInstance(app.getApplicationId(), app.getFinishTime(), app.getDiagnostics().toString(), app.getFinalApplicationStatus(), RMServerUtils.createApplicationState(finalState)))); } }
public static ClientRMService mockClientRMService(RMContext rmContext) { ClientRMService clientRMService = mock(ClientRMService.class); List<ApplicationReport> appReports = new ArrayList<ApplicationReport>(); for (RMApp app : rmContext.getRMApps().values()) { ApplicationReport appReport = ApplicationReport.newInstance( app.getApplicationId(), (ApplicationAttemptId) null, app.getUser(), app.getQueue(), app.getName(), (String) null, 0, (Token) null, app.createApplicationState(), app.getDiagnostics().toString(), (String) null, app.getStartTime(), app.getLaunchTime(), app.getFinishTime(), app.getFinalApplicationStatus(), (ApplicationResourceUsageReport) null, app.getTrackingUrl(), app.getProgress(), app.getApplicationType(), (Token) null); appReports.add(appReport); } GetApplicationsResponse response = mock(GetApplicationsResponse.class); when(response.getApplicationList()).thenReturn(appReports); try { when(clientRMService.getApplications(any(GetApplicationsRequest.class))) .thenReturn(response); } catch (YarnException e) { Assert.fail("Exception is not expected."); } return clientRMService; }
public static ClientRMService mockClientRMService(RMContext rmContext) { ClientRMService clientRMService = mock(ClientRMService.class); List<ApplicationReport> appReports = new ArrayList<ApplicationReport>(); for (RMApp app : rmContext.getRMApps().values()) { ApplicationReport appReport = ApplicationReport.newInstance( app.getApplicationId(), (ApplicationAttemptId) null, app.getUser(), app.getQueue(), app.getName(), (String) null, 0, (Token) null, app.createApplicationState(), app.getDiagnostics().toString(), (String) null, app.getStartTime(), app.getFinishTime(), app.getFinalApplicationStatus(), (ApplicationResourceUsageReport) null, app.getTrackingUrl(), app.getProgress(), app.getApplicationType(), (Token) null); appReports.add(appReport); } GetApplicationsResponse response = mock(GetApplicationsResponse.class); when(response.getApplicationList()).thenReturn(appReports); try { when(clientRMService.getApplications(any(GetApplicationsRequest.class))) .thenReturn(response); } catch (YarnException e) { Assert.fail("Exception is not expteced."); } return clientRMService; }
public void createRMStateForApplications( Map<ApplicationId, ApplicationStateData> applicationState, RMAppState rmAppState) { RMApp app = createNewTestApp(null); ApplicationStateData appState = ApplicationStateData.newInstance(app.getSubmitTime(), app.getStartTime(), app.getUser(), app.getApplicationSubmissionContext(), rmAppState, null, app.getFinishTime()); applicationState.put(app.getApplicationId(), appState); }
public void createRMStateForApplications( Map<ApplicationId, ApplicationStateData> applicationState, RMAppState rmAppState) throws IOException { RMApp app = createNewTestApp(null); ApplicationStateData appState = ApplicationStateData.newInstance(app.getSubmitTime(), app.getStartTime(), app.getUser(), app.getApplicationSubmissionContext(), rmAppState, null, app.getLaunchTime(), app.getFinishTime(), null); applicationState.put(app.getApplicationId(), appState); }
@Test(timeout = 10000) public void testPublishApplicationMetrics() throws Exception { ApplicationId appId = ApplicationId.newInstance(0, 1); RMApp app = createAppAndRegister(appId); metricsPublisher.appCreated(app, app.getStartTime()); metricsPublisher.appACLsUpdated(app, "user1,user2", 4L); metricsPublisher.appFinished(app, RMAppState.FINISHED, app.getFinishTime()); dispatcher.await(); String outputDirApp = getTimelineEntityDir(app) + "/" + TimelineEntityType.YARN_APPLICATION + "/"; File entityFolder = new File(outputDirApp); Assert.assertTrue(entityFolder.isDirectory()); // file name is <entityId>.thist String timelineServiceFileName = appId.toString() + FileSystemTimelineWriterImpl.TIMELINE_SERVICE_STORAGE_EXTENSION; File appFile = new File(outputDirApp, timelineServiceFileName); Assert.assertTrue(appFile.exists()); verifyEntity( appFile, 3, ApplicationMetricsConstants.CREATED_EVENT_TYPE, 8, 0); }
private static void testAppStartState(ApplicationId applicationId, String user, String name, String queue, RMApp application) { Assert.assertTrue("application start time is not greater than 0", application.getStartTime() > 0); Assert.assertTrue("application start time is before currentTime", application.getStartTime() <= System.currentTimeMillis()); Assert.assertEquals("application user is not correct", user, application.getUser()); Assert.assertEquals("application id is not correct", applicationId, application.getApplicationId()); Assert.assertEquals("application progress is not correct", (float)0.0, application.getProgress(), (float)0.0); Assert.assertEquals("application queue is not correct", queue, application.getQueue()); Assert.assertEquals("application name is not correct", name, application.getName()); Assert.assertEquals("application finish time is not 0 and should be", 0, application.getFinishTime()); Assert.assertEquals("application tracking url is not correct", null, application.getTrackingUrl()); StringBuilder diag = application.getDiagnostics(); Assert.assertEquals("application diagnostics is not correct", 0, diag.length()); }
private static void testAppStartState(ApplicationId applicationId, String user, String name, String queue, RMApp application) { Assert.assertTrue("application start time is not greater than 0", application.getStartTime() > 0); Assert.assertTrue("application start time is before currentTime", application.getStartTime() <= System.currentTimeMillis()); Assert.assertEquals("application user is not correct", user, application.getUser()); Assert.assertEquals("application id is not correct", applicationId, application.getApplicationId()); Assert.assertEquals("application progress is not correct", (float)0.0, application.getProgress(), (float)0.0); Assert.assertEquals("application queue is not correct", queue, application.getQueue()); Assert.assertEquals("application name is not correct", name, application.getName()); Assert.assertEquals("application finish time is not 0 and should be", 0, application.getFinishTime()); Assert.assertEquals("application tracking url is not correct", null, application.getTrackingUrl()); StringBuilder diag = application.getDiagnostics(); Assert.assertEquals("application diagnostics is not correct", 0, diag.length()); }
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(); }
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(); }
.add("appMasterHost", host) .add("startTime", app.getStartTime()) .add("finishTime", app.getFinishTime()) .add("finalStatus", app.getFinalApplicationStatus()) .add("memorySeconds", metrics.getMemorySeconds())
.add("appMasterHost", host) .add("startTime", app.getStartTime()) .add("finishTime", app.getFinishTime()) .add("finalStatus", app.getFinalApplicationStatus()) .add("memorySeconds", metrics.getMemorySeconds())
.add("submitTime", app.getSubmitTime()) .add("startTime", app.getStartTime()) .add("finishTime", app.getFinishTime()) .add("finalStatus", app.getFinalApplicationStatus()) .add("memorySeconds", metrics.getMemorySeconds())