Class SecuredBuildQueue
- java.lang.Object
-
- jetbrains.buildServer.serverSide.impl.auth.SecuredBuildQueue
-
- All Implemented Interfaces:
BatchTrigger
,BuildQueue
,BuildQueueEx
public class SecuredBuildQueue extends Object implements BuildQueueEx
- Author:
- Pavel.Sher Date: 02.10.2007
-
-
Constructor Summary
Constructors Constructor Description SecuredBuildQueue()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description List<QueuedBuildEx>
addToQueue(Map<BuildPromotionEx,SAgentRestrictor> promoAgentRestrictorMap, String rawTriggeredBy)
Adds promotions to the queue with corresponding agent restrictors (if agent restrictor is null then no agent restrictor is used).void
applyOrder(String[] itemIds)
Applies new order to the build queue.void
cancelMatchedItems(Filter<SQueuedBuild> itemsFilter, SUser user, String comment)
Removes and cancels items matched by the specified filter.List<SQueuedBuild>
findPersonalBuildsByPersonalChangeListId(long changeListId)
QueuedBuildEx
findQueued(String itemId)
Searches for an item in queue with specified item id.QueuedBuildEx
findQueued(String buildTypeId, Integer agentId)
Looks for build configuration with specified id scheduled to run on specified agent in the queue.QueuedBuildEx
findQueued(BuildPromotion promotion)
Searches for a queued build item for the specified promotionSQueuedBuild
getFirst()
Returns first queue element.List<SQueuedBuild>
getItems()
Returns all queued items.List<SQueuedBuild>
getItems(String buildTypeId)
Returns all items currently waiting in queue corresponding to specified build configuration id.List<SQueuedBuild>
getItemsByPool(int agentPoolId)
Returns all items currently waiting in queue corresponding to the specified agent pool.List<QueuedBuildEx>
getItemsEx()
SQueuedBuild
getLast()
Returns last queue element.int
getNumberOfItems()
Returns number of items currently in the queueint
getNumberOfItemsByPool(int agentPoolId)
Returns number of items currently waiting in queue corresponding to the specified agent pool.int
getOrderNumber(SQueuedBuild queuedBuild)
Returns order number of the specified queued buildList<QueuedBuildEx>
getPersistedItemsEx()
boolean
isInQueue(String buildTypeId)
Returns true if build configuration is already in queue.boolean
isQueueEmpty()
Checks if queue is empty.boolean
mergeBuilds(Predicate<SQueuedBuild> queuedBuildsFilter)
Optimizes build queue by removing builds which can be safely substituted by newer builds added to the queue.void
moveBottom(String itemId)
Moves specified item to the bottom of the queue.void
moveDependenciesToTop(BuildPromotion promotion)
Moves dependencies of given promotion to the top of the queuevoid
moveTop(String itemId)
Moves specified item to the top of the queue.TriggerTask
newTriggerTask(BuildPromotion promotion)
Creates new trigger task based on specified build promotion.boolean
optimizeChains(List<BuildPromotionEx> buildPromotions)
Optimizes build chains, i.e.List<SQueuedBuild>
processTasks(Collection<TriggerTask> tasks, String triggeredBy)
Processes collection of trigger tasks, by adding builds in the queue with parameters specified in these tasks.void
removeAllFromQueue()
Removes all items from the queuevoid
removeAllFromQueue(String buildTypeId)
Removes all items from the queue which correspond to specified build configuration.void
removeAllFromQueue(String buildTypeId, SUser user, String comment)
Removes all items from the queue which correspond to specified build configuration.void
removeItems(Collection<String> itemIds, SUser user, String comment)
Removes items with specified ids from the queuevoid
removeMatchedItems(Filter<SQueuedBuild> itemsFilter, SUser user, String comment)
Removes items matched by the specified filter from the queuevoid
removeQueuedBuilds(Collection<SQueuedBuild> items, SUser user, String comment)
Removes specified items from the queueList<QueuedBuildEx>
restoreInQueue(BuildPromotionEx promo, SAgentRestrictor agentRestrictor, String rawTriggeredBy)
Re-adds build into the queue.void
scheduleBuildQueueReload()
Sends event to reload queue from database (for debug API, TW-85394)void
scheduleCheckingForChangesForQueuedBuilds(Collection<QueuedBuildEx> queuedBuilds)
Processes the specified collection of queued builds, finds builds where changes collection should be done and schedules it.void
setDelegate(BuildQueueEx delegate)
void
setOrderingStrategy(BuildQueueOrderingStrategy strategy)
Assign ordering strategy for this build queuevoid
setSecurityContext(SecurityContextEx securityContext)
boolean
shouldCollectChangesInQueue(BuildPromotionEx promotion)
Returnstrue
if changes should be collected for specified promotion while it is in build queuevoid
terminateQueuedBuild(SQueuedBuild queuedBuild, SUser user, boolean isCanceled, String comment, BuildProblemData buildProblemData)
Removes specified queued build from the queue and creates a history build entry for it.
-
-
-
Method Detail
-
setDelegate
public void setDelegate(@NotNull BuildQueueEx delegate)
-
setSecurityContext
public void setSecurityContext(@NotNull SecurityContextEx securityContext)
-
removeAllFromQueue
public void removeAllFromQueue(String buildTypeId)
Description copied from interface:BuildQueueEx
Removes all items from the queue which correspond to specified build configuration.- Specified by:
removeAllFromQueue
in interfaceBuildQueueEx
- Parameters:
buildTypeId
- id of build configuration
-
removeAllFromQueue
public void removeAllFromQueue()
Description copied from interface:BuildQueueEx
Removes all items from the queue- Specified by:
removeAllFromQueue
in interfaceBuildQueueEx
-
removeAllFromQueue
public void removeAllFromQueue(String buildTypeId, SUser user, String comment)
Description copied from interface:BuildQueueEx
Removes all items from the queue which correspond to specified build configuration.- Specified by:
removeAllFromQueue
in interfaceBuildQueueEx
- Parameters:
buildTypeId
- id of build configurationuser
- usercomment
- comment
-
getOrderNumber
public int getOrderNumber(@NotNull SQueuedBuild queuedBuild)
Description copied from interface:BuildQueueEx
Returns order number of the specified queued build- Specified by:
getOrderNumber
in interfaceBuildQueueEx
- Parameters:
queuedBuild
- queued build- Returns:
- order number or 0 if specified queued build does not exist
-
findPersonalBuildsByPersonalChangeListId
public List<SQueuedBuild> findPersonalBuildsByPersonalChangeListId(long changeListId)
- Specified by:
findPersonalBuildsByPersonalChangeListId
in interfaceBuildQueueEx
-
mergeBuilds
public boolean mergeBuilds(@Nullable Predicate<SQueuedBuild> queuedBuildsFilter)
Description copied from interface:BuildQueueEx
Optimizes build queue by removing builds which can be safely substituted by newer builds added to the queue.- Specified by:
mergeBuilds
in interfaceBuildQueueEx
- Parameters:
queuedBuildsFilter
- filter to apply to the queue builds, if the filter returns false then the queued build won't participate in the optimization, if null then all currently queued builds will be optimized- Returns:
- true if queue was changed and false otherwise
-
optimizeChains
public boolean optimizeChains(@NotNull List<BuildPromotionEx> buildPromotions)
Description copied from interface:BuildQueueEx
Optimizes build chains, i.e. reassigns builds to started builds if possible. If during optimization some of the build promotions are removed from the chains, their queued builds will be removed from the queue as well.- Specified by:
optimizeChains
in interfaceBuildQueueEx
- Parameters:
buildPromotions
- build promotions to optimize- Returns:
- true if at least one build was removed from the queue as a result of optimization
-
restoreInQueue
public List<QueuedBuildEx> restoreInQueue(@NotNull BuildPromotionEx promo, @Nullable SAgentRestrictor agentRestrictor, @NotNull String rawTriggeredBy)
Description copied from interface:BuildQueueEx
Re-adds build into the queue. A copy of specified build promotion will be created, if there were snapshot dependencies on the original build they will be moved to the new one.- Specified by:
restoreInQueue
in interfaceBuildQueueEx
- Parameters:
promo
- original promoagentRestrictor
- agent restrictorrawTriggeredBy
- triggered by- Returns:
- newly added queued builds
-
applyOrder
public void applyOrder(@NotNull String[] itemIds)
Description copied from interface:BuildQueue
Applies new order to the build queue.- Specified by:
applyOrder
in interfaceBuildQueue
- Parameters:
itemIds
- new order of queue items
-
moveTop
public void moveTop(String itemId)
Description copied from interface:BuildQueue
Moves specified item to the top of the queue.- Specified by:
moveTop
in interfaceBuildQueue
- Parameters:
itemId
- id of the item to move to the top of the queue
-
moveBottom
public void moveBottom(String itemId)
Description copied from interface:BuildQueue
Moves specified item to the bottom of the queue.- Specified by:
moveBottom
in interfaceBuildQueue
- Parameters:
itemId
- id of the item to move to the bottom of the queue
-
getItems
@NotNull public List<SQueuedBuild> getItems()
Description copied from interface:BuildQueue
Returns all queued items.- Specified by:
getItems
in interfaceBuildQueue
- Returns:
- list of currently queued items.
-
getItemsEx
@NotNull public List<QueuedBuildEx> getItemsEx()
- Specified by:
getItemsEx
in interfaceBuildQueueEx
-
getPersistedItemsEx
@NotNull public List<QueuedBuildEx> getPersistedItemsEx()
- Specified by:
getPersistedItemsEx
in interfaceBuildQueueEx
-
getItems
@NotNull public List<SQueuedBuild> getItems(String buildTypeId)
Description copied from interface:BuildQueue
Returns all items currently waiting in queue corresponding to specified build configuration id.- Specified by:
getItems
in interfaceBuildQueue
- Parameters:
buildTypeId
- specified build configuration.- Returns:
- all items currently waiting in queue corresponding to specified build configuration id.
-
getItemsByPool
@NotNull public List<SQueuedBuild> getItemsByPool(int agentPoolId)
Description copied from interface:BuildQueueEx
Returns all items currently waiting in queue corresponding to the specified agent pool.- Specified by:
getItemsByPool
in interfaceBuildQueueEx
- Parameters:
agentPoolId
- agent pool id- Returns:
- see above
-
getNumberOfItemsByPool
public int getNumberOfItemsByPool(int agentPoolId)
Description copied from interface:BuildQueueEx
Returns number of items currently waiting in queue corresponding to the specified agent pool.- Specified by:
getNumberOfItemsByPool
in interfaceBuildQueueEx
- Returns:
- number of items currently waiting in queue corresponding to the specified agent pool.
-
scheduleCheckingForChangesForQueuedBuilds
public void scheduleCheckingForChangesForQueuedBuilds(@NotNull Collection<QueuedBuildEx> queuedBuilds)
Description copied from interface:BuildQueueEx
Processes the specified collection of queued builds, finds builds where changes collection should be done and schedules it.- Specified by:
scheduleCheckingForChangesForQueuedBuilds
in interfaceBuildQueueEx
-
shouldCollectChangesInQueue
public boolean shouldCollectChangesInQueue(@NotNull BuildPromotionEx promotion)
Description copied from interface:BuildQueueEx
Returnstrue
if changes should be collected for specified promotion while it is in build queue- Specified by:
shouldCollectChangesInQueue
in interfaceBuildQueueEx
- Parameters:
promotion
- build promotion of interest- Returns:
- see above
-
findQueued
@Nullable public QueuedBuildEx findQueued(@NotNull BuildPromotion promotion)
Description copied from interface:BuildQueueEx
Searches for a queued build item for the specified promotion- Specified by:
findQueued
in interfaceBuildQueueEx
- Returns:
- found item or null
-
getNumberOfItems
public int getNumberOfItems()
Description copied from interface:BuildQueue
Returns number of items currently in the queue- Specified by:
getNumberOfItems
in interfaceBuildQueue
- Returns:
- number of items currently in the queue
-
findQueued
@Nullable public QueuedBuildEx findQueued(@NotNull String buildTypeId, Integer agentId)
Description copied from interface:BuildQueue
Looks for build configuration with specified id scheduled to run on specified agent in the queue.- Specified by:
findQueued
in interfaceBuildQueue
- Specified by:
findQueued
in interfaceBuildQueueEx
- Parameters:
buildTypeId
- id of build configuration to search foragentId
- id of the agent. If not null only build configuration scheduled to specified agent will be returned. If null then build configuration which is not scheduled to any specific agent is returned.- Returns:
- found item or null
-
findQueued
@Nullable public QueuedBuildEx findQueued(@NotNull String itemId)
Description copied from interface:BuildQueue
Searches for an item in queue with specified item id.- Specified by:
findQueued
in interfaceBuildQueue
- Specified by:
findQueued
in interfaceBuildQueueEx
- Parameters:
itemId
- id of the item to look for.- Returns:
- found item or null
-
isInQueue
public boolean isInQueue(@NotNull String buildTypeId)
Description copied from interface:BuildQueue
Returns true if build configuration is already in queue.- Specified by:
isInQueue
in interfaceBuildQueue
- Parameters:
buildTypeId
- id of build configuration- Returns:
- if the specified configuration is in the queue.
-
isQueueEmpty
public boolean isQueueEmpty()
Description copied from interface:BuildQueue
Checks if queue is empty.- Specified by:
isQueueEmpty
in interfaceBuildQueue
- Returns:
- true if queue is empty.
-
getFirst
@Nullable public SQueuedBuild getFirst()
Description copied from interface:BuildQueue
Returns first queue element.- Specified by:
getFirst
in interfaceBuildQueue
- Returns:
- first queue element, null is queue is empty.
-
getLast
@Nullable public SQueuedBuild getLast()
Description copied from interface:BuildQueue
Returns last queue element.- Specified by:
getLast
in interfaceBuildQueue
- Returns:
- last queue element, null is queue is empty.
-
removeItems
public void removeItems(@NotNull Collection<String> itemIds, @Nullable SUser user, @Nullable String comment)
Description copied from interface:BuildQueue
Removes items with specified ids from the queue- Specified by:
removeItems
in interfaceBuildQueue
- Parameters:
itemIds
- ids items to removeuser
- user who performs operationcomment
- comment to use for remove operation
-
removeQueuedBuilds
public void removeQueuedBuilds(@NotNull Collection<SQueuedBuild> items, @Nullable SUser user, @Nullable String comment)
Description copied from interface:BuildQueue
Removes specified items from the queue- Specified by:
removeQueuedBuilds
in interfaceBuildQueue
- Parameters:
items
- items to removeuser
- user who performs operationcomment
- comment to use for remove operation
-
removeMatchedItems
public void removeMatchedItems(@NotNull Filter<SQueuedBuild> itemsFilter, @Nullable SUser user, @Nullable String comment)
Description copied from interface:BuildQueueEx
Removes items matched by the specified filter from the queue- Specified by:
removeMatchedItems
in interfaceBuildQueueEx
- Parameters:
itemsFilter
- queue items filteruser
- user who performs operation, if user is not null then build will be cancelled, otherwise it can be completely removed if there are no started builds depending on itcomment
- comment to use for remove operation
-
cancelMatchedItems
public void cancelMatchedItems(@NotNull Filter<SQueuedBuild> itemsFilter, @Nullable SUser user, @Nullable String comment)
Description copied from interface:BuildQueueEx
Removes and cancels items matched by the specified filter. The main difference of this method andBuildQueueEx.removeMatchedItems(Filter, SUser, String)
is that this method always creates cancelled builds in history for removed queued items, while removeMatchedItems can skip creating cancelled builds if user is not specified- Specified by:
cancelMatchedItems
in interfaceBuildQueueEx
- Parameters:
itemsFilter
- queue items filteruser
- user who performs operationcomment
- comment to use for remove operation
-
terminateQueuedBuild
public void terminateQueuedBuild(@NotNull SQueuedBuild queuedBuild, @Nullable SUser user, boolean isCanceled, @Nullable String comment, @NotNull BuildProblemData buildProblemData)
Description copied from interface:BuildQueueEx
Removes specified queued build from the queue and creates a history build entry for it.- Specified by:
terminateQueuedBuild
in interfaceBuildQueueEx
- Parameters:
queuedBuild
- a queued build to terminateuser
- user who performs operationisCanceled
- whether to create cancelation info for a history build entry. Status of the created build is also detrmined by this parameter: true->UNKNOWN, false->FAILURE.comment
- comment to use for logging during remove operation as well as cancellation info comment if 'isCanceled' is truebuildProblemData
- build problem to add to the history build
-
addToQueue
@NotNull public List<QueuedBuildEx> addToQueue(@NotNull Map<BuildPromotionEx,SAgentRestrictor> promoAgentRestrictorMap, @NotNull String rawTriggeredBy)
Description copied from interface:BuildQueueEx
Adds promotions to the queue with corresponding agent restrictors (if agent restrictor is null then no agent restrictor is used). If same build is already in queue then new build is not added. If promotion has associated graph then it must be top of this graph. All nodes of the graph will be added in the queue. If chains passed to this method intersects in personal build nodes then only one personal build will be added in queue for each intersection. Returns newly added builds and currently queued builds for not added builds.- Specified by:
addToQueue
in interfaceBuildQueueEx
- Parameters:
promoAgentRestrictorMap
- map of top promotion to agent restrictorsrawTriggeredBy
- triggered by- Returns:
- see above
-
setOrderingStrategy
public void setOrderingStrategy(@NotNull BuildQueueOrderingStrategy strategy)
Description copied from interface:BuildQueueEx
Assign ordering strategy for this build queue- Specified by:
setOrderingStrategy
in interfaceBuildQueueEx
- Parameters:
strategy
- new ordering strategy
-
newTriggerTask
@NotNull public TriggerTask newTriggerTask(@NotNull BuildPromotion promotion)
Description copied from interface:BatchTrigger
Creates new trigger task based on specified build promotion.- Specified by:
newTriggerTask
in interfaceBatchTrigger
- Parameters:
promotion
- build promotion which will be added to the queue- Returns:
- new task
-
processTasks
@NotNull public List<SQueuedBuild> processTasks(@NotNull Collection<TriggerTask> tasks, @NotNull String triggeredBy)
Description copied from interface:BatchTrigger
Processes collection of trigger tasks, by adding builds in the queue with parameters specified in these tasks.- Specified by:
processTasks
in interfaceBatchTrigger
- Parameters:
tasks
- trigger tasks describing how to add builds in the queuetriggeredBy
- some information about who triggers these builds- Returns:
- list of queued builds, sorted by their order number in the queue
-
moveDependenciesToTop
public void moveDependenciesToTop(@NotNull BuildPromotion promotion)
Description copied from interface:BuildQueueEx
Moves dependencies of given promotion to the top of the queue- Specified by:
moveDependenciesToTop
in interfaceBuildQueueEx
- Parameters:
promotion
- build promotion
-
scheduleBuildQueueReload
public void scheduleBuildQueueReload()
Description copied from interface:BuildQueueEx
Sends event to reload queue from database (for debug API, TW-85394)- Specified by:
scheduleBuildQueueReload
in interfaceBuildQueueEx
-
-