Search in sources :

Example 1 with LongRunningTaskKey

use of io.datarouter.tasktracker.storage.LongRunningTaskKey in project datarouter by hotpads.

the class LongRunningTaskService method getLastRun.

public Optional<LongRunningTask> getLastRun(TaskTracker tracker) {
    String name = tracker.getName();
    LongRunningTaskKey firstPrefix = new LongRunningTaskKey(name, null, null);
    LongRunningTaskKey lastPrefix = new LongRunningTaskKey(name, Date.from(tracker.getScheduledTime()), tracker.getServerName());
    Range<LongRunningTaskKey> range = new Range<>(firstPrefix, true, lastPrefix, false);
    return dao.scan(range).reduce((firstRun, secondRun) -> secondRun);
}
Also used : Range(io.datarouter.util.tuple.Range) LongRunningTaskKey(io.datarouter.tasktracker.storage.LongRunningTaskKey)

Example 2 with LongRunningTaskKey

use of io.datarouter.tasktracker.storage.LongRunningTaskKey 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;
}
Also used : DatarouterTaskTrackerFiles(io.datarouter.tasktracker.config.DatarouterTaskTrackerFiles) CurrentUserSessionInfoService(io.datarouter.web.user.session.CurrentUserSessionInfoService) LongRunningTaskKey(io.datarouter.tasktracker.storage.LongRunningTaskKey) Mav(io.datarouter.web.handler.mav.Mav) Collectors(java.util.stream.Collectors) ZoneId(java.time.ZoneId) ArrayList(java.util.ArrayList) LongRunningTaskJspDto(io.datarouter.tasktracker.web.LongRunningTasksHandler.LongRunningTaskJspDto) Inject(javax.inject.Inject) List(java.util.List) LongRunningTaskDao(io.datarouter.tasktracker.storage.LongRunningTaskDao) Duration(java.time.Duration) BaseHandler(io.datarouter.web.handler.BaseHandler) LongRunningTask(io.datarouter.tasktracker.storage.LongRunningTask) Mav(io.datarouter.web.handler.mav.Mav) LongRunningTaskJspDto(io.datarouter.tasktracker.web.LongRunningTasksHandler.LongRunningTaskJspDto) ZoneId(java.time.ZoneId) ArrayList(java.util.ArrayList) LongRunningTask(io.datarouter.tasktracker.storage.LongRunningTask) LongRunningTaskKey(io.datarouter.tasktracker.storage.LongRunningTaskKey) BaseHandler(io.datarouter.web.handler.BaseHandler)

Aggregations

LongRunningTaskKey (io.datarouter.tasktracker.storage.LongRunningTaskKey)2 DatarouterTaskTrackerFiles (io.datarouter.tasktracker.config.DatarouterTaskTrackerFiles)1 LongRunningTask (io.datarouter.tasktracker.storage.LongRunningTask)1 LongRunningTaskDao (io.datarouter.tasktracker.storage.LongRunningTaskDao)1 LongRunningTaskJspDto (io.datarouter.tasktracker.web.LongRunningTasksHandler.LongRunningTaskJspDto)1 Range (io.datarouter.util.tuple.Range)1 BaseHandler (io.datarouter.web.handler.BaseHandler)1 Mav (io.datarouter.web.handler.mav.Mav)1 CurrentUserSessionInfoService (io.datarouter.web.user.session.CurrentUserSessionInfoService)1 Duration (java.time.Duration)1 ZoneId (java.time.ZoneId)1 ArrayList (java.util.ArrayList)1 List (java.util.List)1 Collectors (java.util.stream.Collectors)1 Inject (javax.inject.Inject)1