public abstract class AsynchronousExecution extends RuntimeException
Executor
).
May be thrown from 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 |
setExecutor(Executor executor) |
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.
public final Executor getExecutor()
@Restricted(value=org.kohsuke.accmod.restrictions.NoExternalUse.class) public final void setExecutor(Executor 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 Executable#run
, as per ExecutorListener#taskCompletedWithProblems
Copyright © 2016. All rights reserved.