Package com.atlassian.bamboo.chains
Class ChainExecutionManagerImpl
java.lang.Object
com.atlassian.bamboo.chains.ChainExecutionManagerImpl
- All Implemented Interfaces:
ChainExecutionAccessor
,ChainExecutionManager
This class is registered as event listener
postConstruct()
-
Field Summary
-
Constructor Summary
ConstructorDescriptionChainExecutionManagerImpl
(PlanStatePersisterService planStatePersisterService, JobExecutionManager buildContextExecutor, ChainStateFactory chainStateFactory, BuildContextFactory buildContextFactory, com.atlassian.event.api.EventPublisher eventPublisher, ChainPluginSupport chainPluginSupport, ErrorUpdateHandler errorUpdateHandler, AuthorCreatorService authorCreatorService, ResultsSummaryManager resultsSummaryManager, BuildDirectoryManager buildDirectoryManager, VcsBranchIntegrationHelper branchIntegrationHelper, CustomVariableContext customVariableContext, PlanExecutionLockService planExecutionLockService, PlanVcsRevisionHistoryService planVcsRevisionHistoryService, CachedPlanManager cachedPlanManager, VcsRepositoryManager vcsRepositoryManager, StorageTagService storageTagService, PlanBranchPullRequestService planBranchPullRequestService, StorageLocationService storageLocationService, ServerBuildLoggerManager buildLoggerManager, DeploymentVersionService deploymentVersionService, ChainStatePersister chainStatePersister, BambooOpenSessionTemplate bambooOpenSessionTemplate) -
Method Summary
Modifier and TypeMethodDescription@NotNull ChainStateCreationRequestResult
createChainStateNoDetection
(@NotNull ImmutableChain chain, @NotNull UnconditionalBuildDetectionAction buildDetectionAction) Create a chain state ready for building but dont actually build.@NotNull ChainExecutionRequestResult
delayedStart
(@NotNull ImmutableChain chain, @NotNull UnconditionalBuildDetectionAction buildDetectionAction, @NotNull ChainState chainState) Starts the Chain if it's been created alreadydelayedStart
(@NotNull ImmutableChain chain, @NotNull UnconditionalBuildDetectionAction buildDetectionAction, @NotNull ChainState chainState, PlanExecutionLaunchControl.ReleaseLocksActions releaseLocksActions) Starts the Chain if it's been created already@Nullable ChainExecution
getChainExecution
(@NotNull PlanResultKey planResultKey) Get the state of the single ChainExecution@NotNull List<ChainExecution>
getExecutingChains
(@NotNull PlanKey planKey) Get the Collection of the state of the ChainExecution or empty collection when no chain is executing@NotNull List<ChainExecution>
getFlatExecutingChains
(@NotNull PlanKey planKey) Get the Collection of the state of the ChainExecution or empty collection when no chain is executing.@Nullable BuildExecution
getJobExecution
(@NotNull PlanResultKey planResultKey) Get the state of a single Job being executedboolean
Checks if theChain
is "active" ie being queued, or buildingboolean
isExecuting
(@NotNull PlanKey planKey) Checks if the Chain is buildingboolean
isExecuting
(@NotNull PlanResultKey planResultKey) Checks ofBuildResultsSummary
represented byPlanResultKey
is currently building (ie started on an agent_void
Log activeChainExecution
sint
int
numberOfChainsExecuting
(@NotNull PlanKey planKey) Determines the number ofChainExecution
s are active for the givenPlanKey
void
onBuildFinished
(BuildFinishedEvent buildFinishedEvent) void
onChainRemoved
(@NotNull ChainDeletedEvent chainDeletedEvent) void
onChainRemoved
(@NotNull MultipleChainsDeletedEvent chainDeletedEvent) void
restoreState
(Set<PlanResultKey> chainResultsToRestore, Map<PlanResultKey, BuildResultsSummary> jobsInProgress, ExecutorService executorService) Restores the state of running chains after server restart on custom-provided executor service.@NotNull ChainExecutionRequestResult
start
(@NotNull ImmutableChain chain, @NotNull ConditionalBuildDetectionAction buildDetectionAction) Starts the Chainvoid
void
stop
(@NotNull PlanResultKey planResultKey) Stops the executing instance of theChain
represented byPlanResultKey
protected void
-
Field Details
-
MERGE_DIR
- See Also:
-
-
Constructor Details
-
ChainExecutionManagerImpl
public ChainExecutionManagerImpl(PlanStatePersisterService planStatePersisterService, JobExecutionManager buildContextExecutor, ChainStateFactory chainStateFactory, BuildContextFactory buildContextFactory, com.atlassian.event.api.EventPublisher eventPublisher, ChainPluginSupport chainPluginSupport, ErrorUpdateHandler errorUpdateHandler, AuthorCreatorService authorCreatorService, ResultsSummaryManager resultsSummaryManager, BuildDirectoryManager buildDirectoryManager, VcsBranchIntegrationHelper branchIntegrationHelper, CustomVariableContext customVariableContext, PlanExecutionLockService planExecutionLockService, PlanVcsRevisionHistoryService planVcsRevisionHistoryService, CachedPlanManager cachedPlanManager, VcsRepositoryManager vcsRepositoryManager, StorageTagService storageTagService, PlanBranchPullRequestService planBranchPullRequestService, StorageLocationService storageLocationService, ServerBuildLoggerManager buildLoggerManager, DeploymentVersionService deploymentVersionService, ChainStatePersister chainStatePersister, BambooOpenSessionTemplate bambooOpenSessionTemplate)
-
-
Method Details
-
start
@NotNull public @NotNull ChainExecutionRequestResult start(@NotNull @NotNull ImmutableChain chain, @NotNull @NotNull ConditionalBuildDetectionAction buildDetectionAction) Description copied from interface:ChainExecutionManager
Starts the Chain- Specified by:
start
in interfaceChainExecutionManager
- Returns:
- success or null if chain execution has not been started
-
delayedStart
@NotNull public @NotNull ChainExecutionRequestResult delayedStart(@NotNull @NotNull ImmutableChain chain, @NotNull @NotNull UnconditionalBuildDetectionAction buildDetectionAction, @NotNull @NotNull ChainState chainState) Description copied from interface:ChainExecutionManager
Starts the Chain if it's been created already- Specified by:
delayedStart
in interfaceChainExecutionManager
chainState
- if already created- Returns:
- success or null if chain execution has not been started
-
delayedStart
public ChainExecutionRequestResult delayedStart(@NotNull @NotNull ImmutableChain chain, @NotNull @NotNull UnconditionalBuildDetectionAction buildDetectionAction, @NotNull @NotNull ChainState chainState, @NotNull PlanExecutionLaunchControl.ReleaseLocksActions releaseLocksActions) Description copied from interface:ChainExecutionManager
Starts the Chain if it's been created already- Specified by:
delayedStart
in interfaceChainExecutionManager
chainState
- if already createdreleaseLocksActions
- actions used for releasing repositories caches locks- Returns:
- success or null if chain execution has not been started since 9.3
-
onChainRemoved
-
onChainRemoved
@EventListener public void onChainRemoved(@NotNull @NotNull MultipleChainsDeletedEvent chainDeletedEvent) -
onJobSentToAgent
-
onBuildFinished
-
createChainStateNoDetection
@NotNull public @NotNull ChainStateCreationRequestResult createChainStateNoDetection(@NotNull @NotNull ImmutableChain chain, @NotNull @NotNull UnconditionalBuildDetectionAction buildDetectionAction) Description copied from interface:ChainExecutionManager
Create a chain state ready for building but dont actually build.- Specified by:
createChainStateNoDetection
in interfaceChainExecutionManager
- Returns:
-
stop
Description copied from interface:ChainExecutionManager
Stops the executing instance of theChain
represented byPlanResultKey
- Specified by:
stop
in interfaceChainExecutionManager
-
stop
Description copied from interface:ChainExecutionManager
- Specified by:
stop
in interfaceChainExecutionManager
-
isActive
Description copied from interface:ChainExecutionAccessor
Checks if theChain
is "active" ie being queued, or building- Specified by:
isActive
in interfaceChainExecutionAccessor
- Returns:
- active
-
isExecuting
Description copied from interface:ChainExecutionAccessor
Checks if the Chain is building- Specified by:
isExecuting
in interfaceChainExecutionAccessor
- Returns:
- running
-
isExecuting
Description copied from interface:ChainExecutionAccessor
Checks ofBuildResultsSummary
represented byPlanResultKey
is currently building (ie started on an agent_- Specified by:
isExecuting
in interfaceChainExecutionAccessor
- Returns:
- executing
-
getExecutingChains
Description copied from interface:ChainExecutionAccessor
Get the Collection of the state of the ChainExecution or empty collection when no chain is executing- Specified by:
getExecutingChains
in interfaceChainExecutionAccessor
- Returns:
- list of chain executions
-
getFlatExecutingChains
@NotNull public @NotNull List<ChainExecution> getFlatExecutingChains(@NotNull @NotNull PlanKey planKey) Description copied from interface:ChainExecutionAccessor
Get the Collection of the state of the ChainExecution or empty collection when no chain is executing. Flat means no stages or jobs data is included.- Specified by:
getFlatExecutingChains
in interfaceChainExecutionAccessor
- Parameters:
planKey
- plan key- Returns:
- list of flat chain executions
-
getChainExecution
@Nullable public @Nullable ChainExecution getChainExecution(@NotNull @NotNull PlanResultKey planResultKey) Description copied from interface:ChainExecutionAccessor
Get the state of the single ChainExecution- Specified by:
getChainExecution
in interfaceChainExecutionAccessor
- Returns:
-
getJobExecution
@Nullable public @Nullable BuildExecution getJobExecution(@NotNull @NotNull PlanResultKey planResultKey) Description copied from interface:ChainExecutionAccessor
Get the state of a single Job being executed- Specified by:
getJobExecution
in interfaceChainExecutionAccessor
- Returns:
-
numberOfChainsExecuting
Description copied from interface:ChainExecutionAccessor
Determines the number ofChainExecution
s are active for the givenPlanKey
- Specified by:
numberOfChainsExecuting
in interfaceChainExecutionAccessor
- Returns:
-
logChainExecutionState
public void logChainExecutionState()Description copied from interface:ChainExecutionAccessor
Log activeChainExecution
s- Specified by:
logChainExecutionState
in interfaceChainExecutionAccessor
-
numberOfChainsExecuting
public int numberOfChainsExecuting()- Specified by:
numberOfChainsExecuting
in interfaceChainExecutionAccessor
- Returns:
- total number of active
ChainExecution
s
-
restoreState
public Set<PlanResultKey> restoreState(Set<PlanResultKey> chainResultsToRestore, Map<PlanResultKey, BuildResultsSummary> jobsInProgress, ExecutorService executorService) throws ExecutionException, InterruptedExceptionDescription copied from interface:ChainExecutionManager
Restores the state of running chains after server restart on custom-provided executor service.- Specified by:
restoreState
in interfaceChainExecutionManager
- Returns:
- keys of jobs that are running according to stored chain states.
- Throws:
ExecutionException
InterruptedException
-
useDirectExecutor
protected void useDirectExecutor()
-