Class WeightedAverageBuildDurationCalculator
- java.lang.Object
-
- jetbrains.buildServer.serverSide.impl.timeEstimation.WeightedAverageBuildDurationCalculator
-
- All Implemented Interfaces:
BuildDurationCalculator
- Direct Known Subclasses:
WeightedAverageMSDBuildDurationCalculator
public class WeightedAverageBuildDurationCalculator extends Object implements BuildDurationCalculator
- Author:
- Pavel.Sher Date: 02.08.2007
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description protected static class
WeightedAverageBuildDurationCalculator.BuildData
protected static class
WeightedAverageBuildDurationCalculator.BuildTypeData
protected static class
WeightedAverageBuildDurationCalculator.StageValue
-
Field Summary
Fields Modifier and Type Field Description static String
ESTIMATOR_TOTAL_AGENT_APPROACH_KEY
static String
ESTIMATOR_TOTAL_APPROACH_KEY
static String
ORDER_ID
static String
USESTAGES_PROPERTY_KEY
-
Constructor Summary
Constructors Constructor Description WeightedAverageBuildDurationCalculator(SQLRunnerEx sqlRunner, EventDispatcher<BuildServerListener> dispatcher, ProjectManager projectManager)
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description protected void
buildFinished(SFinishedBuild build, Map<String,Long> completedStages)
long
calculateAgentBuildDuration(String buildTypeId, BuildAgent agent)
Calculates estimated duration of a build of the specified build type on the specified agent considering only the time build spent on agent.long
calculateBuildDuration(String buildTypeId)
Calculates estimated duration of a build of the specified build type.protected long
calculateBuildDuration(String buildTypeId, String agentName, String... stagesToUse)
long
calculateBuildDuration(String buildTypeId, BuildAgent agent)
Calculates estimated duration of a build of the specified build type on the specified agent.protected double
calculateWeightedMeanForStage(String agentName, Iterable<WeightedAverageBuildDurationCalculator.StageValue> values)
long
estimateTimeLeftFor(RunningBuildEx build, long timestamp)
Estimates time for the given build to complete from the given (timestamp) pivotprotected WeightedAverageBuildDurationCalculator.BuildTypeData
getStoredStageData(String buildTypeId)
static Collection<String>
getWellKnownStages()
boolean
hasDataForAgent(String buildTypeId, BuildAgent agent)
void
setBuildHistory(BuildHistory history)
void
setIgnoreTooShortBuilds(boolean ignore)
protected boolean
shouldSkip(String buildTypeId, String agentName, long totalBuildDuration)
static boolean
shouldUseTotal(String buildTypeId)
String
toString()
-
-
-
Field Detail
-
ESTIMATOR_TOTAL_APPROACH_KEY
public static final String ESTIMATOR_TOTAL_APPROACH_KEY
- See Also:
- Constant Field Values
-
ESTIMATOR_TOTAL_AGENT_APPROACH_KEY
public static final String ESTIMATOR_TOTAL_AGENT_APPROACH_KEY
- See Also:
- Constant Field Values
-
USESTAGES_PROPERTY_KEY
public static final String USESTAGES_PROPERTY_KEY
- See Also:
- Constant Field Values
-
ORDER_ID
public static final String ORDER_ID
-
-
Constructor Detail
-
WeightedAverageBuildDurationCalculator
public WeightedAverageBuildDurationCalculator(@NotNull SQLRunnerEx sqlRunner, @NotNull EventDispatcher<BuildServerListener> dispatcher, @NotNull ProjectManager projectManager)
-
-
Method Detail
-
getWellKnownStages
@NotNull public static Collection<String> getWellKnownStages()
-
buildFinished
protected void buildFinished(@NotNull SFinishedBuild build, @NotNull Map<String,Long> completedStages)
-
setIgnoreTooShortBuilds
public void setIgnoreTooShortBuilds(boolean ignore)
-
shouldSkip
protected boolean shouldSkip(@NotNull String buildTypeId, String agentName, long totalBuildDuration)
-
getStoredStageData
@Nullable protected WeightedAverageBuildDurationCalculator.BuildTypeData getStoredStageData(String buildTypeId)
-
calculateBuildDuration
public long calculateBuildDuration(@NotNull String buildTypeId, @NotNull BuildAgent agent)
Description copied from interface:BuildDurationCalculator
Calculates estimated duration of a build of the specified build type on the specified agent.- Specified by:
calculateBuildDuration
in interfaceBuildDurationCalculator
- Parameters:
buildTypeId
- build type id.agent
- build agent.- Returns:
- Estimated time in milliseconds. -1 if an estimate cannot be calculated for some reason (e.g. lack of historical data).
-
calculateBuildDuration
public long calculateBuildDuration(@NotNull String buildTypeId)
Description copied from interface:BuildDurationCalculator
Calculates estimated duration of a build of the specified build type.- Specified by:
calculateBuildDuration
in interfaceBuildDurationCalculator
- Returns:
- Estimated time in milliseconds. -1 if an estimate cannot be calculated for some reason (e.g. lack of historical data).
-
calculateAgentBuildDuration
public long calculateAgentBuildDuration(@NotNull String buildTypeId, @NotNull BuildAgent agent)
Description copied from interface:BuildDurationCalculator
Calculates estimated duration of a build of the specified build type on the specified agent considering only the time build spent on agent.- Specified by:
calculateAgentBuildDuration
in interfaceBuildDurationCalculator
- Parameters:
buildTypeId
- build type id.agent
- build agent.- Returns:
- Estimated time in milliseconds. -1 if an estimate cannot be calculated for some reason (e.g. lack of historical data).
-
hasDataForAgent
public boolean hasDataForAgent(@NotNull String buildTypeId, @NotNull BuildAgent agent)
- Specified by:
hasDataForAgent
in interfaceBuildDurationCalculator
- Parameters:
buildTypeId
- build type idagent
- agent- Returns:
- true if calculator has data for specified build configuration and agent (i.e. build of specified build configuration has been executed on the specified agent).
-
setBuildHistory
public void setBuildHistory(@NotNull BuildHistory history)
-
calculateBuildDuration
protected long calculateBuildDuration(@NotNull String buildTypeId, @Nullable String agentName, String... stagesToUse)
-
calculateWeightedMeanForStage
protected double calculateWeightedMeanForStage(@Nullable String agentName, @NotNull Iterable<WeightedAverageBuildDurationCalculator.StageValue> values)
-
estimateTimeLeftFor
public long estimateTimeLeftFor(@NotNull RunningBuildEx build, long timestamp)
Description copied from interface:BuildDurationCalculator
Estimates time for the given build to complete from the given (timestamp) pivot- Specified by:
estimateTimeLeftFor
in interfaceBuildDurationCalculator
- Parameters:
build
- target buildtimestamp
- pivot to base estimate upon- Returns:
- estimation for the time left until completion
-
shouldUseTotal
public static boolean shouldUseTotal(@NotNull String buildTypeId)
-
-