/** * Estimate of how long will it take to execute this executable. * Measured in milliseconds. * * @return -1 if it's impossible to estimate; default, {@link SubTask#getEstimatedDuration} * @since 1.383 */ default long getEstimatedDuration() { return Executables.getParentOf(this).getEstimatedDuration(); }
/** * Returns the estimated duration for the executable. * Protects against {@link AbstractMethodError}s if the {@link Executable} implementation * was compiled against Hudson < 1.383 * * @deprecated as of 1.388 * Use {@link Executables#getEstimatedDurationFor(Executable)} */ public static long getEstimatedDurationFor(Executable e) { return Executables.getEstimatedDurationFor(e); }
/** * Returns the estimated duration for the executable. * Protects against {@link AbstractMethodError}s if the {@link Executable} implementation * was compiled against Hudson < 1.383 */ public static long getEstimatedDurationFor(Executable e) { try { return _getEstimatedDuration(e); } catch (AbstractMethodError error) { return e.getParent().getEstimatedDuration(); } }
/** * Due to the return type change in {@link Executable}, the caller needs a special precaution now. */ public static SubTask getParentOf(Executable e) { try { return _getParentOf(e); } catch (AbstractMethodError _) { try { Method m = e.getClass().getMethod("getParent"); m.setAccessible(true); return (SubTask) m.invoke(e); } catch (IllegalAccessException x) { throw (Error)new IllegalAccessError().initCause(x); } catch (NoSuchMethodException x) { throw (Error)new NoSuchMethodError().initCause(x); } catch (InvocationTargetException x) { Throwable y = x.getTargetException(); if (y instanceof Error) throw (Error)y; if (y instanceof RuntimeException) throw (RuntimeException)y; throw new Error(x); } } }
/** * Returns the estimated duration for the executable. * Protects against {@link AbstractMethodError}s if the {@link Executable} implementation * was compiled against Hudson < 1.383 * * @deprecated as of 1.388 * Use {@link Executables#getEstimatedDurationFor(Executable)} */ public static long getEstimatedDurationFor(Executable e) { return Executables.getEstimatedDurationFor(e); }
/** * Returns the estimated duration for the executable. * Protects against {@link AbstractMethodError}s if the {@link Executable} implementation * was compiled against Hudson < 1.383 */ public static long getEstimatedDurationFor(Executable e) { try { return _getEstimatedDuration(e); } catch (AbstractMethodError error) { return e.getParent().getEstimatedDuration(); } }
/** * Due to the return type change in {@link Executable}, the caller needs a special precaution now. */ public static SubTask getParentOf(Executable e) { try { return _getParentOf(e); } catch (AbstractMethodError _) { try { Method m = e.getClass().getMethod("getParent"); m.setAccessible(true); return (SubTask) m.invoke(e); } catch (IllegalAccessException x) { throw (Error)new IllegalAccessError().initCause(x); } catch (NoSuchMethodException x) { throw (Error)new NoSuchMethodError().initCause(x); } catch (InvocationTargetException x) { Throwable y = x.getTargetException(); if (y instanceof Error) throw (Error)y; if (y instanceof RuntimeException) throw (RuntimeException)y; throw new Error(x); } } }
/** * Checks if the current user has a permission to stop this build. */ public boolean hasStopPermission() { lock.readLock().lock(); try { return executable != null && getParentOf(executable).getOwnerTask().hasAbortPermission(); } finally { lock.readLock().unlock(); } }
/** * Returns the estimated duration for the executable. * Protects against {@link AbstractMethodError}s if the {@link Executable} implementation * was compiled against Hudson < 1.383 * * @deprecated as of 1.388 * Use {@link Executables#getEstimatedDurationFor(Executable)} */ public static long getEstimatedDurationFor(Executable e) { return Executables.getEstimatedDurationFor(e); }
/** * Returns the estimated duration for the executable. Protects against * {@link AbstractMethodError}s if the {@link Executable} implementation was * compiled against Hudson < 1.383 */ public static long getEstimatedDurationFor(Executable e) { try { return _getEstimatedDuration(e); } catch (AbstractMethodError error) { return e.getParent().getEstimatedDuration(); } }
/** * Due to the return type change in {@link Executable}, the caller needs a special precaution now. */ public static SubTask getParentOf(Executable e) { try { return _getParentOf(e); } catch (AbstractMethodError _) { try { Method m = e.getClass().getMethod("getParent"); m.setAccessible(true); return (SubTask) m.invoke(e); } catch (IllegalAccessException x) { throw (Error)new IllegalAccessError().initCause(x); } catch (NoSuchMethodException x) { throw (Error)new NoSuchMethodError().initCause(x); } catch (InvocationTargetException x) { Throwable y = x.getTargetException(); if (y instanceof Error) throw (Error)y; if (y instanceof RuntimeException) throw (RuntimeException)y; throw new Error(x); } } }
/** * Stops the current build. * * @since 1.489 */ @RequirePOST public HttpResponse doStop() { lock.writeLock().lock(); // need write lock as interrupt will change the field try { if (executable != null) { getParentOf(executable).getOwnerTask().checkAbortPermission(); interrupt(); } } finally { lock.writeLock().unlock(); } return HttpResponses.forwardToPreviousPage(); }
/** * Returns the estimated duration for the executable. Protects against * {@link AbstractMethodError}s if the {@link Executable} implementation was * compiled against Hudson < 1.383 * * * @deprecated as of 1.388 Use * {@link Executables#getEstimatedDurationFor(Executable)} */ public static long getEstimatedDurationFor(Executable e) { return Executables.getEstimatedDurationFor(e); } /**
/** * Returns the estimated duration for the executable. * Protects against {@link AbstractMethodError}s if the {@link Executable} implementation * was compiled against Hudson < 1.383 */ public static long getEstimatedDurationFor(Executable e) { try { return _getEstimatedDuration(e); } catch (AbstractMethodError error) { return e.getParent().getEstimatedDuration(); } }
/** * Due to the return type change in {@link Executable}, the caller needs a * special precaution now. */ public static SubTask getParentOf(Executable e) { try { return _getParentOf(e); } catch (AbstractMethodError _) { try { Method m = e.getClass().getMethod("getParent"); m.setAccessible(true); return (SubTask) m.invoke(e); } catch (IllegalAccessException x) { throw (Error) new IllegalAccessError().initCause(x); } catch (NoSuchMethodException x) { throw (Error) new NoSuchMethodError().initCause(x); } catch (InvocationTargetException x) { Throwable y = x.getTargetException(); if (y instanceof Error) { throw (Error) y; } if (y instanceof RuntimeException) { throw (RuntimeException) y; } throw new Error(x); } } }
final WorkUnit workUnit = e.getCurrentWorkUnit(); final Executable executable = workUnit != null ? workUnit.getExecutable() : null; final SubTask subtask = executable != null ? getParentOf(executable) : null;
/** * Returns when this executor started or should start being idle. */ public long getIdleStartMilliseconds() { Queue.Executable e = executable; if (e == null) { return Math.max(finishTime, owner.getConnectTime()); } else { return Math.max(startTime + Math.max(0, Executables.getEstimatedDurationFor(e)), System.currentTimeMillis() + 15000); } }
/** * Estimate of how long will it take to execute this executable. * Measured in milliseconds. * * @return -1 if it's impossible to estimate; default, {@link SubTask#getEstimatedDuration} * @since 1.383 */ default long getEstimatedDuration() { return Executables.getParentOf(this).getEstimatedDuration(); }
/** * Returns when this executor started or should start being idle. */ public long getIdleStartMilliseconds() { Queue.Executable e = executable; if (e == null) return Math.max(finishTime, owner.getConnectTime()); else { return Math.max(startTime + Math.max(0, Executables.getEstimatedDurationFor(e)), System.currentTimeMillis() + 15000); } }
/** * Checks if the current user has a permission to stop this build. */ public boolean hasStopPermission() { lock.readLock().lock(); try { return executable != null && getParentOf(executable).getOwnerTask().hasAbortPermission(); } finally { lock.readLock().unlock(); } }