提交 1c5e8843 编写于 作者: K kohsuke

exposing executors to the remote API.

git-svn-id: https://hudson.dev.java.net/svn/hudson/trunk/hudson/main@10609 71c3de6d-444a-0410-be80-ed276b4c234a
上级 369d5bf6
......@@ -133,6 +133,7 @@ public abstract class Computer extends AbstractModelObject implements AccessCont
* for {@link #executors} to have a larger number than this.
*/
// ugly name to let EL access this
@Exported
public int getNumExecutors() {
return numExecutors;
}
......@@ -301,6 +302,7 @@ public abstract class Computer extends AbstractModelObject implements AccessCont
/**
* Gets the read-only snapshot view of all {@link Executor}s.
*/
@Exported
public List<Executor> getExecutors() {
return new ArrayList<Executor>(executors);
}
......@@ -308,6 +310,7 @@ public abstract class Computer extends AbstractModelObject implements AccessCont
/**
* Returns true if all the executors of this computer is idle.
*/
@Exported
public final boolean isIdle() {
for (Executor e : executors)
if(!e.isIdle())
......
......@@ -4,6 +4,8 @@ import hudson.Util;
import hudson.security.ACL;
import org.kohsuke.stapler.StaplerRequest;
import org.kohsuke.stapler.StaplerResponse;
import org.kohsuke.stapler.export.ExportedBean;
import org.kohsuke.stapler.export.Exported;
import org.acegisecurity.context.SecurityContextHolder;
import javax.servlet.ServletException;
......@@ -17,6 +19,7 @@ import java.util.logging.Level;
*
* @author Kohsuke Kawaguchi
*/
@ExportedBean
public class Executor extends Thread implements ModelObject {
private final Computer owner;
private final Queue queue;
......@@ -133,6 +136,7 @@ public class Executor extends Thread implements ModelObject {
* @return
* a sequential number starting from 0.
*/
@Exported
public int getNumber() {
return number;
}
......@@ -140,6 +144,7 @@ public class Executor extends Thread implements ModelObject {
/**
* Returns true if this {@link Executor} is ready for action.
*/
@Exported
public boolean isIdle() {
return executable==null;
}
......@@ -160,6 +165,7 @@ public class Executor extends Thread implements ModelObject {
* @return -1
* if it's impossible to estimate the progress.
*/
@Exported
public int getProgress() {
Queue.Executable e = executable;
if(e==null) return -1;
......@@ -188,6 +194,23 @@ public class Executor extends Thread implements ModelObject {
return Util.getTimeSpanString(eta);
}
/**
* The same as {@link #getEstimatedRemainingTime()} but return
* it as a number of milli-seconds.
*/
public long getEstimatedRemainingTimeMillis() {
Queue.Executable e = executable;
if(e==null) return -1;
long d = e.getParent().getEstimatedDuration();
if(d<0) return -1;
long eta = d-(System.currentTimeMillis()-startTime);
if(eta<=0) return -1;
return eta;
}
/**
* Stops the current build.
*/
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册