ApplicationHistoryManagerImpl extends AbstractService implements
    ApplicationHistoryManager { @Override public Map<ApplicationId, ApplicationReport> getApplications(long appsNum, long appStartedTimeBegin, long appStartedTimeEnd) throws IOException { Map<ApplicationId, ApplicationHistoryData> histData = historyStore.getAllApplications(); HashMap<ApplicationId, ApplicationReport> applicationsReport = new HashMap<ApplicationId, ApplicationReport>(); int count = 0; for (Entry<ApplicationId, ApplicationHistoryData> entry : histData .entrySet()) { if (count == appsNum) { break; } long appStartTime = entry.getValue().getStartTime(); if (appStartTime < appStartedTimeBegin || appStartTime > appStartedTimeEnd) { continue; } applicationsReport.put(entry.getKey(), convertToApplicationReport(entry.getValue())); count++; } return applicationsReport; } ApplicationHistoryManagerImpl(); @Override ContainerReport getAMContainer(ApplicationAttemptId appAttemptId); @Override Map<ApplicationId, ApplicationReport> getApplications(long appsNum,
      long appStartedTimeBegin, long appStartedTimeEnd); @Override ApplicationReport getApplication(ApplicationId appId); @Override ApplicationAttemptReport getApplicationAttempt(
      ApplicationAttemptId appAttemptId); @Override Map<ApplicationAttemptId, ApplicationAttemptReport> getApplicationAttempts(ApplicationId appId); @Override ContainerReport getContainer(ContainerId containerId); @Override Map<ContainerId, ContainerReport> getContainers(
      ApplicationAttemptId appAttemptId); @Private @VisibleForTesting ApplicationHistoryStore getHistoryStore();  }
@Test public void testApplications() throws IOException { ApplicationId appId1 = ApplicationId.newInstance(0, 1); ApplicationId appId2 = ApplicationId.newInstance(0, 2); ApplicationId appId3 = ApplicationId.newInstance(0, 3); writeApplicationStartData(appId1, 1000); writeApplicationFinishData(appId1); writeApplicationStartData(appId2, 3000); writeApplicationFinishData(appId2); writeApplicationStartData(appId3, 4000); writeApplicationFinishData(appId3); Map<ApplicationId, ApplicationReport> reports = applicationHistoryManagerImpl.getApplications(2, 2000L, 5000L); Assert.assertNotNull(reports); Assert.assertEquals(2, reports.size()); Assert.assertNull(reports.get("1")); Assert.assertNull(reports.get("2")); Assert.assertNull(reports.get("3")); }