Search in sources :

Example 6 with Executable

use of hudson.model.Queue.Executable in project hudson-2.x by hudson.

the class Executor method isLikelyStuck.

/**
     * Returns true if the current build is likely stuck.
     *
     * <p>
     * This is a heuristics based approach, but if the build is suspiciously taking for a long time,
     * this method returns true.
     */
@Exported
public boolean isLikelyStuck() {
    Queue.Executable e = executable;
    if (e == null)
        return false;
    long elapsed = getElapsedTime();
    long d = Executables.getEstimatedDurationFor(e);
    if (d >= 0) {
        // if it's taking 10 times longer than ETA, consider it stuck
        return d * 10 < elapsed;
    } else {
        // if no ETA is available, a build taking longer than a day is considered stuck
        return TimeUnit2.MILLISECONDS.toHours(elapsed) > 24;
    }
}
Also used : Executable(hudson.model.Queue.Executable) Exported(org.kohsuke.stapler.export.Exported)

Aggregations

Executable (hudson.model.Queue.Executable)6 Exported (org.kohsuke.stapler.export.Exported)2 SC_INTERNAL_SERVER_ERROR (javax.servlet.http.HttpServletResponse.SC_INTERNAL_SERVER_ERROR)1