Skip to content

Commit

Permalink
fix collectResumingTasksForResumeFailedMode
Browse files Browse the repository at this point in the history
  • Loading branch information
snagasawa committed Feb 15, 2024
1 parent 6f60f54 commit 2ca6c4e
Showing 1 changed file with 8 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

import java.util.List;
import java.util.Set;
import java.util.Arrays;
import java.util.HashSet;
import java.util.stream.Collectors;
import javax.ws.rs.Consumes;
Expand Down Expand Up @@ -298,21 +299,24 @@ private List<Long> collectResumingTasks(RestSessionAttemptRequest.Resume resume)

private List<Long> collectResumingTasksForResumeFailedMode(long attemptId)
{
TaskStateCode[] statusArr = {TaskStateCode.SUCCESS, TaskStateCode.GROUP_ERROR, TaskStateCode.ERROR, TaskStateCode.CANCELED};
List<TaskStateCode> statuses = Arrays.asList(statusArr);

List<ArchivedTask> tasks = sm
.getSessionStore(getSiteId())
.getTasksOfAttempt(attemptId);

List<Long> successTasks = tasks.stream()
.filter(task -> task.getState() == TaskStateCode.SUCCESS)
List<Long> ids = tasks.stream()
.filter(t-> statuses.contains(t.getState()))
.map(task -> {
if (!task.getParentId().isPresent()) {
if (!task.getParentId().isPresent() && task.getState() == TaskStateCode.SUCCESS) {
throw new IllegalArgumentException("Resuming successfully completed attempts is not supported");
}
return task.getId();
})
.collect(Collectors.toList());

return ImmutableList.copyOf(successTasks);
return ImmutableList.copyOf(ids);
}

private List<Long> collectResumingTasksForResumeFromMode(long attemptId, String fromTaskPattern)
Expand Down

0 comments on commit 2ca6c4e

Please sign in to comment.