use of io.datarouter.tasktracker.web.LongRunningTasksHandler.LongRunningTaskJspDto in project datarouter by hotpads.
the class JobsHealthHandler method uniqueTasks.
@Handler(defaultHandler = true)
Mav uniqueTasks() {
Mav mav = new Mav(files.jsp.admin.datarouter.tasktracker.jobsHealthJsp);
List<LongRunningTask> allTasks = longRunningTaskDao.scan().include(task -> task.getStartTime() == null || task.getStartTime().getTime() > System.currentTimeMillis() - Duration.ofDays(1).toMillis()).list();
List<String> uniqueJobs = allTasks.stream().map(LongRunningTask::getKey).map(LongRunningTaskKey::getName).distinct().collect(Collectors.toList());
Integer numRunningJobs = 0;
ZoneId zoneId = currentUserSessionInfoService.getZoneId(request);
List<LongRunningTaskJspDto> allBadTasks = new ArrayList<>();
for (LongRunningTask task : allTasks) {
if (task.isBadState()) {
allBadTasks.add(new LongRunningTaskJspDto(task, zoneId));
} else if (task.isRunning()) {
numRunningJobs++;
}
}
mav.put("allBadTasks", allBadTasks);
mav.put("uniqueJobs", uniqueJobs);
mav.put("numUniqueJobs", uniqueJobs.size());
mav.put("numRunningJobs", numRunningJobs);
mav.put("legend", LongRunningTasksHandler.legend());
return mav;
}
Aggregations