/** * Find a cluster in the instance list; biased towards live instances * @param instances list of instances * @param appname application name * @return the first found instance, else a failed/finished instance, or null * if there are none of those */ public ApplicationReport findClusterInInstanceList(List<ApplicationReport> instances, String appname) { Preconditions.checkArgument(instances != null, "Null instances list"); Preconditions.checkArgument(StringUtils.isNotEmpty(appname), "Null/empty application name"); // sort by most recent SliderUtils.sortApplicationsByMostRecent(instances); ApplicationReport found = null; for (ApplicationReport app : instances) { if (app.getName().equals(appname)) { if (isApplicationLive(app)) { return app; } // set the found value if not set found = found != null ? found : app; } } return found; }
/** * Find a cluster in the instance list; biased towards live instances * @param instances list of instances * @param appname application name * @return the first found instance, else a failed/finished instance, or null * if there are none of those */ public ApplicationReport findClusterInInstanceList(List<ApplicationReport> instances, String appname) { Preconditions.checkArgument(instances != null, "Null instances list"); Preconditions.checkArgument(StringUtils.isNotEmpty(appname), "Null/empty application name"); // sort by most recent SliderUtils.sortApplicationsByMostRecent(instances); ApplicationReport found = null; for (ApplicationReport app : instances) { if (app.getName().equals(appname)) { if (isApplicationLive(app)) { return app; } // set the found value if not set found = found != null ? found : app; } } return found; }
SliderUtils.sortApplicationsByMostRecent(rmInstances); Map<String, ApplicationReport> reportMap = SliderUtils.buildApplicationReportMap(rmInstances, minAppState,
SliderUtils.sortApplicationsByMostRecent(rmInstances); Map<String, ApplicationReport> reportMap = SliderUtils.buildApplicationReportMap(rmInstances, minAppState,
sortApplicationsByMostRecent(instances); Map<String, ApplicationReport> reportMap = buildApplicationReportMap(instances, min, max);
sortApplicationsByMostRecent(instances); Map<String, ApplicationReport> reportMap = buildApplicationReportMap(instances, min, max);
@Test public void testApplicationReportComparison() { List<ApplicationReport> instances = getApplicationReports(); SliderUtils.sortApplicationsByMostRecent(instances); Assert.assertEquals(1000, instances.get(0).getStartTime()); Assert.assertEquals(1000, instances.get(1).getStartTime()); Assert.assertEquals(1000, instances.get(2).getStartTime()); Assert.assertEquals(1000, instances.get(3).getStartTime()); instances = getApplicationReports(); SliderUtils.sortApplicationReport(instances); Assert.assertEquals(1000, instances.get(0).getStartTime()); Assert.assertEquals(1000, instances.get(1).getStartTime()); Assert.assertEquals(1000, instances.get(2).getStartTime()); Assert.assertEquals(1000, instances.get(3).getStartTime()); Assert.assertTrue(instances.get(0).getYarnApplicationState() == YarnApplicationState.ACCEPTED || instances.get(0).getYarnApplicationState() == YarnApplicationState.RUNNING); Assert.assertTrue(instances.get(1).getYarnApplicationState() == YarnApplicationState.ACCEPTED || instances.get(1).getYarnApplicationState() == YarnApplicationState.RUNNING); Assert.assertTrue(instances.get(2).getYarnApplicationState() == YarnApplicationState.ACCEPTED || instances.get(2).getYarnApplicationState() == YarnApplicationState.RUNNING); Assert.assertTrue(instances.get(3).getYarnApplicationState() == YarnApplicationState.KILLED); }
@Test public void testApplicationReportComparison() { List<ApplicationReport> instances = getApplicationReports(); SliderUtils.sortApplicationsByMostRecent(instances); Assert.assertEquals(1000, instances.get(0).getStartTime()); Assert.assertEquals(1000, instances.get(1).getStartTime()); Assert.assertEquals(1000, instances.get(2).getStartTime()); Assert.assertEquals(1000, instances.get(3).getStartTime()); instances = getApplicationReports(); SliderUtils.sortApplicationReport(instances); Assert.assertEquals(1000, instances.get(0).getStartTime()); Assert.assertEquals(1000, instances.get(1).getStartTime()); Assert.assertEquals(1000, instances.get(2).getStartTime()); Assert.assertEquals(1000, instances.get(3).getStartTime()); Assert.assertTrue(instances.get(0).getYarnApplicationState() == YarnApplicationState.ACCEPTED || instances.get(0).getYarnApplicationState() == YarnApplicationState.RUNNING); Assert.assertTrue(instances.get(1).getYarnApplicationState() == YarnApplicationState.ACCEPTED || instances.get(1).getYarnApplicationState() == YarnApplicationState.RUNNING); Assert.assertTrue(instances.get(2).getYarnApplicationState() == YarnApplicationState.ACCEPTED || instances.get(2).getYarnApplicationState() == YarnApplicationState.RUNNING); Assert.assertTrue(instances.get(3).getYarnApplicationState() == YarnApplicationState.KILLED); }