public abstract class AsynchronousExecution extends RuntimeException
Executor
).
May be thrown from Queue.Executable.run()
after doing any preparatory work synchronously.
Executor.isActive()
will remain true (even though Thread.isAlive()
is not) until completed(java.lang.Throwable)
is called.
The thrower will need to hold on to a reference to this instance as a handle to call completed(java.lang.Throwable)
.
The execution may not extend into another Jenkins session; if you wish to model a long-running execution, you must schedule a new task after restart. This class is not serializable anyway.
Mainly intended for use with OneOffExecutor
(from a Queue.FlyweightTask
), of which there could be many,
but could also be used with a heavyweight executor even though the number of executors is bounded by node configuration.
ResourceController
/ResourceActivity
/ResourceList
/Resource
are not currently supported.
Nor are Queue.Task.getSubTasks()
other than the primary task.
Modifier | Constructor and Description |
---|---|
protected |
AsynchronousExecution()
Constructor for subclasses.
|
Modifier and Type | Method and Description |
---|---|
abstract boolean |
blocksRestart()
Allows an executable to indicate whether it is currently doing something which should prevent Jenkins from being shut down safely.
|
void |
completed(Throwable error)
To be called when the task is actually complete.
|
abstract boolean |
displayCell()
Allows an executable to control whether or not to display
executorCell.jelly . |
Executor |
getExecutor()
Obtains the associated executor.
|
abstract void |
interrupt(boolean forShutdown)
Called in lieu of
Thread.interrupt() by Executor.interrupt() and its overloads. |
void |
maybeComplete()
If there is a pending completion notification, deliver it to the executor.
|
void |
setExecutorWithoutCompleting(Executor executor)
Set the executor without notifying it about task completion.
|
addSuppressed, fillInStackTrace, getCause, getLocalizedMessage, getMessage, getStackTrace, getSuppressed, initCause, printStackTrace, printStackTrace, printStackTrace, setStackTrace, toString
protected AsynchronousExecution()
public abstract void interrupt(boolean forShutdown)
Thread.interrupt()
by Executor.interrupt()
and its overloads.
As with the standard Java method, you are requested to cease work as soon as possible, but there is no enforcement of this.
You might also want to call Executor.recordCauseOfInterruption(hudson.model.Run<?, ?>, hudson.model.TaskListener)
on getExecutor()
.forShutdown
- if true, this interruption is because Jenkins is shutting down (and thus Computer.interrupt()
was called from Jenkins.cleanUp()
); otherwise, a normal interrupt such as by Executor.doStop()
public abstract boolean blocksRestart()
interrupt(boolean)
will be passed forShutdown=true
.)RestartListener.Default.isReadyToRestart()
public abstract boolean displayCell()
executorCell.jelly
.
If this method returns false, the asynchronous execution becomes invisible from UI.
@CheckForNull public final Executor getExecutor()
null
if setExecutorWithoutCompleting(hudson.model.Executor)
has not been called yet.@Restricted(value=org.kohsuke.accmod.restrictions.NoExternalUse.class) public final void setExecutorWithoutCompleting(@NonNull Executor executor)
maybeComplete()
after releasing any problematic locks.@Restricted(value=org.kohsuke.accmod.restrictions.NoExternalUse.class) public final void maybeComplete()
setExecutorWithoutCompleting(Executor)
.public final void completed(@CheckForNull Throwable error)
error
- normally null (preferable to handle errors yourself), but may be specified to simulate an exception from Queue.Executable.run()
, as per ExecutorListener.taskCompletedWithProblems(hudson.model.Executor, hudson.model.Queue.Task, long, java.lang.Throwable)
Copyright © 2004–2021. All rights reserved.