Class CachingBuildEstimator

  • All Implemented Interfaces:
    BuildEstimator

    public class CachingBuildEstimator
    extends Object
    implements BuildEstimator
    Maintains a cache of build estimates. Estimates are taken from feeder and stored locally until they're invalidated. Time intervals are recalculated as time goes using the cached values.
    WARNING
    Although this class accessed from multiple concurrent threads, it's decided not to make it synchronized since this caused deadlocks. Instead it's implemented the way that guarantees the absence of showstoppers like NPE.
    Drawbacks:
    Some threads may get inactual data if this happens at the same time when actual data is being retrieved.
    Author:
    Sergey.Anchipolevsky Date: 08.06.2007
    • Field Detail

      • DEFAULT_ESTIMATES_INVALIDATION_TIMEOUT

        public static final int DEFAULT_ESTIMATES_INVALIDATION_TIMEOUT
        See Also:
        Constant Field Values
    • Method Detail

      • init

        public void init​(@NotNull
                         BuildQueueEx buildQueue)
      • computeEstimates

        public void computeEstimates​(int timeout)
      • getEstimates

        @Nullable
        public BuildEstimates getEstimates​(@NotNull
                                           QueuedBuildInfo queuedBuild)
        Description copied from interface: BuildEstimator
        Returns an expected time interval (start/finish time) for the given queued build. The time interval can be open from the above (has start time, but doesn't have finish time). This may happen when the build duration cannot be predicted due to the lack of statistics. Also null may be returned if the build start time couldn't be estimated. This may happen for the following reasons:
        1. The build is not in the queue
        2. The build never can start because there are no compatible agents
        3. The build comes after another build (to the same agent) whose finish time cannot be estimated
        The time base for the returned time interval is the time of method invocation with some accuracy. This means that two calls for the same queued build will always return different objects.

        The returned objects are value objects, that is they never change their values. The relative times returned by TimePoint methods are calculated for the time when the object was obtained.

        The returned object refers to future events only. That is all the relative times are non-negative.

        Specified by:
        getEstimates in interface BuildEstimator
        Parameters:
        queuedBuild - represents a build in the queue
        Returns:
        the BuildEstimates object describing the expected start / finish times or null if the build couldn't be estimated.
      • invalidate

        public void invalidate​(boolean waitForUpdate)
      • waitForEstimatesUpdate

        protected void waitForEstimatesUpdate()
      • currentTimeMillis

        protected long currentTimeMillis()