YARN-8378. ApplicationHistoryManagerImpl#getApplications doesn't honor filters. Contributed by Lantao Jin.
This commit is contained in:
parent
8eae260af5
commit
6c96f5e4b6
|
@ -104,10 +104,20 @@ public class ApplicationHistoryManagerImpl extends AbstractService implements
|
|||
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;
|
||||
}
|
||||
|
|
|
@ -47,6 +47,12 @@ public class ApplicationHistoryStoreTestUtils {
|
|||
appId.toString(), "test type", "test queue", "test user", 0, 0));
|
||||
}
|
||||
|
||||
protected void writeApplicationStartData(ApplicationId appId, long startTime)
|
||||
throws IOException {
|
||||
store.applicationStarted(ApplicationStartData.newInstance(appId,
|
||||
appId.toString(), "test type", "test queue", "test user", 0, startTime));
|
||||
}
|
||||
|
||||
protected void writeApplicationFinishData(ApplicationId appId)
|
||||
throws IOException {
|
||||
store.applicationFinished(ApplicationFinishData.newInstance(appId, 0,
|
||||
|
|
|
@ -19,6 +19,7 @@
|
|||
package org.apache.hadoop.yarn.server.applicationhistoryservice;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.util.Map;
|
||||
|
||||
import org.apache.hadoop.conf.Configuration;
|
||||
import org.apache.hadoop.yarn.api.records.ApplicationAttemptId;
|
||||
|
@ -71,4 +72,24 @@ public class TestApplicationHistoryManagerImpl extends
|
|||
Assert.assertEquals("test type", appReport.getApplicationType().toString());
|
||||
Assert.assertEquals("test queue", appReport.getQueue().toString());
|
||||
}
|
||||
|
||||
@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"));
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue