Class GeneralNonBlockingStepExecution
- java.lang.Object
-
- org.jenkinsci.plugins.workflow.steps.StepExecution
-
- org.jenkinsci.plugins.workflow.steps.GeneralNonBlockingStepExecution
-
- All Implemented Interfaces:
Serializable
public abstract class GeneralNonBlockingStepExecution extends StepExecution
Generalization ofSynchronousNonBlockingStepExecution
that can be used for block-scoped steps. The step may at any given time either be running CPS VM code, running background code, or waiting for events (for example running a block).- See Also:
- Serialized Form
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description protected static interface
GeneralNonBlockingStepExecution.Block
Block to be passed toGeneralNonBlockingStepExecution.Block.run()
.protected class
GeneralNonBlockingStepExecution.TailCall
-
Constructor Summary
Constructors Modifier Constructor Description protected
GeneralNonBlockingStepExecution(StepContext context)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description boolean
blocksRestart()
Allows a step to indicate thatAsynchronousExecution.blocksRestart()
should be true.String
getStatus()
May be overridden to provide specific information about what a step is currently doing, for diagnostic purposes.void
onResume()
Called whenStepExecution
is brought back into memory after restart.protected void
run(GeneralNonBlockingStepExecution.Block block)
Initiate background work that should not block the CPS VM thread.void
stop(Throwable cause)
If the computation is going synchronously, try to cancel that.-
Methods inherited from class org.jenkinsci.plugins.workflow.steps.StepExecution
applyAll, applyAll, getContext, getStatusBounded, start
-
-
-
-
Constructor Detail
-
GeneralNonBlockingStepExecution
protected GeneralNonBlockingStepExecution(StepContext context)
-
-
Method Detail
-
run
protected final void run(GeneralNonBlockingStepExecution.Block block)
Initiate background work that should not block the CPS VM thread. Call this from a CPS VM thread, such as fromStepExecution.start()
orBodyExecutionCallback.onSuccess(org.jenkinsci.plugins.workflow.steps.StepContext, java.lang.Object)
. The block may finish by callingBodyInvoker.start()
,StepContext.onSuccess(java.lang.Object)
, etc.- Parameters:
block
- some code to run in a utility thread
-
stop
public void stop(Throwable cause) throws Exception
If the computation is going synchronously, try to cancel that.- Overrides:
stop
in classStepExecution
- Parameters:
cause
- Contextual information that lets the step know what resulted in stopping an executing step, passed in the hope that this will assist diagnostics.- Throws:
Exception
-
onResume
public void onResume()
Description copied from class:StepExecution
Called whenStepExecution
is brought back into memory after restart. Convenient for re-establishing the polling.Currently not permitted to throw exceptions, but may report errors via
FutureCallback.onFailure(java.lang.Throwable)
.- Overrides:
onResume
in classStepExecution
- See Also:
SynchronousResumeNotSupportedException
-
getStatus
@NonNull public String getStatus()
Description copied from class:StepExecution
May be overridden to provide specific information about what a step is currently doing, for diagnostic purposes. Typical format should be a short, lowercase phrase. It should not be localized as this is intended for use by developers as well as users. May include technical details about Jenkins internals if relevant.- Overrides:
getStatus
in classStepExecution
- Returns:
- current status, or null if unimplemented
- See Also:
StepExecution.getStatusBounded(long, java.util.concurrent.TimeUnit)
-
blocksRestart
public boolean blocksRestart()
Description copied from class:StepExecution
Allows a step to indicate thatAsynchronousExecution.blocksRestart()
should be true. Typically this would be true ifStepExecution.getStatus()
indicates that the step is in the middle of something active, as opposed to waiting for an external event or a body to complete.Note that activity in the CPS VM thread automatically blocks restart, so overriding this is only necessary for steps using a background thread, such as
SynchronousNonBlockingStepExecution
orGeneralNonBlockingStepExecution
.- Overrides:
blocksRestart
in classStepExecution
- Returns:
- false by default
-
-