本文整理了Java中hudson.model.Executor.getCurrentWorkUnit()
方法的一些代码示例,展示了Executor.getCurrentWorkUnit()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Executor.getCurrentWorkUnit()
方法的具体详情如下:
包路径:hudson.model.Executor
类名称:Executor
方法名:getCurrentWorkUnit
[英]Returns the current WorkUnit (of #getCurrentExecutable()) that this executor is running.
[中]返回此执行器正在运行的当前工作单元(属于#getCurrentExecutable())。
代码示例来源:origin: jenkinsci/jenkins
/**
* Called when the executor actually starts executing the assigned work unit.
*
* This moves the task from the pending state to the "left the queue" state.
*/
/*package*/ void onStartExecuting(Executor exec) throws InterruptedException {
lock.lock();
try { try {
final WorkUnit wu = exec.getCurrentWorkUnit();
pendings.remove(wu.context.item);
LeftItem li = new LeftItem(wu.context);
li.enter(this);
} finally { updateSnapshot(); } } finally {
lock.unlock();
}
}
代码示例来源:origin: jenkinsci/jenkins
@Override
protected void onCriteriaMet() {
// on behalf of the member Executors,
// the one that executes the main thing will send notifications
// Unclear if this will work with AsynchronousExecution; it *seems* this is only called from synchronize which is only called from synchronizeStart which is only called from an executor thread.
Executor e = Executor.currentExecutor();
if (e.getCurrentWorkUnit().isMainWork()) {
e.getOwner().taskAccepted(e,task);
}
}
};
代码示例来源:origin: jenkinsci/jenkins
/**
* All the {@link Executor}s that jointly execute a {@link Task} call this method to synchronize on the start.
*/
public void synchronizeStart() throws InterruptedException {
startLatch.synchronize();
// the main thread will send a notification
Executor e = Executor.currentExecutor();
WorkUnit wu = e.getCurrentWorkUnit();
if (wu.isMainWork()) {
future.start.set(e.getCurrentExecutable());
}
}
代码示例来源:origin: jenkinsci/jenkins
public Builder with(@CheckForNull Computer computer) {
if (computer == null) {
return this;
}
if (computer.isOnline()) {
final List<Executor> executors = computer.getExecutors();
final boolean acceptingTasks = computer.isAcceptingTasks();
for (Executor e : executors) {
definedExecutors++;
onlineExecutors++;
if (e.getCurrentWorkUnit() != null) {
busyExecutors++;
} else {
idleExecutors++;
if (acceptingTasks) availableExecutors++;
}
}
} else {
final int numExecutors = computer.getNumExecutors();
definedExecutors += numExecutors;
if (computer.isConnecting()) {
connectingExecutors += numExecutors;
}
}
return this;
}
代码示例来源:origin: jenkinsci/jenkins
parked.put(e, new JobOffer(e));
final WorkUnit workUnit = e.getCurrentWorkUnit();
if (workUnit != null) {
lostPendings.remove(workUnit.context.item);
代码示例来源:origin: jenkinsci/jenkins
for (Computer c : Jenkins.getInstance().getComputers()) {
for (Executor e : c.getAllExecutors()) {
final WorkUnit workUnit = e.getCurrentWorkUnit();
final Executable executable = workUnit != null ? workUnit.getExecutable() : null;
final SubTask subtask = executable != null ? getParentOf(executable) : null;
代码示例来源:origin: jenkinsci/jenkins
/**
* All the {@link Executor}s that jointly execute a {@link Task} call this method to synchronize on the end of the task.
*
* @throws InterruptedException
* If any of the member thread is interrupted while waiting for other threads to join, all
* the member threads will report {@link InterruptedException}.
*/
public void synchronizeEnd(Executor e, Queue.Executable executable, Throwable problems, long duration) throws InterruptedException {
endLatch.synchronize();
// the main thread will send a notification
WorkUnit wu = e.getCurrentWorkUnit();
if (wu.isMainWork()) {
if (problems == null) {
future.set(executable);
e.getOwner().taskCompleted(e, task, duration);
} else {
future.set(problems);
e.getOwner().taskCompletedWithProblems(e, task, duration, problems);
}
}
}
代码示例来源:origin: org.jenkins-ci.plugins/metrics
public void addAction(Run run) {
Executor executor = run.getExecutor();
if (executor == null) {
return;
}
WorkUnit workUnit = executor.getCurrentWorkUnit();
if (workUnit == null) {
return;
}
WorkUnitContext context = workUnit.context;
if (context == null) {
return;
}
TimeInQueueAction action;
synchronized (actions) {
action = actions.remove(context);
}
if (action != null) {
run.addAction(action);
}
}
代码示例来源:origin: org.jenkins-ci.main/jenkins-core
/**
* Called when the executor actually starts executing the assigned work unit.
*
* This moves the task from the pending state to the "left the queue" state.
*/
/*package*/ void onStartExecuting(Executor exec) throws InterruptedException {
lock.lock();
try { try {
final WorkUnit wu = exec.getCurrentWorkUnit();
pendings.remove(wu.context.item);
LeftItem li = new LeftItem(wu.context);
li.enter(this);
} finally { updateSnapshot(); } } finally {
lock.unlock();
}
}
代码示例来源:origin: org.jvnet.hudson.main/hudson-core
@Override
protected void onCriteriaMet() {
// on behalf of the member Executors,
// the one that executes the main thing will send notifications
Executor e = Executor.currentExecutor();
if (e.getCurrentWorkUnit().isMainWork()) {
e.getOwner().taskAccepted(e,task);
}
}
};
代码示例来源:origin: org.eclipse.hudson/hudson-core
@Override
protected void onCriteriaMet() {
// on behalf of the member Executors,
// the one that executes the main thing will send notifications
Executor e = Executor.currentExecutor();
if (e.getCurrentWorkUnit().isMainWork()) {
e.getOwner().taskAccepted(e, task);
}
}
};
代码示例来源:origin: org.jenkins-ci.main/jenkins-core
@Override
protected void onCriteriaMet() {
// on behalf of the member Executors,
// the one that executes the main thing will send notifications
// Unclear if this will work with AsynchronousExecution; it *seems* this is only called from synchronize which is only called from synchronizeStart which is only called from an executor thread.
Executor e = Executor.currentExecutor();
if (e.getCurrentWorkUnit().isMainWork()) {
e.getOwner().taskAccepted(e,task);
}
}
};
代码示例来源:origin: hudson/hudson-2.x
@Override
protected void onCriteriaMet() {
// on behalf of the member Executors,
// the one that executes the main thing will send notifications
Executor e = Executor.currentExecutor();
if (e.getCurrentWorkUnit().isMainWork()) {
e.getOwner().taskAccepted(e,task);
}
}
};
代码示例来源:origin: org.eclipse.hudson.main/hudson-core
@Override
protected void onCriteriaMet() {
// on behalf of the member Executors,
// the one that executes the main thing will send notifications
Executor e = Executor.currentExecutor();
if (e.getCurrentWorkUnit().isMainWork()) {
e.getOwner().taskAccepted(e,task);
}
}
};
代码示例来源:origin: org.jenkins-ci.main/jenkins-core
/**
* All the {@link Executor}s that jointly execute a {@link Task} call this method to synchronize on the start.
*/
public void synchronizeStart() throws InterruptedException {
startLatch.synchronize();
// the main thread will send a notification
Executor e = Executor.currentExecutor();
WorkUnit wu = e.getCurrentWorkUnit();
if (wu.isMainWork()) {
future.start.set(e.getCurrentExecutable());
}
}
代码示例来源:origin: groupon/DotCi
@Override
protected DynamicSubBuild newBuild() throws IOException {
final List<Action> actions = Executor.currentExecutor().getCurrentWorkUnit().context.actions;
DynamicBuild parentBuild = getParent().getLastBuild();
CauseAction causeAction = null;
for (final Action a : actions) {
if (a instanceof ParentBuildAction) {
parentBuild = ((ParentBuildAction) a).getParent();
}
if (a instanceof CauseAction) {
causeAction = (CauseAction) a;
}
}
final DynamicSubBuild newBuild = new DynamicSubBuild(this, parentBuild.getCause(), parentBuild.getNumber());
newBuild.save();
return newBuild;
}
代码示例来源:origin: org.jenkins-ci.main/jenkins-core
/**
* All the {@link Executor}s that jointly execute a {@link Task} call this method to synchronize on the end of the task.
*
* @throws InterruptedException
* If any of the member thread is interrupted while waiting for other threads to join, all
* the member threads will report {@link InterruptedException}.
*/
public void synchronizeEnd(Executor e, Queue.Executable executable, Throwable problems, long duration) throws InterruptedException {
endLatch.synchronize();
// the main thread will send a notification
WorkUnit wu = e.getCurrentWorkUnit();
if (wu.isMainWork()) {
if (problems == null) {
future.set(executable);
e.getOwner().taskCompleted(e, task, duration);
} else {
future.set(problems);
e.getOwner().taskCompletedWithProblems(e, task, duration, problems);
}
}
}
代码示例来源:origin: hudson/hudson-2.x
/**
* All the {@link Executor}s that jointly execute a {@link Task} call this method to synchronize on the end of the task.
*
* @throws InterruptedException
* If any of the member thread is interrupted while waiting for other threads to join, all
* the member threads will report {@link InterruptedException}.
*/
public void synchronizeEnd(Queue.Executable executable, Throwable problems, long duration) throws InterruptedException {
endLatch.synchronize();
// the main thread will send a notification
Executor e = Executor.currentExecutor();
WorkUnit wu = e.getCurrentWorkUnit();
if (wu.isMainWork()) {
if (problems == null) {
future.set(executable);
e.getOwner().taskCompleted(e, task, duration);
} else {
future.set(problems);
e.getOwner().taskCompletedWithProblems(e, task, duration, problems);
}
}
}
代码示例来源:origin: org.jvnet.hudson.main/hudson-core
/**
* All the {@link Executor}s that jointly execute a {@link Task} call this method to synchronize on the end of the task.
*
* @throws InterruptedException
* If any of the member thread is interrupted while waiting for other threads to join, all
* the member threads will report {@link InterruptedException}.
*/
public void synchronizeEnd(Queue.Executable executable, Throwable problems, long duration) throws InterruptedException {
endLatch.synchronize();
// the main thread will send a notification
Executor e = Executor.currentExecutor();
WorkUnit wu = e.getCurrentWorkUnit();
if (wu.isMainWork()) {
if (problems == null) {
future.set(executable);
e.getOwner().taskCompleted(e, task, duration);
} else {
future.set(problems);
e.getOwner().taskCompletedWithProblems(e, task, duration, problems);
}
}
}
代码示例来源:origin: jenkinsci/workflow-cps-plugin
private static void assertNoTasksRunning(Jenkins j) {
j.getQueue().maintain();
assert j.getQueue().isEmpty();
Computer[] computerList = j.getComputers();
for (Computer c : computerList) {
List<Executor> executors = c.getExecutors();
for (Executor ex : executors) {
if (ex.isBusy()) {
Assert.fail("Computer "+c+" has an Executor "+ex+" still running a task: "+ex.getCurrentWorkUnit());
}
}
}
}
内容来源于网络,如有侵权,请联系作者删除!