com.atlassian.bamboo.v2.build.queue
Class BuildQueueManagerImpl

java.lang.Object
  extended by com.atlassian.bamboo.v2.build.queue.BuildQueueManagerImpl
All Implemented Interfaces:
BuildQueueManager

public class BuildQueueManagerImpl
extends java.lang.Object
implements BuildQueueManager


Field Summary
protected  java.util.concurrent.locks.ReadWriteLock queueLock
           
 
Fields inherited from interface com.atlassian.bamboo.v2.build.queue.BuildQueueManager
DISABLE_BUILD_SYSTEM_PROPERTY
 
Constructor Summary
BuildQueueManagerImpl(com.atlassian.event.api.EventPublisher eventPublisher, BuildExecutionManager buildExecutionManager, PlanManager planManager, org.springframework.jms.core.JmsTemplate jmsTemplate, com.atlassian.plugin.PluginAccessor pluginAccessor, ErrorUpdateHandler errorUpdateHandler, BootstrapManager bootstrapManager, BuildResultsSummaryManager buildResultsSummaryManager, PlanExecutableAgentsHelper planExecutableAgentsHelper, CustomVariableContextRunner customVariableContextRunner)
           
 
Method Summary
 void addBuildToQueue(BuildContext buildContext)
          Attempts to add the build to a queue.
 java.util.List<BuildContext> getBuildQueue()
          Returns a thread safe list of BuildContext objects representing the builds that is in the queue
 BuildQueuePosition getQueuePosition(PlanResultKey planResultKey)
          Returns information on position of plan result in the queue.
 boolean queueContains(PlanKey planKey)
          Indicates whether a build of a given build plan is in the queue.
 void reconstructBuildQueue()
          Reconstructs the build queue.
 void removeAllBuildsForPlanFromQueue(PlanKey planKey)
          Removes all the BuildContext associated with the planKey to be removed from the queue.
 void removeBuildFromQueue(PlanResultKey buildResultKey)
          Removes the BuildContext associated with the buildResultKey to be removed from the queue.
 void reorderBuildInQueue(java.lang.String planKey, int index)
          Reorders the build queue.
 boolean reorderBuildInQueue(java.lang.String buildResultKey, java.lang.String prevBuildResultKey, java.lang.String nextBuildResultKey)
          Moves a given build in a queue in between two given builds.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

queueLock

protected java.util.concurrent.locks.ReadWriteLock queueLock
Constructor Detail

BuildQueueManagerImpl

public BuildQueueManagerImpl(com.atlassian.event.api.EventPublisher eventPublisher,
                             BuildExecutionManager buildExecutionManager,
                             PlanManager planManager,
                             org.springframework.jms.core.JmsTemplate jmsTemplate,
                             com.atlassian.plugin.PluginAccessor pluginAccessor,
                             ErrorUpdateHandler errorUpdateHandler,
                             BootstrapManager bootstrapManager,
                             BuildResultsSummaryManager buildResultsSummaryManager,
                             PlanExecutableAgentsHelper planExecutableAgentsHelper,
                             CustomVariableContextRunner customVariableContextRunner)
Method Detail

addBuildToQueue

public void addBuildToQueue(@NotNull
                            BuildContext buildContext)
Description copied from interface: BuildQueueManager
Attempts to add the build to a queue. A BuildQueuedEvent is fired if queuing was successful and a BuildRejectedFromQueueEvent iif rejected. A lock on the build is obtained from the BuildExecutionManager.

Specified by:
addBuildToQueue in interface BuildQueueManager
Parameters:
buildContext - @NotNull

removeBuildFromQueue

public void removeBuildFromQueue(@NotNull
                                 PlanResultKey buildResultKey)
Description copied from interface: BuildQueueManager
Removes the BuildContext associated with the buildResultKey to be removed from the queue. A BuildDeQueuedEvent is fired. The lock on the build is not released. The caller should call BuildExecutionManager#finishProcess to release this lock when ready.

Specified by:
removeBuildFromQueue in interface BuildQueueManager

removeAllBuildsForPlanFromQueue

public void removeAllBuildsForPlanFromQueue(@NotNull
                                            PlanKey planKey)
Description copied from interface: BuildQueueManager
Removes all the BuildContext associated with the planKey to be removed from the queue. A BuildDeQueuedEvent is fired. The lock on the build is not released. The caller should call BuildExecutionManager#finishProcess to release this lock when ready.

Specified by:
removeAllBuildsForPlanFromQueue in interface BuildQueueManager

reorderBuildInQueue

public void reorderBuildInQueue(java.lang.String planKey,
                                int index)
Description copied from interface: BuildQueueManager
Reorders the build queue. BuildContext associated with the planKey is moved to new position in the queue indicated by the zero-based index parameter. If index is < 0 or >= size of queue then BuildContext is positioned at the beginning or at the end of the queue respectively.

Specified by:
reorderBuildInQueue in interface BuildQueueManager
Parameters:
planKey - Plan key of the build that shall be repositioned in the queue.
index - New position of a BuildContext associated with the planKey in the queue.

reorderBuildInQueue

public boolean reorderBuildInQueue(@NotNull
                                   java.lang.String buildResultKey,
                                   @Nullable
                                   java.lang.String prevBuildResultKey,
                                   @Nullable
                                   java.lang.String nextBuildResultKey)
Description copied from interface: BuildQueueManager
Moves a given build in a queue in between two given builds. Required because: - By the time a user requests a reorder that plan may already have shifted up the queue (possibly by a considerable number of positions) thus it may be that be reordering to position 3 your may have actually pushed it down the queue rather than up where you wanted it. By reordering between two plans on the queue you basically eliminate this problem. - It allows us to check that the target position of the queue is as the user expects, so we can detect if there was a queue repositioning clash (by another user reordering the queue remotely). You must specify buildResultKey and either prevBuildResultKey or nextBuildResultKey (or both).

Specified by:
reorderBuildInQueue in interface BuildQueueManager
Returns:
true if queue has been successfully reordered and false otherwise (e.g. previous and next builds were not adjacent)

getQueuePosition

@NotNull
public BuildQueuePosition getQueuePosition(@NotNull
                                                   PlanResultKey planResultKey)
Description copied from interface: BuildQueueManager
Returns information on position of plan result in the queue.

Specified by:
getQueuePosition in interface BuildQueueManager
Parameters:
planResultKey - identifies plan result
Returns:
the [@link BuildQueuePosition} object

getBuildQueue

@NotNull
public java.util.List<BuildContext> getBuildQueue()
Description copied from interface: BuildQueueManager
Returns a thread safe list of BuildContext objects representing the builds that is in the queue

Specified by:
getBuildQueue in interface BuildQueueManager
Returns:
List of BuildContext. Changes to this List is not reflected in the queue.

queueContains

public boolean queueContains(PlanKey planKey)
Description copied from interface: BuildQueueManager

Indicates whether a build of a given build plan is in the queue.

Specified by:
queueContains in interface BuildQueueManager
Parameters:
planKey - The build plan key
Returns:
true if a build of the given build plan is in the queue, false otherwise.

reconstructBuildQueue

public void reconstructBuildQueue()
Description copied from interface: BuildQueueManager
Reconstructs the build queue. This needs to happen in the following scenarios: - Agent capability gets updated - Agent enabled/disabled - Plan configuration (requirements) updated.

Specified by:
reconstructBuildQueue in interface BuildQueueManager


Copyright © 2012 Atlassian. All Rights Reserved.