Class BuildCumulativeTimeCalculator


  • public class BuildCumulativeTimeCalculator
    extends Object
    Tracks cumulative time for which the individual build steps of a build have been executing at any point in time (fix to TW-79922)
    Since:
    2023.09
    • Constructor Detail

      • BuildCumulativeTimeCalculator

        public BuildCumulativeTimeCalculator​(AgentEventDispatcher agentEventDispatcher)
    • Method Detail

      • setBuildCumulativeTime

        public void setBuildCumulativeTime​(Long buildCumulativeExecutionTime)
        Sets field which keeps track of how long the current build's steps have been executing for cumulatively.
        Parameters:
        buildCumulativeExecutionTime - total cumulative duration of build at invocation time
      • getBuildCumulativeTime

        public long getBuildCumulativeTime()
        Calculates current cumulative build execution time for a running build only. Method will not produce correct result for non-running builds. Refer to "See Also" for determining whether an agent is running a build. Returns 0 if cumulative build time wasn't tracked before
        Parameters:
        buildCumulativeExecutionTime - total cumulative duration of build after previous step has been executed
        Returns:
        total cumulative duration of build at invocation time and after current step has been executed
        See Also:
        CurrentBuildTracker.getCurrentBuild()
      • computeBuildTimeoutMs

        public long computeBuildTimeoutMs​(AgentRunningBuild build)
        Calculates the time (in ms) the build can still execute for before timing out given how long it has been executing for already
        Parameters:
        build - for which the remaining time before timeout will be determined
        Returns:
        remaining time in ms a build can execute before timeout