Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix resuming subtasks #90

Draft
wants to merge 4 commits into
base: v0.10.5_patched
Choose a base branch
from
Draft
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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()))
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

resumeするtaskをSUCCESSのみから変更。
参照: SUCCESSのみが取得対象

.map(task -> {
if (!task.getParentId().isPresent()) {
if (!task.getParentId().isPresent() && task.getState() == TaskStateCode.SUCCESS) {
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

すでに成功したattemptのresumeは禁止されているため、L310のfilterの変更に合わせて修正。
!task.getParentId().isPresent() は「parentIdがないtask = rootTask」のこと。
(rootTaskがSUCCESS = attemptも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