@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.
|
void |
doStop(org.kohsuke.stapler.StaplerRequest req,
org.kohsuke.stapler.StaplerResponse rsp)
Deprecated.
as of 1.489
Use
doStop() . |
org.kohsuke.stapler.HttpResponse |
doYank()
Throws away this executor and get a new one.
|
Api |
getApi()
Exposes the executor to the remote API.
|
AsynchronousExecution |
getAsynchronousExecution()
If currently running in asynchronous mode, returns that handle.
|
Throwable |
getCauseOfDeath()
If this thread dies unexpectedly, obtain the cause of the failure.
|
Queue.Executable |
getCurrentExecutable()
Returns the current build this executor is running.
|
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()
Same as
Thread.getName() . |
long |
getElapsedTime() |
static long |
getEstimatedDurationFor(Queue.Executable e)
Deprecated.
as of 1.388
Use
Executables.getEstimatedDurationFor(Queue.Executable) |
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.
|
void |
killHard()
For testing only.
|
<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
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)
public void killHard()
@Exported @CheckForNull public Queue.Executable getCurrentExecutable()
@Exported 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()
@CheckForNull public Throwable getCauseOfDeath()
isActive()
.@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()
.IOException
javax.servlet.ServletException
public org.kohsuke.stapler.HttpResponse doStop()
public org.kohsuke.stapler.HttpResponse doYank()
public boolean hasStopPermission()
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)
Executables.getEstimatedDurationFor(Queue.Executable)
AbstractMethodError
s if the Queue.Executable
implementation
was compiled against Hudson < 1.383Copyright © 2016. All rights reserved.