提交 a8ed6647 编写于 作者: K Kohsuke Kawaguchi

A Trigger timer thread is used for many things, so its execution can delay significantly.

Use our own queue
上级 2c976142
......@@ -93,6 +93,7 @@ import java.util.NoSuchElementException;
import java.util.Set;
import java.util.Timer;
import java.util.TreeSet;
import java.util.concurrent.Callable;
import java.util.concurrent.TimeUnit;
import java.util.concurrent.atomic.AtomicInteger;
import java.util.concurrent.Future;
......@@ -106,6 +107,7 @@ import javax.servlet.ServletException;
import jenkins.model.Jenkins;
import jenkins.security.QueueItemAuthenticator;
import jenkins.security.QueueItemAuthenticatorConfiguration;
import jenkins.util.AtmostOneTaskExecutor;
import org.acegisecurity.AccessDeniedException;
import org.acegisecurity.Authentication;
import org.kohsuke.stapler.HttpResponse;
......@@ -246,6 +248,7 @@ public class Queue extends ResourceController implements Saveable {
this.workUnit = p;
assert executor.isParking();
executor.start(workUnit);
// LOGGER.info("Starting "+executor.getName());
}
@Override
......@@ -295,6 +298,14 @@ public class Queue extends ResourceController implements Saveable {
private volatile transient QueueSorter sorter;
private transient final AtmostOneTaskExecutor<Void> maintainerThread = new AtmostOneTaskExecutor<Void>(new Callable<Void>() {
@Override
public Void call() throws Exception {
maintain();
return null;
}
});
public Queue(LoadBalancer loadBalancer) {
this.loadBalancer = loadBalancer.sanitize();
// if all the executors are busy doing something, then the queue won't be maintained in
......@@ -910,7 +921,8 @@ public class Queue extends ResourceController implements Saveable {
* This wakes up one {@link Executor} so that it will maintain a queue.
*/
public void scheduleMaintenance() {
new MaintainTask(this).once();
// LOGGER.info("Scheduling maintenance");
maintainerThread.submit();
}
/**
......@@ -1073,6 +1085,7 @@ public class Queue extends ResourceController implements Saveable {
}
private boolean makePending(BuildableItem p) {
// LOGGER.info("Making "+p.task+" pending"); // REMOVE
p.isPending = true;
return pendings.add(p);
}
......@@ -1994,13 +2007,6 @@ public class Queue extends ResourceController implements Saveable {
}
}
private void once() {
Timer timer = Trigger.timer;
if (timer != null) {
timer.schedule(this,0);
}
}
protected void doRun() {
Queue q = queue.get();
if (q != null)
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册