Package com.atlassian.bamboo.chains
Class ChainExecutionManagerImpl
- java.lang.Object
-
- com.atlassian.bamboo.chains.ChainExecutionManagerImpl
-
- All Implemented Interfaces:
ChainExecutionAccessor
,ChainExecutionManager
public class ChainExecutionManagerImpl extends Object implements ChainExecutionManager
This class is registered as event listenerpostConstruct()
-
-
Constructor Summary
Constructors Constructor Description 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)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description @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 alreadyChainExecutionRequestResult
delayedStart(@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@Nullable BuildExecution
getJobExecution(@NotNull PlanResultKey planResultKey)
Get the state of a single Job being executedboolean
isActive(@NotNull PlanKey planKey)
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
logChainExecutionState()
Log activeChainExecution
sint
numberOfChainsExecuting()
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
onJobSentToAgent(BuildTimingPoints.SentToAgent event)
Set<PlanResultKey>
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
stop(@NotNull PlanKey planKey)
void
stop(@NotNull PlanResultKey planResultKey)
Stops the executing instance of theChain
represented byPlanResultKey
-
-
-
Field Detail
-
MERGE_DIR
public static final String MERGE_DIR
- See Also:
- Constant Field Values
-
-
Constructor Detail
-
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)
-
-
Method Detail
-
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
@EventListener public void onChainRemoved(@NotNull @NotNull ChainDeletedEvent chainDeletedEvent)
-
onChainRemoved
@EventListener public void onChainRemoved(@NotNull @NotNull MultipleChainsDeletedEvent chainDeletedEvent)
-
onJobSentToAgent
@EventListener public void onJobSentToAgent(@NotNull BuildTimingPoints.SentToAgent event)
-
onBuildFinished
@EventListener @HibernateEventListenerAspect public void onBuildFinished(BuildFinishedEvent buildFinishedEvent)
-
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
public void stop(@NotNull @NotNull PlanResultKey planResultKey)
Description copied from interface:ChainExecutionManager
Stops the executing instance of theChain
represented byPlanResultKey
- Specified by:
stop
in interfaceChainExecutionManager
-
stop
public void stop(@NotNull @NotNull PlanKey planKey)
Description copied from interface:ChainExecutionManager
- Specified by:
stop
in interfaceChainExecutionManager
-
isActive
public boolean isActive(@NotNull @NotNull PlanKey planKey)
Description copied from interface:ChainExecutionAccessor
Checks if theChain
is "active" ie being queued, or building- Specified by:
isActive
in interfaceChainExecutionAccessor
- Returns:
- active
-
isExecuting
public boolean isExecuting(@NotNull @NotNull PlanKey planKey)
Description copied from interface:ChainExecutionAccessor
Checks if the Chain is building- Specified by:
isExecuting
in interfaceChainExecutionAccessor
- Returns:
- running
-
isExecuting
public boolean isExecuting(@NotNull @NotNull PlanResultKey planResultKey)
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
@NotNull public @NotNull List<ChainExecution> getExecutingChains(@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- Specified by:
getExecutingChains
in interfaceChainExecutionAccessor
- Returns:
- chainExecution
-
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
public int numberOfChainsExecuting(@NotNull @NotNull PlanKey planKey)
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, InterruptedException
Description 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
-
-