提交 3b00d9cc 编写于 作者: K kohsuke

bug fix. executor list was not displaying things correctly.


git-svn-id: https://hudson.dev.java.net/svn/hudson/trunk/hudson/main@3184 71c3de6d-444a-0410-be80-ed276b4c234a
上级 9b047a87
......@@ -39,7 +39,7 @@ import java.util.ArrayList;
* @author Kohsuke Kawaguchi
* @see AbstractProject
*/
public abstract class AbstractBuild<P extends AbstractProject<P,R>,R extends AbstractBuild<P,R>> extends Run<P,R> implements Runnable {
public abstract class AbstractBuild<P extends AbstractProject<P,R>,R extends AbstractBuild<P,R>> extends Run<P,R> implements Queue.Executable {
/**
* PluginName of the slave this project was built on.
......
......@@ -314,8 +314,8 @@ public abstract class AbstractProject<P extends AbstractProject<P,R>,R extends A
return duration;
}
public void execute() throws IOException {
newBuild().run();
public R createExecutable() throws IOException {
return newBuild();
}
public boolean checkout(AbstractBuild build, Launcher launcher, BuildListener listener, File changelogFile) throws IOException {
......
......@@ -17,14 +17,13 @@ public class Executor extends Thread {
private final Computer owner;
private final Queue queue;
private Queue.Task task;
private long startTime;
/**
* Executor number that identifies it among other executors for the same {@link Computer}.
*/
private int number;
private Queue.Executable executable;
public Executor(Computer owner) {
super("Executor #"+owner.getExecutors().size()+" for "+owner.getDisplayName());
......@@ -47,6 +46,7 @@ public class Executor extends Thread {
}
}
Queue.Task task;
try {
task = queue.pop();
} catch (InterruptedException e) {
......@@ -55,14 +55,15 @@ public class Executor extends Thread {
try {
startTime = System.currentTimeMillis();
task.execute();
executable = task.createExecutable();
executable.run();
} catch (Throwable e) {
// for some reason the executor died. this is really
// a bug in the code, but we don't want the executor to die,
// so just leave some info and go on to build other things
e.printStackTrace();
}
task = null;
executable = null;
}
}
......@@ -72,8 +73,8 @@ public class Executor extends Thread {
* @return
* null if the executor is idle.
*/
public Queue.Task getCurrentTask() {
return task;
public Queue.Executable getCurrentExecutable() {
return executable;
}
/**
......@@ -91,7 +92,7 @@ public class Executor extends Thread {
* Returns true if this {@link Executor} is ready for action.
*/
public boolean isIdle() {
return task==null;
return executable==null;
}
/**
......@@ -101,7 +102,7 @@ public class Executor extends Thread {
* if it's impossible to estimate the progress.
*/
public int getProgress() {
long d = task.getEstimatedDuration();
long d = executable.getParent().getEstimatedDuration();
if(d<0) return -1;
int num = (int)((System.currentTimeMillis()-startTime)*100/d);
......@@ -114,7 +115,7 @@ public class Executor extends Thread {
* until the build completes.
*/
public String getEstimatedRemainingTime() {
long d = task.getEstimatedDuration();
long d = executable.getParent().getEstimatedDuration();
if(d<0) return "N/A";
long eta = d-(System.currentTimeMillis()-startTime);
......
......@@ -506,7 +506,19 @@ public class Queue {
*/
long getEstimatedDuration();
void execute() throws IOException;
Executable createExecutable() throws IOException;
}
public interface Executable extends Runnable {
/**
* Task from which this executable was created.
*/
Task getParent();
/**
* Called by {@link Executor} to perform the task
*/
void run();
}
/**
......
......@@ -209,7 +209,7 @@ public abstract class Run <JobT extends Job<JobT,RunT>,RunT extends Run<JobT,Run
public Executor getExecutor() {
for( Computer c : Hudson.getInstance().getComputers() ) {
for (Executor e : c.getExecutors()) {
if(e.getCurrentTask()==getParent())
if(e.getCurrentExecutable()==this)
return e;
}
}
......
......@@ -52,8 +52,8 @@
</j:when>
<j:otherwise>
<td class="pane" width="70%">
<div nowrap="true">Building <a href="${rootURL}/${e.currentTask.url}">${e.currentTask}</a></div>
<t:buildProgressBar build="${e.currentTask}"/>
<div nowrap="true">Building <a href="${rootURL}/${e.currentExecutable.url}">${e.currentExecutable}</a></div>
<t:buildProgressBar build="${e.currentExecutable}"/>
</td>
<td class="pane" width="16" align="center" valign="middle">
<l:isAdmin>
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册