Interface BuildQueueManager
-
- All Superinterfaces:
AgentQueueAccessor
- All Known Implementing Classes:
BuildQueueManagerImpl
@Internal @ThreadSafe public interface BuildQueueManager extends AgentQueueAccessor
This interface defines the work that the queue manager can do. Implementors must be threadsafe.
-
-
Nested Class Summary
Nested Classes Modifier and Type Interface Description static class
BuildQueueManager.QueuedResultKey
static class
BuildQueueManager.QueueItemView<T>
-
Nested classes/interfaces inherited from interface com.atlassian.bamboo.v2.build.queue.AgentQueueAccessor
AgentQueueAccessor.QueueAccessResult
-
-
Field Summary
Fields Modifier and Type Field Description static String
DISABLE_BUILD_SYSTEM_PROPERTY
-
Method Summary
All Methods Instance Methods Abstract Methods Modifier and Type Method Description void
addToQueue(@NotNull CommonContext context)
Attempts to add the build to a queue.@Nullable Set<Long>
getExecutorsForQueuedExecutable(@NotNull ResultKey resultKey)
@Nullable Collection<ElasticImageConfiguration>
getImagesForQueuedExecutable(@NotNull ResultKey resultKey)
@Nullable Collection<ElasticImageConfiguration>
getNonDedicatedImagesForQueuedExecutable(@NotNull ResultKey resultKey)
Returns the images that can execute the given executable.@NotNull Iterable<BuildQueueManager.QueuedResultKey>
getQueuedExecutables()
@NotNull BuildQueuePosition
getQueuePosition(@NotNull ResultKey resultKey)
Returns information on position of plan result in the queue.@Nullable Collection<EphemeralAgentTemplate>
getTemplatesForQueueExecutable(@NotNull ResultKey resultKey)
Returns the ephemeral agents templates currently considered to be eligible for building resultKey.long
getTimeSpentOnRecalculatingAllExecutors(long durationTillNowInMillis)
The method returns the number of milliseconds spent on recalculating all executors for a time duration until now.void
invalidateExecutables(@NotNull BuildAgent buildAgent)
Updates all agent-executable mappings for a given agent.void
invalidateExecutors(@NotNull Key planKey)
void
invalidateExecutors(@NotNull String reason)
void
launchDedicatedAgentsForTemplate(@NotNull EphemeralAgentTemplate template)
Launches dedicated agents for the given template and executables present in the queue at the moment of this method call.@Nullable BuildQueueManager.QueueItemView<CommonContext>
peekContext(@NotNull ResultKey resultKey)
Returns a queued CommonContext for given resultKey.void
removeBuildFromQueue(@NotNull ResultKey resultKey)
Removes theCommonContext
associated with the resultKey to be removed from the queue.void
removeDedicationTimestamp(@NotNull ResultKey resultKey)
Remove the dedication timestamp for the given result key if the one exists.boolean
reorderInQueue(ResultKey resultKey, int index)
Reorders the build queue.void
restoreState(Set<ResultKey> resultsToRestore)
Restore state after server restart.-
Methods inherited from interface com.atlassian.bamboo.v2.build.queue.AgentQueueAccessor
takeBuildContext, takeContext, takeContext
-
-
-
-
Field Detail
-
DISABLE_BUILD_SYSTEM_PROPERTY
static final String DISABLE_BUILD_SYSTEM_PROPERTY
- See Also:
- Constant Field Values
-
-
Method Detail
-
addToQueue
void addToQueue(@NotNull @NotNull CommonContext context)
Attempts to add the build to a queue. A com.atlassian.bamboo.v2.build.events.BuildQueuedEvent is fired if queuing was successfulA lock on the build is obtained from the
BuildExecutionManager
.- Parameters:
context
-
-
removeBuildFromQueue
void removeBuildFromQueue(@NotNull @NotNull ResultKey resultKey)
Removes theCommonContext
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.- Parameters:
resultKey
-
-
peekContext
@Nullable @Nullable BuildQueueManager.QueueItemView<CommonContext> peekContext(@NotNull @NotNull ResultKey resultKey)
Returns a queued CommonContext for given resultKey. Consider using com.atlassian.bamboo.v2.build.queue.QueueManagerView for your build queue viewing needs}- Parameters:
resultKey
-- Returns:
-
reorderInQueue
boolean reorderInQueue(ResultKey resultKey, int index)
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 thenCommonContext
is positioned at the beginning or at the end of the queue respectively.- Parameters:
resultKey
- Result key of the build that shall be repositioned in the queue.index
- New position of aCommonContext
associated with the planKey in the queue.
-
getQueuePosition
@NotNull @NotNull BuildQueuePosition getQueuePosition(@NotNull @NotNull ResultKey resultKey)
Returns information on position of plan result in the queue.- Parameters:
resultKey
- identifies plan result- Returns:
- the [@link BuildQueuePosition} object
-
invalidateExecutors
void invalidateExecutors(@NotNull @NotNull String reason)
-
invalidateExecutors
void invalidateExecutors(@NotNull @NotNull Key planKey)
-
invalidateExecutables
void invalidateExecutables(@NotNull @NotNull BuildAgent buildAgent)
Updates all agent-executable mappings for a given agent.
-
getQueuedExecutables
@NotNull @NotNull Iterable<BuildQueueManager.QueuedResultKey> getQueuedExecutables()
- Returns:
- the currently queued executables.
-
getImagesForQueuedExecutable
@Nullable @Nullable Collection<ElasticImageConfiguration> getImagesForQueuedExecutable(@NotNull @NotNull ResultKey resultKey)
- Returns:
- the images that can execute the given executable. returns null if the executable is unknown.
-
getNonDedicatedImagesForQueuedExecutable
@Nullable @Nullable Collection<ElasticImageConfiguration> getNonDedicatedImagesForQueuedExecutable(@NotNull @NotNull ResultKey resultKey)
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.- Parameters:
resultKey
- executable- Returns:
- list of elastic image configurations
- Since:
- 9.3
-
getTemplatesForQueueExecutable
@Nullable @Nullable Collection<EphemeralAgentTemplate> getTemplatesForQueueExecutable(@NotNull @NotNull ResultKey resultKey)
Returns the ephemeral agents templates currently considered to be eligible for building resultKey. If the resultKey is not found the null is returned.- Parameters:
resultKey
- result key to look for- Returns:
- ephemeral agents templates.
- Since:
- 9.3
-
getExecutorsForQueuedExecutable
@Nullable @Nullable Set<Long> getExecutorsForQueuedExecutable(@NotNull @NotNull ResultKey resultKey)
- Returns:
- the ids of agents that can execute the given executable. returns null if the executable is unknown.
-
restoreState
void restoreState(Set<ResultKey> resultsToRestore)
Restore state after server restart.- Parameters:
resultsToRestore
- keys of results that it makes sense to restore
-
getTimeSpentOnRecalculatingAllExecutors
@Internal long getTimeSpentOnRecalculatingAllExecutors(long durationTillNowInMillis)
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.- Parameters:
durationTillNowInMillis
- the time duration until now in milliseconds- Returns:
- the number of milliseconds spent on recalculating all executors
- Since:
- 9.2
-
removeDedicationTimestamp
void removeDedicationTimestamp(@NotNull @NotNull ResultKey resultKey)
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.- Parameters:
resultKey
- of the related executable- Since:
- 9.4
-
launchDedicatedAgentsForTemplate
void launchDedicatedAgentsForTemplate(@NotNull @NotNull EphemeralAgentTemplate template)
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.- Parameters:
template
- the template to launch dedicated agents for- Since:
- 9.4
-
-