SubTask -> Task traversal and additional bug fix

git-svn-id: https://hudson.dev.java.net/svn/hudson/trunk/hudson/main@34613 71c3de6d-444a-0410-be80-ed276b4c234a
This commit is contained in:
kohsuke committed 2010-09-09 22:26:49 +00:00
1 parent eedac7b0fc
commit 0cee4ef199
5 files changed
+25 -2

No files matched your search

@@ -41,6 +41,7 @@ import hudson.model.Cause.UserCause;
import hudson.model.Descriptor.FormException;
import hudson.model.Fingerprint.RangeSet;
import hudson.model.Queue.Executable;
import hudson.model.Queue.Task;
import hudson.model.queue.SubTask;
import hudson.model.Queue.WaitingItem;
import hudson.model.RunMap.Constructor;
@@ -920,6 +921,10 @@ public abstract class AbstractProject<P extends AbstractProject<P,R>,R extends A
return this; // in this way, any member that wants to run with the main guy can nominate the project itself
}
public final Task getOwnerTask() {
return this;
}
/**
* {@inheritDoc}
*
@@ -344,7 +344,7 @@ public class Executor extends Thread implements ModelObject {
public void doStop( StaplerRequest req, StaplerResponse rsp ) throws IOException, ServletException {
Queue.Executable e = executable;
if(e!=null) {
e.getParent().checkAbortPermission();
e.getParent().getOwnerTask().checkAbortPermission();
interrupt();
}
rsp.forwardToPreviousPage(req);
@@ -355,7 +355,7 @@ public class Executor extends Thread implements ModelObject {
*/
public boolean hasStopPermission() {
Queue.Executable e = executable;
return e!=null && e.getParent().hasAbortPermission();
return e!=null && e.getParent().getOwnerTask().hasAbortPermission();
}
public Computer getOwner() {
@@ -25,6 +25,7 @@
package hudson.model.queue;
import hudson.model.Queue;
import hudson.model.Queue.Task;
import java.util.Collection;
import java.util.Collections;
@@ -40,4 +41,8 @@ public abstract class AbstractQueueTask implements Queue.Task {
public Collection<? extends SubTask> getSubTasks() {
return Collections.emptyList();
}
public final Task getOwnerTask() {
return this;
}
}
@@ -110,4 +110,12 @@ public abstract class QueueTaskFilter implements Queue.Task {
public Collection<? extends SubTask> getSubTasks() {
return base.getSubTasks();
}
public final Task getOwnerTask() {
return this;
}
public Object getSameNodeConstraint() {
return base.getSameNodeConstraint();
}
}
@@ -72,6 +72,11 @@ public interface SubTask extends ResourceActivity {
*/
Executable createExecutable() throws IOException;
/**
* Gets the {@link Task} that this subtask belongs to.
*/
Task getOwnerTask();
/**
* If a subset of {@link SubTask}s of a {@link Task} needs to be collocated with other {@link SubTask}s,
* those {@link SubTask}s should return the equal object here. If null, the execution unit isn't under a