com.atlassian.bamboo.build
Class DefaultBuildExecutionManager

java.lang.Object
  extended by com.atlassian.bamboo.build.DefaultBuildExecutionManager
All Implemented Interfaces:
BuildExecutionManager, BuildExecutionUpdateManager, BuildLoggerManager

public class DefaultBuildExecutionManager
extends java.lang.Object
implements BuildExecutionManager


Field Summary
 
Fields inherited from interface com.atlassian.bamboo.build.BuildExecutionManager
DEFAULT_WAITTIME
 
Constructor Summary
DefaultBuildExecutionManager()
           
 
Method Summary
 void addToCurrentlyBuilding(BuildContext buildContext)
          Denotes that the passed build context is beginning the build process.
 void execute(BuildContext buildContext)
          Checks if the Build is already building and if successful executes the BuildContext At this point a BuildResultsSummary that matches the given BuildContext
 void finishBuild(java.lang.String buildResultKey)
          Calls removeCurrentlyBuilding & finishProcess
 void finishProcess(java.lang.String planKey)
          Unmark the build for processing
 BuildLogger getBuildLogger(PlanKey planKey)
          Returns a BuildLogger for the given plan
 BuildLogger getBuildLogger(PlanResultKey resultKey)
          Returns a BuildLogger for the given result
 BuildLogger getBuildLogger(java.lang.String planOrResultKey)
          Returns a BuildLogger for the given plan or result key.
 CurrentlyBuilding getBuildRunningOnAgent(java.lang.Long buildAgentId)
           
 java.util.List<CurrentlyBuilding> getCurrentlyBuilding(java.lang.String planKey)
           
 CurrentlyBuilding getCurrentlyBuildingByBuildResult(BuildIdentifier buildIdentifier)
          Returns CurrentlyBuilding instance for build identifier (or BuildContext).
 CurrentlyBuilding getCurrentlyBuildingByBuildResultKey(java.lang.String buildResultKey)
          Returns CurrentlyBuilding instance for build identified by buildResultKey.
 java.util.List<CurrentlyBuilding> getCurrentlyExecutingBuilds()
          Retrieves a list of all builds being executed (i.e not just queued).
 boolean isBeingProcessed(java.lang.String planKey)
          Checks if this buildKey is being actively processed
 void removeBuildLogger(PlanKey planKey)
          Removes plan logger for given plan key.
 void removeBuildLogger(PlanResultKey buildResultKey)
          Removes buildLogger for finished build process.
 CurrentlyBuilding removeCurrentlyBuilding(java.lang.String planKey)
           
 void setAuthorCreatorService(AuthorCreatorService authorCreatorService)
           
 void setBuildFinish(BuildContext buildContext, TimingPoint timingPoint)
           
 void setBuildLoggerManager(BuildLoggerManager buildLoggerManager)
           
 void setBuildManager(BuildManager buildManager)
           
 void setBuildNumberGeneratorService(BuildNumberGeneratorService buildNumberGeneratorService)
           
 void setBuildResultsSummaryManager(BuildResultsSummaryManager buildResultsSummaryManager)
           
 void setBuildRunningOnAgent(BuildContext buildContext, java.lang.Long buildAgentId)
          Marks that this plan has started building on the agentId.
 void setBuildStart(BuildContext buildContext, TimingPoint timingPoint)
           
 void setChangeDetectionManager(ChangeDetectionManager changeDetectionManager)
           
 void setCurrentlyBuilding(BuildContext buildContext, java.util.Collection<BuildAgent> executableAgents)
          Denotes that the passed build context is beginning the build process.
 void setCurrentlyBuilding(BuildContext buildContext, java.util.Collection<BuildAgent> executableAgents, java.util.Collection<ElasticImageConfiguration> executableImages)
          Denotes that the passed build context is beginning the build process.
 void setErrorUpdateHandler(ErrorUpdateHandler errorUpdateHandler)
           
 void setEventManager(com.atlassian.event.EventManager eventManager)
           
 void setLimitedConcurrencyCaller(LimitedConcurrencyCaller limitedConcurrencyCaller)
           
 void setPendingBuildResultsCleanup(PendingBuildResultsCleanup pendingBuildResultsCleanup)
           
 void setTriggerReasonManager(TriggerReasonManager triggerReasonManager)
           
 void startManualBuild(Build buildPlan, com.atlassian.user.User user)
           
 void startManualBuild(Build buildPlan, com.atlassian.user.User user, java.util.Map<java.lang.String,java.lang.String> params)
           
 boolean tryToBuild(java.lang.String planKey, boolean wait)
          Attempts to build the passed planKey.
 boolean tryToDetectAndBuild(java.lang.String planKey, BuildDetectionAction buildDetectionAction, boolean waitForProcessLock)
          Wraps up the passed callback BuildDetectionAction in a process lock, and also a check for currentlyBuilding.
 boolean tryToProcess(java.lang.String planKey)
          Attempts to gain control to process the build.
 boolean waitToProcess(java.lang.String planKey)
          Attempts to process the plan for up to BuildExecutionManager.DEFAULT_WAITTIME time.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

DefaultBuildExecutionManager

public DefaultBuildExecutionManager()
Method Detail

isBeingProcessed

public boolean isBeingProcessed(@NotNull
                                java.lang.String planKey)
Description copied from interface: BuildExecutionManager
Checks if this buildKey is being actively processed

Specified by:
isBeingProcessed in interface BuildExecutionManager
Returns:
true if the builds is being processed

tryToProcess

public boolean tryToProcess(@NotNull
                            java.lang.String planKey)
Description copied from interface: BuildExecutionManager
Attempts to gain control to process the build. Returns true if access acquired and false if not successful

Specified by:
tryToProcess in interface BuildExecutionManager
Returns:
true to process acquisition successful and false if not

execute

public void execute(@NotNull
                    BuildContext buildContext)
Description copied from interface: BuildExecutionManager
Checks if the Build is already building and if successful executes the BuildContext At this point a BuildResultsSummary that matches the given BuildContext

Specified by:
execute in interface BuildExecutionManager

tryToDetectAndBuild

public boolean tryToDetectAndBuild(@NotNull
                                   java.lang.String planKey,
                                   @NotNull
                                   BuildDetectionAction buildDetectionAction,
                                   boolean waitForProcessLock)
Description copied from interface: BuildExecutionManager
Wraps up the passed callback BuildDetectionAction in a process lock, and also a check for currentlyBuilding. Will fire off BuildTriggeredEvent if the callback completes successfully and a BuildContext is returned by the callback action.

Specified by:
tryToDetectAndBuild in interface BuildExecutionManager
Returns:
success

waitToProcess

public boolean waitToProcess(@NotNull
                             java.lang.String planKey)
Description copied from interface: BuildExecutionManager
Attempts to process the plan for up to BuildExecutionManager.DEFAULT_WAITTIME time. You can force the method to abort and return by calling Thread.interrupt()

Specified by:
waitToProcess in interface BuildExecutionManager
Returns:
true if the "lock" has been obtianed, false if not

finishProcess

public void finishProcess(@NotNull
                          java.lang.String planKey)
Description copied from interface: BuildExecutionManager
Unmark the build for processing

Specified by:
finishProcess in interface BuildExecutionManager

startManualBuild

public void startManualBuild(@NotNull
                             Build buildPlan,
                             @NotNull
                             com.atlassian.user.User user)
Specified by:
startManualBuild in interface BuildExecutionManager

startManualBuild

public void startManualBuild(@NotNull
                             Build buildPlan,
                             @NotNull
                             com.atlassian.user.User user,
                             @NotNull
                             java.util.Map<java.lang.String,java.lang.String> params)
Specified by:
startManualBuild in interface BuildExecutionManager

getCurrentlyExecutingBuilds

public java.util.List<CurrentlyBuilding> getCurrentlyExecutingBuilds()
Description copied from interface: BuildExecutionManager
Retrieves a list of all builds being executed (i.e not just queued).

Specified by:
getCurrentlyExecutingBuilds in interface BuildExecutionManager
Returns:

getCurrentlyBuilding

@NotNull
public java.util.List<CurrentlyBuilding> getCurrentlyBuilding(@NotNull
                                                                      java.lang.String planKey)
Specified by:
getCurrentlyBuilding in interface BuildExecutionManager

getCurrentlyBuildingByBuildResultKey

public CurrentlyBuilding getCurrentlyBuildingByBuildResultKey(@NotNull
                                                              java.lang.String buildResultKey)
Description copied from interface: BuildExecutionManager
Returns CurrentlyBuilding instance for build identified by buildResultKey. Should be used only if BuildIdentifier is not available - basically in actions

Specified by:
getCurrentlyBuildingByBuildResultKey in interface BuildExecutionManager
Returns:

getCurrentlyBuildingByBuildResult

public CurrentlyBuilding getCurrentlyBuildingByBuildResult(@NotNull
                                                           BuildIdentifier buildIdentifier)
Description copied from interface: BuildExecutionManager
Returns CurrentlyBuilding instance for build identifier (or BuildContext).

Specified by:
getCurrentlyBuildingByBuildResult in interface BuildExecutionManager
Returns:

setCurrentlyBuilding

public void setCurrentlyBuilding(@NotNull
                                 BuildContext buildContext,
                                 @NotNull
                                 java.util.Collection<BuildAgent> executableAgents,
                                 @NotNull
                                 java.util.Collection<ElasticImageConfiguration> executableImages)
Denotes that the passed build context is beginning the build process. (i.e. it's being queued). Executable build agent lists are considered to be up to date if this method is used.

Specified by:
setCurrentlyBuilding in interface BuildExecutionManager
Parameters:
buildContext -
executableAgents - - a list of agents on which this build can be run.
executableImages - - a list of images on which the build can be run.

setCurrentlyBuilding

public void setCurrentlyBuilding(@NotNull
                                 BuildContext buildContext,
                                 @NotNull
                                 java.util.Collection<BuildAgent> executableAgents)
Description copied from interface: BuildExecutionManager
Denotes that the passed build context is beginning the build process. (i.e. it's being queued)

Specified by:
setCurrentlyBuilding in interface BuildExecutionManager
executableAgents - - a list of agents on which this build can be run.

addToCurrentlyBuilding

public void addToCurrentlyBuilding(@NotNull
                                   BuildContext buildContext)
Denotes that the passed build context is beginning the build process. (i.e. it's being queued). Executable build agent lists are considered to be not yet initialized if this method is used.

Specified by:
addToCurrentlyBuilding in interface BuildExecutionManager
Parameters:
buildContext -

setBuildRunningOnAgent

public void setBuildRunningOnAgent(@NotNull
                                   BuildContext buildContext,
                                   java.lang.Long buildAgentId)
Description copied from interface: BuildExecutionUpdateManager
Marks that this plan has started building on the agentId.

Specified by:
setBuildRunningOnAgent in interface BuildExecutionUpdateManager

getBuildRunningOnAgent

public CurrentlyBuilding getBuildRunningOnAgent(@NotNull
                                                java.lang.Long buildAgentId)
Specified by:
getBuildRunningOnAgent in interface BuildExecutionManager

tryToBuild

public boolean tryToBuild(@NotNull
                          java.lang.String planKey,
                          boolean wait)
Attempts to build the passed planKey. A simple shortcut method that calls BuildManager.isAllowBuilding(String), getCurrentlyBuilding(String) and tryToProcess(String). If the call returns true, you also have the "lock" on the plan.

Specified by:
tryToBuild in interface BuildExecutionManager
Parameters:
planKey -
wait - should it return fast, or wait if can't get the lock
Returns:

finishBuild

public void finishBuild(@NotNull
                        java.lang.String buildResultKey)
Description copied from interface: BuildExecutionManager
Calls removeCurrentlyBuilding & finishProcess

Specified by:
finishBuild in interface BuildExecutionManager

removeCurrentlyBuilding

public CurrentlyBuilding removeCurrentlyBuilding(@NotNull
                                                 java.lang.String planKey)
Specified by:
removeCurrentlyBuilding in interface BuildExecutionManager

setBuildStart

public void setBuildStart(@NotNull
                          BuildContext buildContext,
                          TimingPoint timingPoint)
Specified by:
setBuildStart in interface BuildExecutionUpdateManager

setBuildFinish

public void setBuildFinish(@NotNull
                           BuildContext buildContext,
                           TimingPoint timingPoint)
Specified by:
setBuildFinish in interface BuildExecutionUpdateManager

getBuildLogger

@NotNull
public BuildLogger getBuildLogger(@NotNull
                                          PlanKey planKey)
Description copied from interface: BuildLoggerManager
Returns a BuildLogger for the given plan

Specified by:
getBuildLogger in interface BuildLoggerManager
Returns:

getBuildLogger

@NotNull
public BuildLogger getBuildLogger(@NotNull
                                          PlanResultKey resultKey)
Description copied from interface: BuildLoggerManager
Returns a BuildLogger for the given result

Specified by:
getBuildLogger in interface BuildLoggerManager
Returns:

getBuildLogger

@NotNull
public BuildLogger getBuildLogger(@NotNull
                                          java.lang.String planOrResultKey)
Description copied from interface: BuildLoggerManager
Returns a BuildLogger for the given plan or result key. If it's detected that the AgentContext is building something, passing the plan key String will switch to log to the result log

Specified by:
getBuildLogger in interface BuildLoggerManager
Returns:
buildLogger

removeBuildLogger

public void removeBuildLogger(PlanKey planKey)
Description copied from interface: BuildLoggerManager
Removes plan logger for given plan key.

Specified by:
removeBuildLogger in interface BuildLoggerManager

removeBuildLogger

public void removeBuildLogger(PlanResultKey buildResultKey)
Description copied from interface: BuildLoggerManager
Removes buildLogger for finished build process. Removed build logger is not used anymore as build has been finished and build result should be persisted already.

Specified by:
removeBuildLogger in interface BuildLoggerManager

setBuildManager

public void setBuildManager(BuildManager buildManager)

setEventManager

public void setEventManager(com.atlassian.event.EventManager eventManager)

setTriggerReasonManager

public void setTriggerReasonManager(TriggerReasonManager triggerReasonManager)

setErrorUpdateHandler

public void setErrorUpdateHandler(ErrorUpdateHandler errorUpdateHandler)

setChangeDetectionManager

public void setChangeDetectionManager(ChangeDetectionManager changeDetectionManager)

setBuildResultsSummaryManager

public void setBuildResultsSummaryManager(BuildResultsSummaryManager buildResultsSummaryManager)

setBuildLoggerManager

public void setBuildLoggerManager(BuildLoggerManager buildLoggerManager)

setBuildNumberGeneratorService

public void setBuildNumberGeneratorService(BuildNumberGeneratorService buildNumberGeneratorService)

setPendingBuildResultsCleanup

public void setPendingBuildResultsCleanup(PendingBuildResultsCleanup pendingBuildResultsCleanup)

setLimitedConcurrencyCaller

public void setLimitedConcurrencyCaller(LimitedConcurrencyCaller limitedConcurrencyCaller)

setAuthorCreatorService

public void setAuthorCreatorService(AuthorCreatorService authorCreatorService)


Copyright © 2010 Atlassian. All Rights Reserved.