use of hudson.model.queue.SubTask in project hudson-2.x by hudson.
the class AbstractProject method getSubTasks.
public List<SubTask> getSubTasks() {
List<SubTask> r = new ArrayList<SubTask>();
r.add(this);
for (SubTaskContributor euc : SubTaskContributor.all()) r.addAll(euc.forProject(this));
for (JobProperty<? super P> p : getAllProperties()) r.addAll(p.getSubTasks());
return r;
}
use of hudson.model.queue.SubTask in project hudson-2.x by hudson.
the class Executor method run.
@Override
public void run() {
// run as the system user. see ACL.SYSTEM for more discussion about why this is somewhat broken
SecurityContextHolder.getContext().setAuthentication(ACL.SYSTEM);
try {
finishTime = System.currentTimeMillis();
while (shouldRun()) {
executable = null;
workUnit = null;
synchronized (owner) {
if (owner.getNumExecutors() < owner.getExecutors().size()) {
// we've got too many executors.
owner.removeExecutor(this);
return;
}
}
// see issue #1583
if (Thread.interrupted())
continue;
if (induceDeath)
throw new ThreadDeath();
SubTask task;
try {
// perform this state change as an atomic operation wrt other queue operations
synchronized (queue) {
workUnit = grabJob();
workUnit.setExecutor(this);
task = workUnit.work;
startTime = System.currentTimeMillis();
executable = task.createExecutable();
}
} catch (IOException e) {
LOGGER.log(Level.SEVERE, "Executor threw an exception", e);
continue;
} catch (InterruptedException e) {
continue;
}
Throwable problems = null;
final String threadName = getName();
try {
workUnit.context.synchronizeStart();
if (executable instanceof Actionable) {
for (Action action : workUnit.context.actions) {
((Actionable) executable).addAction(action);
}
}
setName(threadName + " : executing " + executable.toString());
queue.execute(executable, task);
} 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
LOGGER.log(Level.SEVERE, "Executor threw an exception", e);
workUnit.context.abort(e);
problems = e;
} finally {
setName(threadName);
finishTime = System.currentTimeMillis();
try {
workUnit.context.synchronizeEnd(executable, problems, finishTime - startTime);
} catch (InterruptedException e) {
workUnit.context.abort(e);
continue;
} finally {
workUnit.setExecutor(null);
}
}
}
} catch (RuntimeException e) {
causeOfDeath = e;
throw e;
} catch (Error e) {
causeOfDeath = e;
throw e;
}
}
Aggregations