@Override public void addLock(final String taskid, final TaskLock taskLock) { Preconditions.checkNotNull(taskid, "taskid"); Preconditions.checkNotNull(taskLock, "taskLock"); log.info( "Adding lock on interval[%s] version[%s] for task: %s", taskLock.getInterval(), taskLock.getVersion(), taskid ); handler.addLock(taskid, taskLock); }
@Deprecated @Override public <T> void addAuditLog(final Task task, final TaskAction<T> taskAction) { Preconditions.checkNotNull(taskAction, "taskAction"); log.info("Logging action for task[%s]: %s", task.getId(), taskAction); handler.addLog(task.getId(), taskAction); }
@Override public List<TaskInfo<Task, TaskStatus>> getActiveTaskInfo(@Nullable String dataSource) { return ImmutableList.copyOf( handler.getActiveTaskInfo(dataSource) ); }
@Override public void removeLock(String taskid, TaskLock taskLockToRemove) { Preconditions.checkNotNull(taskid, "taskid"); Preconditions.checkNotNull(taskLockToRemove, "taskLockToRemove"); final Long lockId = handler.getLockId(taskid, taskLockToRemove); if (lockId == null) { log.warn("Cannot find lock[%s]", taskLockToRemove); } else { log.info("Deleting TaskLock with id[%d]: %s", lockId, taskLockToRemove); handler.removeLock(lockId); } }
@Override public void replaceLock(String taskid, TaskLock oldLock, TaskLock newLock) { Preconditions.checkNotNull(taskid, "taskid"); Preconditions.checkNotNull(oldLock, "oldLock"); Preconditions.checkNotNull(newLock, "newLock"); log.info( "Replacing an existing lock[%s] with a new lock[%s] for task: %s", oldLock, newLock, taskid ); final Long oldLockId = handler.getLockId(taskid, oldLock); if (oldLockId == null) { throw new ISE("Cannot find an existing lock[%s]", oldLock); } handler.replaceLock(taskid, oldLockId, newLock); }
private Map<Long, TaskLock> getLocksWithIds(final String taskid) { return handler.getLocks(taskid); } }
@Deprecated @Override public List<TaskAction> getAuditLogs(final String taskId) { return handler.getLogs(taskId); }
@Override public Optional<Task> getTask(final String taskId) { return handler.getEntry(taskId); }
@Override public Optional<TaskStatus> getStatus(final String taskId) { return handler.getStatus(taskId); }
@Nullable @Override public TaskInfo<Task, TaskStatus> getTaskInfo(String taskId) { return handler.getTaskInfo(taskId); }
@Override public List<TaskInfo<Task, TaskStatus>> getRecentlyCreatedAlreadyFinishedTaskInfo( @Nullable Integer maxTaskStatuses, @Nullable Duration durationBeforeNow, @Nullable String datasource ) { return ImmutableList.copyOf( handler.getCompletedTaskInfo( DateTimes.nowUtc().minus(durationBeforeNow == null ? config.getRecentlyFinishedThreshold() : durationBeforeNow), maxTaskStatuses, datasource ) ); }
@Override public void removeLock(String taskid, TaskLock taskLockToRemove) { Preconditions.checkNotNull(taskid, "taskid"); Preconditions.checkNotNull(taskLockToRemove, "taskLockToRemove"); final Long lockId = handler.getLockId(taskid, taskLockToRemove); if (lockId == null) { log.warn("Cannot find lock[%s]", taskLockToRemove); } else { log.info("Deleting TaskLock with id[%d]: %s", lockId, taskLockToRemove); handler.removeLock(lockId); } }
@Override public void replaceLock(String taskid, TaskLock oldLock, TaskLock newLock) { Preconditions.checkNotNull(taskid, "taskid"); Preconditions.checkNotNull(oldLock, "oldLock"); Preconditions.checkNotNull(newLock, "newLock"); log.info( "Replacing an existing lock[%s] with a new lock[%s] for task: %s", oldLock, newLock, taskid ); final Long oldLockId = handler.getLockId(taskid, oldLock); if (oldLockId == null) { throw new ISE("Cannot find an existing lock[%s]", oldLock); } handler.replaceLock(taskid, oldLockId, newLock); }
private Map<Long, TaskLock> getLocksWithIds(final String taskid) { return handler.getLocks(taskid); } }
@Deprecated @Override public List<TaskAction> getAuditLogs(final String taskId) { return handler.getLogs(taskId); }
@Override public Optional<Task> getTask(final String taskId) { return handler.getEntry(taskId); }
@Override public Optional<TaskStatus> getStatus(final String taskId) { return handler.getStatus(taskId); }
@Nullable @Override public TaskInfo<Task, TaskStatus> getTaskInfo(String taskId) { return handler.getTaskInfo(taskId); }
@Override public List<TaskInfo<Task, TaskStatus>> getRecentlyFinishedTaskInfo( @Nullable Integer maxTaskStatuses, @Nullable Duration duration, @Nullable String datasource ) { return ImmutableList.copyOf( handler.getCompletedTaskInfo( DateTimes.nowUtc().minus(duration == null ? config.getRecentlyFinishedThreshold() : duration), maxTaskStatuses, datasource ) ); }
@Override public List<Task> getActiveTasks() { // filter out taskInfo with a null 'task' which should only happen in practice if we are missing a jackson module // and don't know what to do with the payload, so we won't be able to make use of it anyway return handler.getActiveTaskInfo(null) .stream() .filter(taskInfo -> taskInfo.getStatus().isRunnable() && taskInfo.getTask() != null) .map(TaskInfo::getTask) .collect(Collectors.toList()); }