Class BuildPromotionManagerImpl
- java.lang.Object
-
- jetbrains.buildServer.serverSide.impl.BuildPromotionManagerImpl
-
- All Implemented Interfaces:
BuildPromotionFactory
,BuildPromotionManager
,BuildPromotionManagerEx
public class BuildPromotionManagerImpl extends Object implements BuildPromotionManagerEx
- Author:
- Pavel.Sher Date: 21.05.2008
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description class
BuildPromotionManagerImpl.TemplateDummyBuildPromotion
-
Nested classes/interfaces inherited from interface jetbrains.buildServer.serverSide.BuildPromotionManager
BuildPromotionManager.BuildPromotionInitFromDbHint
-
-
Field Summary
Fields Modifier and Type Field Description static int
FINISHED_PROMOTION_EXPIRATION_COUNTER
static String
PROMOTIONS_CACHE_EXPIRATION_CHECK_THRESHOLD
-
Constructor Summary
Constructors Constructor Description BuildPromotionManagerImpl(EventDispatcher<BuildPromotionListener> buildPromotionListenerEventDispatcher, ServerResponsibility serverResponsibility, ExecutorServices executorServices)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description void
buildsRemoved(String buildTypeId, BuildTypeRemovedBuilds predicate)
void
clearCachedPromotions()
DummyBuildPromotion
createDummyPromotion(String branchName, BuildTypeEx buildType)
Creates dummy (not real) build promotion, a build won't be able to start with this promotionDummyBuildPromotion
createDummyPromotion(BuildTypeTemplateEx template)
Creates dummy (not real) build promotion, a build won't be able to start with this promotionBuildPromotionEx
createNewPromotion(SBuildType buildType)
Creates new promotion for specified build configurationBuildPromotionEx
findCached(long promotionId)
Collection<BuildPromotionEx>
findCached(Collection<Long> ids)
BuildPromotionEx
findPromotionById(long promoId)
Searches for a promotion with specified id.BuildPromotion
findPromotionOrReplacement(long origPromotionId)
The method will return the original build promotion if it was not deleted by the queue optimization process.Collection<BuildPromotion>
findPromotionsByIds(Collection<Long> promoIds, BuildPromotionManager.BuildPromotionInitFromDbHint... initHints)
Accepts collection of promotion ids and returns corresponding objects.BuildPromotionContext
getContext()
EventDispatcher<BuildPromotionListener>
getDispatcher()
Long
getLastBorrowedModificationId(SBuildType buildType, boolean ignoreCanceledAndNotStarted)
Returns max modification id associated with last created promotion in the specified build configuration.Long
getMaxUsedModificationId(SBuildType buildType, String branch)
Returns max modification id associated with last created promotion in the specified build configuration in the given branch.BuildPromotionEx
getPromotionById(long promotionId)
Searches for a promotion with specified id.int
getSize()
void
promotionDeleted(BuildPromotionEx promo)
void
promotionPersisted(BuildPromotionEx promotion)
void
resetChanges(Collection<SProject> projects)
Resets changes in promotions from specified projectsvoid
runCachedItemsExpirationCheck()
void
setContext(BuildPromotionContext context)
void
setEventDispatcher(EventDispatcher<BuildServerListener> eventDispatcher)
void
setSqlRunner(SQLRunnerEx sqlRunner)
void
traverseCachedBuildTypePromotions(Set<String> buildTypeIds, ItemProcessor<BuildPromotionEx> processor)
-
-
-
Field Detail
-
FINISHED_PROMOTION_EXPIRATION_COUNTER
public static final int FINISHED_PROMOTION_EXPIRATION_COUNTER
- See Also:
- Constant Field Values
-
PROMOTIONS_CACHE_EXPIRATION_CHECK_THRESHOLD
public static final String PROMOTIONS_CACHE_EXPIRATION_CHECK_THRESHOLD
- See Also:
- Constant Field Values
-
-
Constructor Detail
-
BuildPromotionManagerImpl
public BuildPromotionManagerImpl(@NotNull EventDispatcher<BuildPromotionListener> buildPromotionListenerEventDispatcher, @NotNull ServerResponsibility serverResponsibility, @NotNull ExecutorServices executorServices)
-
-
Method Detail
-
getContext
@NotNull public BuildPromotionContext getContext()
-
setContext
public void setContext(@NotNull BuildPromotionContext context)
-
setSqlRunner
public void setSqlRunner(@NotNull SQLRunnerEx sqlRunner)
-
setEventDispatcher
public void setEventDispatcher(@NotNull EventDispatcher<BuildServerListener> eventDispatcher)
-
getSize
public int getSize()
-
traverseCachedBuildTypePromotions
public void traverseCachedBuildTypePromotions(@NotNull Set<String> buildTypeIds, @NotNull ItemProcessor<BuildPromotionEx> processor)
-
createNewPromotion
@NotNull public BuildPromotionEx createNewPromotion(@NotNull SBuildType buildType)
Description copied from interface:BuildPromotionFactory
Creates new promotion for specified build configuration- Specified by:
createNewPromotion
in interfaceBuildPromotionFactory
- Parameters:
buildType
- build configuration (for personal promotion - RemoteBuildType)- Returns:
- newly created build promotion
-
createDummyPromotion
@NotNull public DummyBuildPromotion createDummyPromotion(@NotNull String branchName, @NotNull BuildTypeEx buildType)
Description copied from interface:BuildPromotionFactory
Creates dummy (not real) build promotion, a build won't be able to start with this promotion- Specified by:
createDummyPromotion
in interfaceBuildPromotionFactory
buildType
- build configuration- Returns:
- see above
-
createDummyPromotion
@NotNull public DummyBuildPromotion createDummyPromotion(@NotNull BuildTypeTemplateEx template)
Description copied from interface:BuildPromotionFactory
Creates dummy (not real) build promotion, a build won't be able to start with this promotion- Specified by:
createDummyPromotion
in interfaceBuildPromotionFactory
- Parameters:
template
- build configuration template for which promotion is created- Returns:
- see above
-
getDispatcher
@NotNull public EventDispatcher<BuildPromotionListener> getDispatcher()
- Specified by:
getDispatcher
in interfaceBuildPromotionManager
-
getPromotionById
@NotNull public BuildPromotionEx getPromotionById(long promotionId) throws InvalidBuildPromotionException
Description copied from interface:BuildPromotionManager
Searches for a promotion with specified id.- Specified by:
getPromotionById
in interfaceBuildPromotionManager
- Parameters:
promotionId
- id of promotion- Returns:
- loaded promotion
- Throws:
InvalidBuildPromotionException
- if promotion with specified id does not exist or is invalid
-
findCached
@Nullable public BuildPromotionEx findCached(long promotionId)
- Specified by:
findCached
in interfaceBuildPromotionManagerEx
-
findCached
@NotNull public Collection<BuildPromotionEx> findCached(@NotNull Collection<Long> ids)
- Specified by:
findCached
in interfaceBuildPromotionManagerEx
-
getLastBorrowedModificationId
@Nullable public Long getLastBorrowedModificationId(@NotNull SBuildType buildType, boolean ignoreCanceledAndNotStarted)
Description copied from interface:BuildPromotionManager
Returns max modification id associated with last created promotion in the specified build configuration.- Specified by:
getLastBorrowedModificationId
in interfaceBuildPromotionManager
- Parameters:
buildType
- build configuration (personal build configurations are accepted too)ignoreCanceledAndNotStarted
- if true then cancelled and not yet started promotions are excluded- Returns:
- see above
-
getMaxUsedModificationId
@Nullable public Long getMaxUsedModificationId(@NotNull SBuildType buildType, @NotNull String branch)
Description copied from interface:BuildPromotionManager
Returns max modification id associated with last created promotion in the specified build configuration in the given branch.- Specified by:
getMaxUsedModificationId
in interfaceBuildPromotionManager
- Parameters:
buildType
- build type of interest (personal build configurations are accepted too)branch
- branch of interest, empty branch means default- Returns:
- see above
-
findPromotionById
@Nullable public BuildPromotionEx findPromotionById(long promoId)
Description copied from interface:BuildPromotionManagerEx
Searches for a promotion with specified id. Similar toBuildPromotionManager.getPromotionById(long)
but does not throw exception if promotion with specified id does not exist.- Specified by:
findPromotionById
in interfaceBuildPromotionManager
- Specified by:
findPromotionById
in interfaceBuildPromotionManagerEx
- Parameters:
promoId
- id of the promotion- Returns:
- see above
-
findPromotionOrReplacement
@Nullable public BuildPromotion findPromotionOrReplacement(long origPromotionId)
Description copied from interface:BuildPromotionManager
The method will return the original build promotion if it was not deleted by the queue optimization process. If this is the case, then the method will try to locate a replacement and return the replacement instead.- Specified by:
findPromotionOrReplacement
in interfaceBuildPromotionManager
- Parameters:
origPromotionId
- id of original promotion- Returns:
- replacement promotion if original promotion was replaced and marked as deleted, or original promotion if it exists.
-
findPromotionsByIds
@NotNull public Collection<BuildPromotion> findPromotionsByIds(@NotNull Collection<Long> promoIds, BuildPromotionManager.BuildPromotionInitFromDbHint... initHints)
Description copied from interface:BuildPromotionManager
Accepts collection of promotion ids and returns corresponding objects. Order of returned objects may not be the same as order of ids passed as argument.- Specified by:
findPromotionsByIds
in interfaceBuildPromotionManager
- Parameters:
promoIds
- ids of promotionsinitHints
- if promotion is not in cache and is loaded from the database, these hints specify what information should be prefetched from the DB- Returns:
- found build promotions
-
promotionPersisted
public void promotionPersisted(@NotNull BuildPromotionEx promotion)
- Specified by:
promotionPersisted
in interfaceBuildPromotionManagerEx
-
promotionDeleted
public void promotionDeleted(@NotNull BuildPromotionEx promo)
- Specified by:
promotionDeleted
in interfaceBuildPromotionManagerEx
-
buildsRemoved
public void buildsRemoved(@NotNull String buildTypeId, @NotNull BuildTypeRemovedBuilds predicate)
- Specified by:
buildsRemoved
in interfaceBuildPromotionManagerEx
-
resetChanges
public void resetChanges(@NotNull Collection<SProject> projects)
Description copied from interface:BuildPromotionManagerEx
Resets changes in promotions from specified projects- Specified by:
resetChanges
in interfaceBuildPromotionManagerEx
- Parameters:
projects
- projects for changes reset
-
runCachedItemsExpirationCheck
public void runCachedItemsExpirationCheck()
-
clearCachedPromotions
public void clearCachedPromotions()
-
-