Skip to content

Commit

Permalink
kagkarlsson#515: apply spottless, add .gitattributes
Browse files Browse the repository at this point in the history
  • Loading branch information
kamko committed Jan 4, 2025
1 parent b21da31 commit 1e9771d
Show file tree
Hide file tree
Showing 4 changed files with 19 additions and 22 deletions.
1 change: 1 addition & 0 deletions .gitattributes
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
* text eol=lf
Original file line number Diff line number Diff line change
Expand Up @@ -359,31 +359,29 @@ protected void detectDeadExecutions() {
LOG.debug("Deleting executions with unresolved tasks.");

Map<String, Instant> unresolvedTaskToNewestExecution = new HashMap<>();
schedulerTaskRepository
.getScheduledExecutions(
schedulerTaskRepository.getScheduledExecutions(
ScheduledExecutionsFilter.all(),
execution -> unresolvedTaskToNewestExecution.merge(
execution.taskInstance.getTaskName(),
execution.executionTime,
(oldValue, newValue) -> oldValue.isAfter(newValue) ? oldValue : newValue
));

taskResolver
.getUnresolved()
.stream()
execution ->
unresolvedTaskToNewestExecution.merge(
execution.taskInstance.getTaskName(),
execution.executionTime,
(oldValue, newValue) -> oldValue.isAfter(newValue) ? oldValue : newValue));

taskResolver.getUnresolved().stream()
.map(UnresolvedTask::getTaskName)
.filter(taskName -> {
Instant newestExecution = unresolvedTaskToNewestExecution.get(taskName);
.filter(
taskName -> {
Instant newestExecution = unresolvedTaskToNewestExecution.get(taskName);

if (newestExecution == null) {
// probably deleted by other node
return true;
}
if (newestExecution == null) {
// probably deleted by other node
return true;
}

Duration age = Duration.between(newestExecution, clock.now());
Duration age = Duration.between(newestExecution, clock.now());

return age.compareTo(deleteUnresolvedAfter) >= 0;
})
return age.compareTo(deleteUnresolvedAfter) >= 0;
})
.forEach(
taskName -> {
LOG.warn(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@

import com.github.kagkarlsson.scheduler.stats.StatsRegistry;
import com.github.kagkarlsson.scheduler.task.Task;
import java.time.Duration;
import java.time.Instant;
import java.util.ArrayList;
import java.util.Arrays;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -118,7 +118,6 @@ public void scheduler_should_detect_dead_execution_that_never_updated_heartbeat(
assertThat(nonCompletingExecutionHandler.timesExecuted.get(), is(2));
}


public static class NonCompletingTask<T> extends OneTimeTask<T> {
private final VoidExecutionHandler<T> handler;

Expand Down

0 comments on commit 1e9771d

Please sign in to comment.