Skip to content
This repository has been archived by the owner on Dec 15, 2021. It is now read-only.

Commit

Permalink
[JENKINS-22941] AsynchronousExecution.blocksRestart
Browse files Browse the repository at this point in the history
  • Loading branch information
jglick committed Mar 24, 2015
1 parent ae24ba1 commit 285b450
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 5 deletions.
Expand Up @@ -78,7 +78,7 @@
import jenkins.model.Jenkins;
import jenkins.model.lazy.BuildReference;
import jenkins.model.lazy.LazyBuildMixIn;
import jenkins.model.queue.Executable2;
import jenkins.model.queue.AsynchronousExecution;
import jenkins.util.Timer;
import org.jenkinsci.plugins.workflow.actions.LogAction;
import org.jenkinsci.plugins.workflow.flow.FlowDefinition;
Expand All @@ -96,7 +96,7 @@

@SuppressWarnings("SynchronizeOnNonFinalField")
@edu.umd.cs.findbugs.annotations.SuppressWarnings("JLM_JSR166_UTILCONCURRENT_MONITORENTER") // completed is an unusual usage
public final class WorkflowRun extends Run<WorkflowJob,WorkflowRun> implements Executable2, LazyBuildMixIn.LazyLoadingRun<WorkflowJob,WorkflowRun> {
public final class WorkflowRun extends Run<WorkflowJob,WorkflowRun> implements Queue.Executable, LazyBuildMixIn.LazyLoadingRun<WorkflowJob,WorkflowRun> {

private static final Logger LOGGER = Logger.getLogger(WorkflowRun.class.getName());

Expand Down Expand Up @@ -212,6 +212,11 @@ private AsynchronousExecution sleep() {
}
getExecutor().recordCauseOfInterruption(WorkflowRun.this, listener);
}
@Override public boolean blocksRestart() {
// TODO check whether the CPS VM thread is active
// (and make it stop scheduling things when Jenkins.isQuietingDown())
return false;
}
};
final AtomicReference<ScheduledFuture<?>> copyLogsTask = new AtomicReference<ScheduledFuture<?>>();
copyLogsTask.set(Timer.get().scheduleAtFixedRate(new Runnable() {
Expand Down
Expand Up @@ -36,6 +36,7 @@
import java.util.logging.Logger;
import javax.annotation.CheckForNull;
import jenkins.model.Jenkins;
import jenkins.model.queue.AsynchronousExecution;
import jenkins.util.Timer;
import org.acegisecurity.Authentication;
import org.jenkinsci.plugins.durabletask.executors.ContinuableExecutable;
Expand All @@ -54,7 +55,6 @@
import static java.util.logging.Level.*;
import javax.annotation.Nonnull;
import javax.annotation.Nullable;
import jenkins.model.queue.Executable2;

public class ExecutorStepExecution extends AbstractStepExecutionImpl {

Expand Down Expand Up @@ -135,7 +135,7 @@ public void stop(Throwable cause) {
private static final class RunningTask {
final @Nonnull StepContext context;
/** null until placeholder executable runs */
@Nullable Executable2.AsynchronousExecution execution;
@Nullable AsynchronousExecution execution;
/** null until placeholder executable runs */
@Nullable Launcher launcher;
RunningTask(StepContext context) {
Expand Down Expand Up @@ -389,7 +389,7 @@ private static final class Callback extends BodyExecutionCallback {
/**
* Occupies {@link Executor} while workflow uses this slave.
*/
private final class PlaceholderExecutable implements ContinuableExecutable, Executable2 {
private final class PlaceholderExecutable implements ContinuableExecutable {

@Override public void run() {
final TaskListener listener;
Expand Down Expand Up @@ -464,6 +464,9 @@ private final class PlaceholderExecutable implements ContinuableExecutable, Exec
// TODO save the BodyExecution somehow and call .cancel() here; currently you need to Executor.doStop the WorkflowRun as a whole, which is inconvenient
super.getExecutor().recordCauseOfInterruption(r, listener);
}
@Override public boolean blocksRestart() {
return false;
}
};
throw runningTask.execution;
}
Expand Down

0 comments on commit 285b450

Please sign in to comment.