@ExportedBean public class Executor extends Thread implements ModelObject
Executor
s start threads on-demand.
Callers should use isActive()
instead of Thread.isAlive()
.
Thread.State, Thread.UncaughtExceptionHandler
Modifier and Type | Field and Description |
---|---|
protected Computer |
owner |
MAX_PRIORITY, MIN_PRIORITY, NORM_PRIORITY
Modifier and Type | Method and Description |
---|---|
Result |
abortResult() |
void |
completedAsynchronous(Throwable error) |
static Executor |
currentExecutor()
Returns the executor of the current thread or null if current thread is not an executor.
|
org.kohsuke.stapler.HttpResponse |
doStop()
Stops the current build.
You can use doStopBuild(String) instead to ensure what will be
interrupted is actually what you want to interrupt. |
void |
doStop(org.kohsuke.stapler.StaplerRequest req,
org.kohsuke.stapler.StaplerResponse rsp)
Deprecated.
as of 1.489
Use
doStop() or doStopBuild(String) . |
org.kohsuke.stapler.HttpResponse |
doStopBuild(String runExtId)
Stops the current build, if matching the specified external id
(or no id is specified, or the current
Queue.Executable is not a Run ). |
org.kohsuke.stapler.HttpResponse |
doYank()
Deprecated.
now a no-op
|
Api |
getApi()
Exposes the executor to the remote API.
|
AsynchronousExecution |
getAsynchronousExecution()
If currently running in asynchronous mode, returns that handle.
|
Throwable |
getCauseOfDeath()
Deprecated.
no longer used
|
Collection<CauseOfInterruption> |
getCausesOfInterruption()
Returns causes of interruption.
|
Queue.Executable |
getCurrentExecutable()
Returns the current build this executor is running.
|
Queue.Executable |
getCurrentExecutableForApi()
Same as
getCurrentExecutable() but checks Item.READ . |
FilePath |
getCurrentWorkspace()
If current executable is
AbstractBuild ,
return the workspace that this executor is using, or null if the build hasn't gotten
to that point yet. |
WorkUnit |
getCurrentWorkUnit()
Returns the current
WorkUnit (of the current executable )
that this executor is running. |
String |
getDisplayName()
Human readable name of the Jenkins executor.
|
long |
getElapsedTime() |
static long |
getEstimatedDurationFor(Queue.Executable e)
Deprecated.
call
Queue.Executable.getEstimatedDuration() directly |
String |
getEstimatedRemainingTime()
Computes a human-readable text that shows the expected remaining time
until the build completes.
|
long |
getEstimatedRemainingTimeMillis()
The same as
getEstimatedRemainingTime() but return
it as a number of milli-seconds. |
long |
getIdleStartMilliseconds()
Returns when this executor started or should start being idle.
|
int |
getNumber()
Gets the executor number that uniquely identifies it among
other
Executor s for the same computer. |
Computer |
getOwner() |
int |
getProgress()
Returns the progress of the current build in the number between 0-100.
|
long |
getTimeSpentInQueue()
Returns the number of milli-seconds the currently executing job spent in the queue
waiting for an available executor.
|
String |
getTimestampString()
Gets the string that says how long since this build has started.
|
boolean |
hasStopPermission()
Checks if the current user has a permission to stop this build.
|
void |
interrupt() |
void |
interrupt(Result result)
Interrupt the execution,
but instead of marking the build as aborted, mark it as specified result.
|
void |
interrupt(Result result,
CauseOfInterruption... causes)
Interrupt the execution.
|
boolean |
isActive()
Check if executor is ready to accept tasks.
|
boolean |
isBusy()
The opposite of
isIdle() — the executor is doing some work. |
boolean |
isDisplayCell()
If this executor is running an
AsynchronousExecution and that execution wants to hide the display
cell for the executor (because there is another executor displaying the job progress and we don't want to
confuse the user) then this method will return false to indicate to executors.jelly that
the executor cell should be hidden. |
boolean |
isIdle()
Returns true if this
Executor is ready for action. |
boolean |
isLikelyStuck()
Returns true if the current build is likely stuck.
|
boolean |
isParking()
Returns true if this executor is waiting for a task to execute.
|
<T> T |
newImpersonatingProxy(Class<T> type,
T core)
Creates a proxy object that executes the callee in the context that impersonates
this executor.
|
static Executor |
of(Queue.Executable executable)
Finds the executor currently running a given process.
|
void |
recordCauseOfInterruption(Run<?,?> build,
TaskListener listener)
report cause of interruption and record it to the build, if available.
|
void |
run() |
void |
start()
Can't start executor like you normally start a thread.
|
activeCount, checkAccess, clone, countStackFrames, currentThread, destroy, dumpStack, enumerate, getAllStackTraces, getContextClassLoader, getDefaultUncaughtExceptionHandler, getId, getName, getPriority, getStackTrace, getState, getThreadGroup, getUncaughtExceptionHandler, holdsLock, interrupted, isAlive, isDaemon, isInterrupted, join, join, join, resume, setContextClassLoader, setDaemon, setDefaultUncaughtExceptionHandler, setName, setPriority, setUncaughtExceptionHandler, sleep, sleep, stop, stop, suspend, toString, yield
@NonNull protected final Computer owner
public Executor(@NonNull Computer owner, int n)
public void interrupt(Result result)
public void interrupt(Result result, CauseOfInterruption... causes)
public Result abortResult()
public void recordCauseOfInterruption(Run<?,?> build, TaskListener listener)
@Restricted(value=org.kohsuke.accmod.restrictions.NoExternalUse.class) public void completedAsynchronous(@CheckForNull Throwable error)
@CheckForNull public Queue.Executable getCurrentExecutable()
@Exported(name="currentExecutable") @Restricted(value=org.kohsuke.accmod.restrictions.DoNotUse.class) public Queue.Executable getCurrentExecutableForApi()
getCurrentExecutable()
but checks Item.READ
.@NonNull public Collection<CauseOfInterruption> getCausesOfInterruption()
@CheckForNull public WorkUnit getCurrentWorkUnit()
WorkUnit
(of the current executable
)
that this executor is running.public FilePath getCurrentWorkspace()
AbstractBuild
,
return the workspace that this executor is using, or null if the build hasn't gotten
to that point yet.public String getDisplayName()
Thread.getName()
.getDisplayName
in interface ModelObject
@Exported public int getNumber()
Executor
s for the same computer.@Exported public boolean isIdle()
Executor
is ready for action.public boolean isBusy()
isIdle()
— the executor is doing some work.public boolean isActive()
Thread.isAlive()
, which would be incorrect for
non-started threads or running AsynchronousExecution
.@CheckForNull public AsynchronousExecution getAsynchronousExecution()
public boolean isDisplayCell()
AsynchronousExecution
and that execution wants to hide the display
cell for the executor (because there is another executor displaying the job progress and we don't want to
confuse the user) then this method will return false
to indicate to executors.jelly
that
the executor cell should be hidden.true
iff the executorCell.jelly
for this Executor
should be displayed in
executors.jelly
.AsynchronousExecution.displayCell()
public boolean isParking()
@Deprecated @CheckForNull public Throwable getCauseOfDeath()
@Exported public int getProgress()
@Exported public boolean isLikelyStuck()
This is a heuristics based approach, but if the build is suspiciously taking for a long time, this method returns true.
public long getElapsedTime()
public long getTimeSpentInQueue()
public String getTimestampString()
public String getEstimatedRemainingTime()
public long getEstimatedRemainingTimeMillis()
getEstimatedRemainingTime()
but return
it as a number of milli-seconds.public void start()
start
in class Thread
start(WorkUnit)
@Deprecated public void doStop(org.kohsuke.stapler.StaplerRequest req, org.kohsuke.stapler.StaplerResponse rsp) throws IOException, javax.servlet.ServletException
doStop()
or doStopBuild(String)
.IOException
javax.servlet.ServletException
public org.kohsuke.stapler.HttpResponse doStop()
doStopBuild(String)
instead to ensure what will be
interrupted is actually what you want to interrupt.doStopBuild(String)
@Restricted(value=org.kohsuke.accmod.restrictions.NoExternalUse.class) public org.kohsuke.stapler.HttpResponse doStopBuild(@CheckForNull @QueryParameter(fixEmpty=true) String runExtId)
Queue.Executable
is not a Run
).runExtId
- if not null, the externalizable id (Run.getExternalizableId()
)
of the build the user expects to interrupt@Deprecated public org.kohsuke.stapler.HttpResponse doYank()
public boolean hasStopPermission()
@NonNull public Computer getOwner()
public long getIdleStartMilliseconds()
public Api getApi()
public <T> T newImpersonatingProxy(Class<T> type, T core)
@CheckForNull public static Executor currentExecutor()
@CheckForNull public static Executor of(Queue.Executable executable)
executable
- a possibly running executableOneOffExecutor
) whose getCurrentExecutable()
matches that,
or null if it could not be found (for example because the execution has already completed)@Deprecated public static long getEstimatedDurationFor(Queue.Executable e)
Queue.Executable.getEstimatedDuration()
directlyCopyright © 2004–2021. All rights reserved.