Class BuildQueueManagerImpl

    • Method Detail

      • removeBuildFromQueue

        public void removeBuildFromQueue​(@NotNull
                                         @NotNull ResultKey resultKey)
        Description copied from interface: BuildQueueManager
        Removes the CommonContext associated with the resultKey to be removed from the queue.

        The lock on the build is not released. The caller should call com.atlassian.bamboo.build.BuildExecutionManager#finishBuild(PlanResultKey) to release this lock when ready.

        Specified by:
        removeBuildFromQueue in interface BuildQueueManager
      • reorderInQueue

        public boolean reorderInQueue​(ResultKey resultKey,
                                      int index)
        Description copied from interface: BuildQueueManager
        Reorders the build queue. CommonContext associated with the resultKey is moved to new position in the queue indicated by the zero-based index parameter. If index is < 0 or >= size of queue then CommonContext is positioned at the beginning or at the end of the queue respectively.
        Specified by:
        reorderInQueue in interface BuildQueueManager
        Parameters:
        resultKey - Result key of the build that shall be repositioned in the queue.
        index - New position of a CommonContext associated with the planKey in the queue.
      • getQueuePosition

        @NotNull
        public @NotNull BuildQueuePosition getQueuePosition​(@NotNull
                                                            @NotNull ResultKey resultKey)
        Description copied from interface: BuildQueueManager
        Returns information on position of plan result in the queue.
        Specified by:
        getQueuePosition in interface BuildQueueManager
        Parameters:
        resultKey - identifies plan result
        Returns:
        the [@link BuildQueuePosition} object
      • getNonDedicatedImagesForQueuedExecutable

        @Nullable
        public @Nullable Collection<ElasticImageConfiguration> getNonDedicatedImagesForQueuedExecutable​(@NotNull
                                                                                                        @NotNull ResultKey resultKey)
        Description copied from interface: BuildQueueManager
        Returns the images that can execute the given executable. If the executable is not found, null is returned. If the executable is dedicated at the moment of check, the empty list will be returned.
        Specified by:
        getNonDedicatedImagesForQueuedExecutable in interface BuildQueueManager
        Parameters:
        resultKey - executable
        Returns:
        list of elastic image configurations
      • getTemplatesForQueueExecutable

        @Nullable
        public @Nullable Collection<EphemeralAgentTemplate> getTemplatesForQueueExecutable​(@NotNull
                                                                                           @NotNull ResultKey resultKey)
        Description copied from interface: BuildQueueManager
        Returns the ephemeral agents templates currently considered to be eligible for building resultKey. If the resultKey is not found the null is returned.
        Specified by:
        getTemplatesForQueueExecutable in interface BuildQueueManager
        Parameters:
        resultKey - result key to look for
        Returns:
        ephemeral agents templates.
      • getExecutorsForQueuedExecutable

        @Nullable
        public @Nullable Set<Long> getExecutorsForQueuedExecutable​(@NotNull
                                                                   @NotNull ResultKey resultKey)
        Specified by:
        getExecutorsForQueuedExecutable in interface BuildQueueManager
        Returns:
        the ids of agents that can execute the given executable. returns null if the executable is unknown.
      • restoreState

        public void restoreState​(Set<ResultKey> resultsToRestore)
        Description copied from interface: BuildQueueManager
        Restore state after server restart.
        Specified by:
        restoreState in interface BuildQueueManager
        Parameters:
        resultsToRestore - keys of results that it makes sense to restore
      • removeDedicationTimestamp

        public void removeDedicationTimestamp​(@NotNull
                                              @NotNull ResultKey resultKey)
        Description copied from interface: BuildQueueManager
        Remove the dedication timestamp for the given result key if the one exists. The dedication timestamp works as a due-to-date, to which the build queue holds the related executable for a dedicated agent. After the date pass, every executor can grab the executable. Removing the dedication timestamp means that the executable is no longer dedicated.
        Specified by:
        removeDedicationTimestamp in interface BuildQueueManager
        Parameters:
        resultKey - of the related executable
      • launchDedicatedAgentsForTemplate

        public void launchDedicatedAgentsForTemplate​(@NotNull
                                                     @NotNull EphemeralAgentTemplate template)
        Description copied from interface: BuildQueueManager
        Launches dedicated agents for the given template and executables present in the queue at the moment of this method call. The dedicated agent will be launched if the corresponding executable is not already waiting for any dedicated agent.
        Specified by:
        launchDedicatedAgentsForTemplate in interface BuildQueueManager
        Parameters:
        template - the template to launch dedicated agents for
      • getTimeSpentOnRecalculatingAllExecutors

        public long getTimeSpentOnRecalculatingAllExecutors​(long durationTillNowInMillis)
        Description copied from interface: BuildQueueManager
        The method returns the number of milliseconds spent on recalculating all executors for a time duration until now. Important: If the subsequent method calls have a bigger durationTillNowInMillis than the previous one, it can lead to an underestimated result.
        Specified by:
        getTimeSpentOnRecalculatingAllExecutors in interface BuildQueueManager
        Parameters:
        durationTillNowInMillis - the time duration until now in milliseconds
        Returns:
        the number of milliseconds spent on recalculating all executors
      • takeBuildContext

        @Nullable
        public @Nullable CommonContext takeBuildContext​(long agentId)
                                                 throws InterruptedException
        Description copied from interface: AgentQueueAccessor
        Takes a CommonContext from the queue, blocking until one is available.

        The lock on the build is not released. The caller should call com.atlassian.bamboo.build.BuildExecutionManager#finishBuild(PlanResultKey) to release this lock when ready.

        Specified by:
        takeBuildContext in interface AgentQueueAccessor
        Parameters:
        agentId - the id of the agent that is taking the build context.
        Returns:
        The CommonContext, null in case of timeout on retrieval.
        Throws:
        InterruptedException - if the calling Thread is interrupted.