public class BuildQueueManagerImpl extends Object implements BuildQueueManager
BuildQueueManager.QueuedResultKey, BuildQueueManager.QueueItemView<T>
AgentQueueAccessor.QueueAccessResult
DISABLE_BUILD_SYSTEM_PROPERTY
Constructor and Description |
---|
BuildQueueManagerImpl(@NotNull AgentManager agentManager,
@NotNull com.atlassian.event.api.EventPublisher eventPublisher,
@NotNull BuildExecutionManager buildExecutionManager,
@NotNull com.atlassian.plugin.PluginAccessor pluginAccessor,
@NotNull ErrorUpdateHandler errorUpdateHandler,
@NotNull ExecutableAgentsHelper executableAgentsHelper,
@NotNull CustomVariableContextRunner customVariableContextRunner,
@NotNull ExecutionPhaseService executionPhaseService,
@NotNull XStreamFactory xStreamFactory,
@NotNull org.springframework.transaction.support.TransactionTemplate transactionTemplate,
@NotNull LocalResultProcessor resultProcessor) |
Modifier and Type | Method and 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) |
@NotNull Iterable<BuildQueueManager.QueuedResultKey> |
getQueuedExecutables() |
@NotNull BuildQueuePosition |
getQueuePosition(@NotNull ResultKey resultKey)
Returns information on position of plan result in the queue.
|
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 key) |
void |
invalidateExecutors(@NotNull String reason) |
@Nullable BuildQueueManager.QueueItemView<CommonContext> |
peekContext(@NotNull ResultKey resultKey)
Returns a queued CommonContext for given resultKey.
|
void |
removeBuildFromQueue(@NotNull ResultKey resultKey)
Removes the
CommonContext associated with the resultKey to be removed from the queue. |
boolean |
reorderInQueue(ResultKey resultKey,
int index)
Reorders the build queue.
|
void |
restoreState(Set<ResultKey> resultsToRestore)
Restore state after server restart.
|
@Nullable CommonContext |
takeBuildContext(long agentId)
Takes a
CommonContext from the queue, blocking until one is available. |
@Nullable AgentQueueAccessor.QueueAccessResult |
takeContext(long agentId)
Takes a
CommonContext from the queue, blocking until one is available. |
AgentQueueAccessor.QueueAccessResult |
takeContext(long agentId,
@Nullable ResultKey resultKey)
If resultKey is not null, takes a specific
CommonContext from the queue or nothing if there's no job with specified key in the queue. |
@Inject public BuildQueueManagerImpl(@NotNull @NotNull AgentManager agentManager, @NotNull @NotNull com.atlassian.event.api.EventPublisher eventPublisher, @NotNull @NotNull BuildExecutionManager buildExecutionManager, @NotNull @NotNull com.atlassian.plugin.PluginAccessor pluginAccessor, @NotNull @NotNull ErrorUpdateHandler errorUpdateHandler, @NotNull @NotNull ExecutableAgentsHelper executableAgentsHelper, @NotNull @NotNull CustomVariableContextRunner customVariableContextRunner, @NotNull @NotNull ExecutionPhaseService executionPhaseService, @NotNull @NotNull XStreamFactory xStreamFactory, @NotNull @NotNull org.springframework.transaction.support.TransactionTemplate transactionTemplate, @NotNull @NotNull LocalResultProcessor resultProcessor)
public void addToQueue(@NotNull @NotNull CommonContext context)
BuildQueueManager
A lock on the build is obtained from the BuildExecutionManager
.
addToQueue
in interface BuildQueueManager
public void removeBuildFromQueue(@NotNull @NotNull ResultKey resultKey)
BuildQueueManager
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.
removeBuildFromQueue
in interface BuildQueueManager
public boolean reorderInQueue(ResultKey resultKey, int index)
BuildQueueManager
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.reorderInQueue
in interface BuildQueueManager
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.@NotNull public @NotNull BuildQueuePosition getQueuePosition(@NotNull @NotNull ResultKey resultKey)
BuildQueueManager
getQueuePosition
in interface BuildQueueManager
resultKey
- identifies plan resultpublic void invalidateExecutors(@NotNull @NotNull String reason)
invalidateExecutors
in interface BuildQueueManager
public void invalidateExecutors(@NotNull @NotNull Key key)
invalidateExecutors
in interface BuildQueueManager
public void invalidateExecutables(@NotNull @NotNull BuildAgent buildAgent)
BuildQueueManager
invalidateExecutables
in interface BuildQueueManager
@NotNull public @NotNull Iterable<BuildQueueManager.QueuedResultKey> getQueuedExecutables()
getQueuedExecutables
in interface BuildQueueManager
@Nullable public @Nullable Collection<ElasticImageConfiguration> getImagesForQueuedExecutable(@NotNull @NotNull ResultKey resultKey)
getImagesForQueuedExecutable
in interface BuildQueueManager
@Nullable public @Nullable Set<Long> getExecutorsForQueuedExecutable(@NotNull @NotNull ResultKey resultKey)
getExecutorsForQueuedExecutable
in interface BuildQueueManager
@Nullable public @Nullable BuildQueueManager.QueueItemView<CommonContext> peekContext(@NotNull @NotNull ResultKey resultKey)
BuildQueueManager
peekContext
in interface BuildQueueManager
public void restoreState(Set<ResultKey> resultsToRestore)
BuildQueueManager
restoreState
in interface BuildQueueManager
resultsToRestore
- keys of results that it makes sense to restorepublic long getTimeSpentOnRecalculatingAllExecutors(long durationTillNowInMillis)
BuildQueueManager
getTimeSpentOnRecalculatingAllExecutors
in interface BuildQueueManager
durationTillNowInMillis
- the time duration until now in milliseconds@Nullable public @Nullable CommonContext takeBuildContext(long agentId) throws InterruptedException
AgentQueueAccessor
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.
takeBuildContext
in interface AgentQueueAccessor
agentId
- the id of the agent that is taking the build context.CommonContext
, null in case of timeout on retrieval.InterruptedException
- if the calling Thread
is interrupted.@Nullable public @Nullable AgentQueueAccessor.QueueAccessResult takeContext(long agentId) throws InterruptedException
AgentQueueAccessor
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.
takeContext
in interface AgentQueueAccessor
agentId
- the id of the agent that is taking the build context.AgentQueueAccessor.QueueAccessResult
containing: CommonContext
on success, error message on error, nulls in case of timeout on retrieval.InterruptedException
- if the calling Thread
is interrupted.public AgentQueueAccessor.QueueAccessResult takeContext(long agentId, @Nullable @Nullable ResultKey resultKey) throws InterruptedException
AgentQueueAccessor
CommonContext
from the queue or nothing if there's no job with specified key in the queue.
If resultKey is null, behaved identically to AgentQueueAccessor.takeContext(long)
.
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.
takeContext
in interface AgentQueueAccessor
agentId
- the id of the agent that is taking the build context.resultKey
- of the job that agent expects to receiveAgentQueueAccessor.QueueAccessResult
containing: CommonContext
on success, error message on error, nulls in case of timeout on retrieval.InterruptedException
- if the calling Thread
is interrupted.Copyright © 2024 Atlassian Software Systems Pty Ltd. All rights reserved.