new AmInfo().setAppName(appReport.getName()).setAppType(appReport.getApplicationType())); appStatusBuilder.setAppStartTime(appReport.getStartTime()); switch (appReport.getYarnApplicationState()) {
@Override public boolean test(ApplicationReport applicationReport) { return !applicationReport.getApplicationType().equals(YARN_APPLICATION_TYPE_MAPREDUCE); } });
@Override public boolean test(ApplicationReport applicationReport) { return !applicationReport.getApplicationType().equals(YARN_APPLICATION_TYPE_MAPREDUCE); } });
private String[] getAppNameAndType(CommandLine cliParser, String option) throws IOException, YarnException { String applicationIdOrName = cliParser.getOptionValue(option); try { ApplicationId id = ApplicationId.fromString(applicationIdOrName); ApplicationReport report = getApplicationReport(id); return new String[]{report.getName(), report.getApplicationType()}; } catch (IllegalArgumentException e) { // assume CLI option provided the app name // and read appType from command line since id wasn't provided String appType = getSingleAppTypeFromCLI(cliParser); return new String[]{applicationIdOrName, appType}; } }
private void setupMocks(final String mrJobId, final String wfExternalId, final String yarnApplicationId) throws HadoopAccessorException, IOException, URISyntaxException, InterruptedException, YarnException { when(hadoopJobIdFinder.find()).thenReturn(mrJobId); when(applicationReport.getApplicationType()).thenReturn("MAPREDUCE"); when(workflowActionBean.getWfId()).thenReturn("workflowId"); when(workflowActionBean.getExternalId()).thenReturn(wfExternalId); when(applicationReport.getYarnApplicationState()).thenReturn(YarnApplicationState.RUNNING); when(applicationId.toString()).thenReturn(yarnApplicationId); when(applicationReport.getApplicationId()).thenReturn(applicationId); when(reader.read()).thenReturn(Lists.newArrayList(applicationReport)); }
@Test public void testGetLastYarnIdFromUnorderedListSuccess() { final ApplicationReport newLauncher = mock(ApplicationReport.class); when(newLauncher.getApplicationType()).thenReturn("Oozie Launcher"); when(newLauncher.getYarnApplicationState()).thenReturn(YarnApplicationState.FINISHED); final ApplicationId newLauncherId = mock(ApplicationId.class); when(newLauncherId.toString()).thenReturn("application_1534164756526_0003"); when(newLauncher.getApplicationId()).thenReturn(newLauncherId); final ApplicationReport newMRJob = mock(ApplicationReport.class); when(newMRJob.getApplicationType()).thenReturn("MAPREDUCE"); when(newMRJob.getYarnApplicationState()).thenReturn(YarnApplicationState.RUNNING); final ApplicationId newMRJobId = mock(ApplicationId.class); when(newMRJobId.toString()).thenReturn("application_1534164756526_0004"); when(newMRJob.getApplicationId()).thenReturn(newMRJobId); final String lastYarnId = yarnApplicationIdFinder.getLastYarnId(Lists.newArrayList(newMRJob, newLauncher)); assertEquals("last YARN id should be the maximal element in the list", "application_1534164756526_0004", lastYarnId); } }
@Test public void whenHadoopJobIdIsNotPresentChildYarnApplicationIdIsFound() throws Exception { when(hadoopJobIdFinder.find()).thenReturn(null); when(applicationReport.getApplicationType()).thenReturn("MAPREDUCE"); when(workflowActionBean.getWfId()).thenReturn("workflowId"); when(applicationReport.getYarnApplicationState()).thenReturn(YarnApplicationState.RUNNING); when(applicationId.toString()).thenReturn("application_1534164756526_0000"); when(applicationReport.getApplicationId()).thenReturn(applicationId); when(reader.read()).thenReturn(Lists.newArrayList(applicationReport)); assertEquals("no Hadoop Job ID, but an appropriate YARN application: applicationId should be found", "application_1534164756526_0000", yarnApplicationIdFinder.find()); }
private List<ApplicationReport> getApplicationReports() { List<ApplicationReport> instances = new ArrayList<ApplicationReport>(); instances.add(getApplicationReport(1000, 0, "app1", YarnApplicationState.ACCEPTED)); instances.add(getApplicationReport(900, 998, "app1", YarnApplicationState.KILLED)); instances.add(getApplicationReport(900, 998, "app2", YarnApplicationState.FAILED)); instances.add(getApplicationReport(1000, 0, "app2", YarnApplicationState.RUNNING)); instances.add(getApplicationReport(800, 837, "app3", YarnApplicationState.FINISHED)); instances.add(getApplicationReport(1000, 0, "app3", YarnApplicationState.RUNNING)); instances.add(getApplicationReport(900, 998, "app3", YarnApplicationState.KILLED)); instances.add(getApplicationReport(800, 837, "app4", YarnApplicationState.FINISHED)); instances.add(getApplicationReport(1000, 1050, "app4", YarnApplicationState.KILLED)); instances.add(getApplicationReport(900, 998, "app4", YarnApplicationState.FINISHED)); Assert.assertEquals("app1", instances.get(0).getApplicationType()); Assert.assertEquals("app1", instances.get(1).getApplicationType()); Assert.assertEquals("app2", instances.get(2).getApplicationType()); Assert.assertEquals("app2", instances.get(3).getApplicationType()); return instances; }
private List<ApplicationReport> getApplicationReports() { List<ApplicationReport> instances = new ArrayList<ApplicationReport>(); instances.add(getApplicationReport(1000, 0, "app1", YarnApplicationState.ACCEPTED)); instances.add(getApplicationReport(900, 998, "app1", YarnApplicationState.KILLED)); instances.add(getApplicationReport(900, 998, "app2", YarnApplicationState.FAILED)); instances.add(getApplicationReport(1000, 0, "app2", YarnApplicationState.RUNNING)); instances.add(getApplicationReport(800, 837, "app3", YarnApplicationState.FINISHED)); instances.add(getApplicationReport(1000, 0, "app3", YarnApplicationState.RUNNING)); instances.add(getApplicationReport(900, 998, "app3", YarnApplicationState.KILLED)); instances.add(getApplicationReport(800, 837, "app4", YarnApplicationState.FINISHED)); instances.add(getApplicationReport(1000, 1050, "app4", YarnApplicationState.KILLED)); instances.add(getApplicationReport(900, 998, "app4", YarnApplicationState.FINISHED)); Assert.assertEquals("app1", instances.get(0).getApplicationType()); Assert.assertEquals("app1", instances.get(1).getApplicationType()); Assert.assertEquals("app2", instances.get(2).getApplicationType()); Assert.assertEquals("app2", instances.get(3).getApplicationType()); return instances; }
@Test public void whenHadoopJobIdAndChildYarnApplicationAreNotPresentActionExternalIdIsFound() throws Exception { when(hadoopJobIdFinder.find()).thenReturn(null); when(reader.read()).thenReturn(Collections.emptyList()); when(workflowActionBean.getExternalId()).thenReturn("application_1534164756526_0000"); assertEquals("no Hadoop Job ID nor YARN applications: WorkflowActionBean.externalId should be found", "application_1534164756526_0000", yarnApplicationIdFinder.find()); when(applicationReport.getApplicationType()).thenReturn("Oozie Launcher"); when(applicationReport.getApplicationId()).thenReturn(applicationId); when(applicationId.toString()).thenReturn("application_1534164756526_0001"); when(reader.read()).thenReturn(Lists.newArrayList(applicationReport)); assertEquals( "no Hadoop Job ID nor YARN applications of MAPREDUCE type: WorkflowActionBean.externalId should be found", "application_1534164756526_0000", yarnApplicationIdFinder.find()); when(applicationReport.getApplicationType()).thenReturn("MAPREDUCE"); when(workflowActionBean.getWfId()).thenReturn("workflowId"); assertEquals( "no Hadoop Job ID nor YARN applications of the same workflow: WorkflowActionBean.externalId should be found", "application_1534164756526_0000", yarnApplicationIdFinder.find()); }
@Test public void whenOldLauncherAndMRobApplicationsAreFinishedAndNewLauncherPresentNewLauncherIsUsed() throws Exception { final ApplicationReport oldLauncher = mock(ApplicationReport.class); when(oldLauncher.getApplicationType()).thenReturn("Oozie Launcher"); when(oldLauncher.getYarnApplicationState()).thenReturn(YarnApplicationState.FINISHED); final ApplicationId oldLauncherId = mock(ApplicationId.class); when(oldLauncher.getApplicationId()).thenReturn(oldLauncherId); final ApplicationReport oldMRJob = mock(ApplicationReport.class); when(oldMRJob.getApplicationType()).thenReturn("MAPREDUCE"); when(oldMRJob.getYarnApplicationState()).thenReturn(YarnApplicationState.FINISHED); final ApplicationId oldMRJobId = mock(ApplicationId.class); when(oldMRJob.getApplicationId()).thenReturn(oldMRJobId); final ApplicationReport newLauncher = mock(ApplicationReport.class); when(newLauncher.getApplicationType()).thenReturn("Oozie Launcher"); when(newLauncher.getYarnApplicationState()).thenReturn(YarnApplicationState.FINISHED); final ApplicationId newLauncherId = mock(ApplicationId.class); when(newLauncher.getApplicationId()).thenReturn(newLauncherId); final ApplicationReport newMRJob = mock(ApplicationReport.class); when(newMRJob.getApplicationType()).thenReturn("MAPREDUCE"); when(newMRJob.getYarnApplicationState()).thenReturn(YarnApplicationState.RUNNING); final ApplicationId newMRJobId = mock(ApplicationId.class);
/** * convert an AM report to a string for diagnostics * @param report the report * @return the string value */ public static String reportToString(ApplicationReport report) { if (report == null) { return "Null application report"; } return "App " + report.getName() + "/" + report.getApplicationType() + "# " + report.getApplicationId() + " user " + report.getUser() + " is in state " + report.getYarnApplicationState() + " RPC: " + report.getHost() + ":" + report.getRpcPort() + " URL: " + report.getOriginalTrackingUrl(); }
/** * convert an AM report to a string for diagnostics * @param report the report * @return the string value */ public static String reportToString(ApplicationReport report) { if (report == null) { return "Null application report"; } return "App " + report.getName() + "/" + report.getApplicationType() + "# " + report.getApplicationId() + " user " + report.getUser() + " is in state " + report.getYarnApplicationState() + " RPC: " + report.getHost() + ":" + report.getRpcPort() + " URL: " + report.getOriginalTrackingUrl(); }
row.addValue(index++, report.getQueue()); } else if (SubmittedField.TYPE == f) { row.addValue(index++, report.getApplicationType()); } else if (SubmittedField.STARTTIME == f) { row.addValue(index++, DateFormat.getDateTimeInstance(DateFormat.SHORT, DateFormat.SHORT).format(
public AppInfo(ApplicationReport app) { appId = app.getApplicationId().toString(); if (app.getCurrentApplicationAttemptId() != null) { currentAppAttemptId = app.getCurrentApplicationAttemptId().toString(); } user = app.getUser(); queue = app.getQueue(); name = app.getName(); type = app.getApplicationType(); host = app.getHost(); rpcPort = app.getRpcPort(); appState = app.getYarnApplicationState(); diagnosticsInfo = app.getDiagnostics(); trackingUrl = app.getTrackingUrl(); originalTrackingUrl = app.getOriginalTrackingUrl(); submittedTime = app.getStartTime(); startedTime = app.getStartTime(); finishedTime = app.getFinishTime(); elapsedTime = Times.elapsed(startedTime, finishedTime); finalAppStatus = app.getFinalApplicationStatus(); progress = app.getProgress() * 100; // in percent if (app.getApplicationTags() != null && !app.getApplicationTags().isEmpty()) { this.applicationTags = CSV_JOINER.join(app.getApplicationTags()); } }
public AppInfo(ApplicationReport app) { appId = app.getApplicationId().toString(); if (app.getCurrentApplicationAttemptId() != null) { currentAppAttemptId = app.getCurrentApplicationAttemptId().toString(); } user = app.getUser(); queue = app.getQueue(); name = app.getName(); type = app.getApplicationType(); host = app.getHost(); rpcPort = app.getRpcPort(); appState = app.getYarnApplicationState(); diagnosticsInfo = app.getDiagnostics(); trackingUrl = app.getTrackingUrl(); originalTrackingUrl = app.getOriginalTrackingUrl(); submittedTime = app.getStartTime(); startedTime = app.getStartTime(); finishedTime = app.getFinishTime(); elapsedTime = Times.elapsed(startedTime, finishedTime); finalAppStatus = app.getFinalApplicationStatus(); progress = app.getProgress() * 100; // in percent if (app.getApplicationTags() != null && !app.getApplicationTags().isEmpty()) { this.applicationTags = CSV_JOINER.join(app.getApplicationTags()); } }
public SerializedApplicationReport(ApplicationReport report) { this.applicationId = report.getApplicationId().toString(); ApplicationAttemptId attemptId = report.getCurrentApplicationAttemptId(); this.applicationAttemptId = attemptId != null ? attemptId.toString() : "N/A"; this.name = report.getName(); this.applicationType = report.getApplicationType(); this.user = report.getUser(); this.queue = report.getQueue(); this.host = report.getHost(); this.rpcPort = report.getRpcPort(); this.state = report.getYarnApplicationState().toString(); this.diagnostics = report.getDiagnostics(); this.startTime = report.getStartTime(); this.finishTime = report.getFinishTime(); FinalApplicationStatus appStatus = report.getFinalApplicationStatus(); this.finalStatus = appStatus == null ? "" : appStatus.toString(); this.progress = report.getProgress(); this.url = report.getTrackingUrl(); this.origTrackingUrl= report.getOriginalTrackingUrl(); }
public SerializedApplicationReport(ApplicationReport report) { this.applicationId = report.getApplicationId().toString(); ApplicationAttemptId attemptId = report.getCurrentApplicationAttemptId(); this.applicationAttemptId = attemptId != null ? attemptId.toString() : "N/A"; this.name = report.getName(); this.applicationType = report.getApplicationType(); this.user = report.getUser(); this.queue = report.getQueue(); this.host = report.getHost(); this.rpcPort = report.getRpcPort(); this.state = report.getYarnApplicationState().toString(); this.diagnostics = report.getDiagnostics(); this.startTime = report.getStartTime(); this.finishTime = report.getFinishTime(); FinalApplicationStatus appStatus = report.getFinalApplicationStatus(); this.finalStatus = appStatus == null ? "" : appStatus.toString(); this.progress = report.getProgress(); this.url = report.getTrackingUrl(); this.origTrackingUrl= report.getOriginalTrackingUrl(); }
@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()); }
@Test public void testApplicationReport() throws IOException, YarnException { ApplicationId appId = null; appId = ApplicationId.newInstance(0, 1); writeApplicationStartData(appId); writeApplicationFinishData(appId); ApplicationAttemptId appAttemptId = ApplicationAttemptId.newInstance(appId, 1); writeApplicationAttemptStartData(appAttemptId); writeApplicationAttemptFinishData(appAttemptId); ApplicationReport appReport = applicationHistoryManagerImpl.getApplication(appId); Assert.assertNotNull(appReport); Assert.assertEquals(appId, appReport.getApplicationId()); Assert.assertEquals(appAttemptId, appReport.getCurrentApplicationAttemptId()); Assert.assertEquals(appAttemptId.toString(), appReport.getHost()); Assert.assertEquals("test type", appReport.getApplicationType().toString()); Assert.assertEquals("test queue", appReport.getQueue().toString()); } }