Class CachingBuildEstimator
- java.lang.Object
-
- jetbrains.buildServer.serverSide.impl.timeEstimation.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
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static interface
CachingBuildEstimator.Feeder
Provides source estimation data for the cache.
-
Field Summary
Fields Modifier and Type Field Description static int
DEFAULT_ESTIMATES_INVALIDATION_TIMEOUT
static String
INVALIDATION_TIMEOUT_PROP
-
Constructor Summary
Constructors Constructor Description CachingBuildEstimator(CachingBuildEstimator.Feeder feeder, EventDispatcher<BuildServerListener> dispatcher, BuildQueueEx buildQueue)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description void
computeEstimates(int timeout)
protected long
currentTimeMillis()
BuildEstimates
getEstimates(QueuedBuildInfo queuedBuild)
Returns an expected time interval (start/finish time) for the given queued build.void
init(BuildQueueEx buildQueue)
void
invalidate(boolean waitForUpdate)
protected void
waitForEstimatesUpdate()
-
-
-
Field Detail
-
INVALIDATION_TIMEOUT_PROP
public static final String INVALIDATION_TIMEOUT_PROP
- See Also:
- Constant Field Values
-
DEFAULT_ESTIMATES_INVALIDATION_TIMEOUT
public static final int DEFAULT_ESTIMATES_INVALIDATION_TIMEOUT
- See Also:
- Constant Field Values
-
-
Constructor Detail
-
CachingBuildEstimator
public CachingBuildEstimator(@NotNull CachingBuildEstimator.Feeder feeder, @NotNull EventDispatcher<BuildServerListener> dispatcher, @NotNull BuildQueueEx buildQueue)
-
-
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:- The build is not in the queue
- The build never can start because there are no compatible agents
- The build comes after another build (to the same agent) whose finish time cannot be estimated
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 interfaceBuildEstimator
- 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()
-
-