Set<String> appStates = parseQueries(statesQuery, true);
if (!appStates.isEmpty()) {
checkAppStates = true;
}
AppsInfo allApps = new AppsInfo();
Collection<ApplicationReport> appReports = null;
try {
appReports = appContext.getAllApplications().values();
} catch (IOException e) {
throw new WebApplicationException(e);
}
for (ApplicationReport appReport : appReports) {
if (checkCount && num == countNum) {
break;
}
if (checkAppStates
&& !appStates.contains(appReport.getYarnApplicationState().toString()
.toLowerCase())) {
continue;
}
if (finalStatusQuery != null && !finalStatusQuery.isEmpty()) {
FinalApplicationStatus.valueOf(finalStatusQuery);
if (!appReport.getFinalApplicationStatus().toString()
.equalsIgnoreCase(finalStatusQuery)) {
continue;
}
}
if (userQuery != null && !userQuery.isEmpty()) {
if (!appReport.getUser().equals(userQuery)) {
continue;
}
}
if (queueQuery != null && !queueQuery.isEmpty()) {
if (!appReport.getQueue().equals(queueQuery)) {
continue;
}
}
if (checkAppTypes
&& !appTypes.contains(appReport.getApplicationType().trim()
.toLowerCase())) {
continue;
}
if (checkStart
&& (appReport.getStartTime() < sBegin || appReport.getStartTime() > sEnd)) {
continue;
}
if (checkEnd
&& (appReport.getFinishTime() < fBegin || appReport.getFinishTime() > fEnd)) {
continue;
}
AppInfo app = new AppInfo(appReport);
allApps.add(app);
num++;
}
return allApps;
}