public class AgentManagerImpl extends Object implements AgentManager, LocalAgentManager
DEFAULT_AGENT_NAME| Constructor and Description |
|---|
AgentManagerImpl(AgentDao agentDao,
CapabilitySetManager capabilitySetManager,
CapabilityManager capabilityManager,
com.atlassian.event.api.EventPublisher eventPublisher,
BambooLicenseManager bambooLicenseManager,
ElasticInstanceManager elasticInstanceManager,
ErrorUpdateHandler errorUpdateHandler,
BuildLoggerManager buildLoggerManager,
FeatureManager featureManager,
DeploymentsInProgressService deploymentsInProgressService,
ElasticTunnelDefinitionDao elasticTunnelDefinitionDao) |
| Modifier and Type | Method and Description |
|---|---|
void |
abandonBuild(@NotNull BuildAgent remoteAgent,
boolean agentStartingUp) |
boolean |
allowNewElasticAgent()
Allow an elastic agent to register and come online? Based on licensing restrictions.
|
boolean |
allowNewElasticAgents(int numOfAgentsToCreate)
Allow a specified number of elastic agents to register and come online? Based on licensing restrictions.
|
boolean |
allowNewLocalAgent()
Allow a local agent to come online? Based on licensing restrictions.
|
boolean |
allowNewRemoteAgent()
Allow a remote agent to register and come online? Based on licensing restrictions.
|
boolean |
allowNewRemoteAgents(int numOfAgentsToCreate)
Allow a specified number of remote agents to register and come online? Based on licensing restrictions.
|
boolean |
checkPipelinesAreDisabled() |
void |
createDefaultAgent()
sets up a default local agent if no local agent exists
|
void |
createLocalAgent(LocalAgentDefinition definition)
Create a new local agent.
|
void |
disableAllAgents()
Disable all pipelines
|
void |
enableAllAgents()
Enable all pipelines
|
<T> T |
executeIfIdle(Callable<T> callable)
Executes a given
Callable only if no builds are in progress. |
Map<Long,PipelineDefinition> |
findAllAgentsForAgentIds(@NotNull Collection<Long> agentIds)
Returns a Map of
PipelineDefinitions keyed by their id |
@NotNull Collection<BuildAgent> |
getActiveAndEnabledAgents()
Returns agents that are enabled and online
|
@Nullable BuildAgent |
getAgent(long agentId) |
long |
getAgentCount(Class<? extends PipelineDefinition> agentDefinitionClass)
Retrieves the amount of agents of given type stored in the database
|
@Nullable PipelineDefinition |
getAgentDefinition(@NotNull Long agentId) |
@Nullable PipelineDefinition |
getAgentDefinitionByName(@NotNull String name)
Retrieve a pipelineDefinition by name.
|
@NotNull List<PipelineDefinition> |
getAgentDefinitionsWithNameLike(@NotNull String likeName)
Return a list of agents whose name is like the provided string.
|
@NotNull List<BuildAgent> |
getAllAgents() |
@NotNull List<ElasticAgentDefinition> |
getAllElasticAgentDefinitions(@NotNull Collection<String> instanceIds)
Retrieve elastic agent definitions from db.
|
@NotNull List<ElasticAgentDefinition> |
getAllElasticAgentDefinitions(int firstResult,
int maxResults)
Retrieve most recently terminated elastic agent definitions from db, ordered by termination time, descending.
|
@NotNull List<LocalBuildAgent> |
getAllLocalAgents()
Returns all
LocalBuildAgent objects |
@NotNull List<BuildAgent> |
getAllNonElasticAgents() |
List<PipelineDefinition> |
getAllPersistedAgentDefinitions()
Retrieves a list of all agent definitions stored in the database.
|
@NotNull List<BuildAgent> |
getAllRemoteAgents()
Gets all remote agents in the system.
|
@NotNull List<BuildAgent> |
getAllRemoteAgents(boolean onlineOnly)
Get remote agents.
|
@NotNull Collection<BuildAgent> |
getBusyBuildAgents()
Gets a collection agents that are currently building or cancelling a build
|
@NotNull Collection<BuildAgent> |
getElasticActiveAndEnabledAgents()
Returns elastic agents that are enabled and online
|
@NotNull Collection<LocalBuildAgent> |
getLocalActiveAndEnabledAgents()
Returns local agents that are enabled and online
|
LocalBuildAgent |
getLocalAgent(long pipelineId)
Returns the pipeline that matches the passed id
|
@NotNull List<BuildAgent> |
getOnlineElasticAgents()
Retrieve all online elastic build agents.
|
@NotNull Collection<BuildAgent> |
getRemoteActiveAndEnabledAgents()
Returns remote agents that are enabled and online
|
void |
initAgents()
Inits the local agents Must be ran before any other methods.
|
void |
onAgentReturning(@NotNull BuildAgent agent)
Performs any other operations required when an agent goes offline, such as updating the status and shutdown
time.
|
void |
removeAgent(long agentId)
Removes the passed agent
|
void |
saveAnyPipeline(@NotNull PipelineDefinition pipelineDefinition)
Stores a pipeline
PipelineDefinition of any type (elastic, local, remote)
AgentConfigurationUpdateEvent is fired after the pipeline is saved |
void |
saveAnyPipeline(@NotNull PipelineDefinition pipelineDefinition,
@Nullable AgentConfigurationUpdatedEventFactory eventFactory)
Stores a pipeline
PipelineDefinition of any type (elastic, local,
remote) |
void |
saveElasticPipeline(@NotNull ElasticAgentDefinition elasticDefinition)
Stores the elastic
PipelineDefinition |
void |
savePipeline(@NotNull PipelineDefinition pipelineDefinition)
Stores the
PipelineDefinition. |
void |
savePipeline(@NotNull PipelineDefinition pipelineDefinition,
@Nullable AgentConfigurationUpdatedEventFactory eventFactory)
Stores the
PipelineDefinition. |
void |
saveReturningElasticPipeline(@NotNull ElasticAgentDefinition elasticDefinition)
Stores the elastic
PipelineDefinition of a returning elastic agent. |
void |
startLocalAgents()
Starts all current
LocalBuildAgent objects |
void |
stopAgent(@NotNull BuildAgent agent)
Performs any other operations required when an agent goes offline, such as updating the status and shutdown
time.
|
void |
stopLocalAgents()
Stops all
LocalBuildAgent |
boolean |
updateAgentStatusIfResultReturnPossibleAfterServerRestart(long agentId,
ResultKey resultKey,
String displayName,
long deploymentResultId)
Checks if agent is capable of 'surviving' a server restart, i.e.
|
public AgentManagerImpl(AgentDao agentDao, CapabilitySetManager capabilitySetManager, CapabilityManager capabilityManager, com.atlassian.event.api.EventPublisher eventPublisher, BambooLicenseManager bambooLicenseManager, ElasticInstanceManager elasticInstanceManager, ErrorUpdateHandler errorUpdateHandler, BuildLoggerManager buildLoggerManager, FeatureManager featureManager, DeploymentsInProgressService deploymentsInProgressService, ElasticTunnelDefinitionDao elasticTunnelDefinitionDao)
public void createDefaultAgent()
AgentManagercreateDefaultAgent in interface AgentManagerpublic void initAgents()
AgentManagerinitAgents in interface AgentManagerpublic void startLocalAgents()
AgentManagerLocalBuildAgent objectsstartLocalAgents in interface AgentManagerpublic void stopLocalAgents()
AgentManagerLocalBuildAgentstopLocalAgents in interface AgentManager@NotNull public @NotNull List<LocalBuildAgent> getAllLocalAgents()
AgentManagerLocalBuildAgent objectsgetAllLocalAgents in interface AgentManagerLocalBuildAgent objects, or an empty
collection if none exists.@NotNull public @NotNull List<BuildAgent> getOnlineElasticAgents()
AgentManagergetOnlineElasticAgents in interface AgentManager@NotNull public @NotNull List<ElasticAgentDefinition> getAllElasticAgentDefinitions(int firstResult, int maxResults)
AgentManagergetAllElasticAgentDefinitions in interface AgentManagerpublic long getAgentCount(Class<? extends PipelineDefinition> agentDefinitionClass)
AgentManagergetAgentCount in interface AgentManageragentDefinitionClass - agent type@NotNull public @NotNull List<ElasticAgentDefinition> getAllElasticAgentDefinitions(@NotNull @NotNull Collection<String> instanceIds)
AgentManagergetAllElasticAgentDefinitions in interface AgentManagerinstanceIds - the instances ids on which the agents were running@NotNull public @NotNull List<BuildAgent> getAllRemoteAgents(boolean onlineOnly)
AgentManagergetAllRemoteAgents in interface AgentManageronlineOnly - - only return those agents which are online currently.@NotNull public @NotNull List<BuildAgent> getAllRemoteAgents()
AgentManagergetAllRemoteAgents in interface AgentManager@NotNull public @NotNull List<BuildAgent> getAllAgents()
getAllAgents in interface AgentManager@NotNull public @NotNull List<BuildAgent> getAllNonElasticAgents()
getAllNonElasticAgents in interface AgentManager@NotNull public @NotNull Collection<BuildAgent> getBusyBuildAgents()
AgentManagergetBusyBuildAgents in interface AgentManagerBuildAgent@NotNull public @NotNull Collection<BuildAgent> getActiveAndEnabledAgents()
AgentManagergetActiveAndEnabledAgents in interface AgentManagerBuildAgent@NotNull public @NotNull Collection<BuildAgent> getRemoteActiveAndEnabledAgents()
AgentManagergetRemoteActiveAndEnabledAgents in interface AgentManagerBuildAgent@NotNull public @NotNull Collection<BuildAgent> getElasticActiveAndEnabledAgents()
AgentManagergetElasticActiveAndEnabledAgents in interface AgentManagerBuildAgent@NotNull public @NotNull Collection<LocalBuildAgent> getLocalActiveAndEnabledAgents()
AgentManagergetLocalActiveAndEnabledAgents in interface AgentManagerLocalBuildAgentpublic void createLocalAgent(LocalAgentDefinition definition) throws BambooLicenseException
AgentManagercreateLocalAgent in interface AgentManagerBambooLicenseExceptionpublic void savePipeline(@NotNull
@NotNull PipelineDefinition pipelineDefinition)
AgentManagerPipelineDefinition. Updates any caches so calls to AgentManager.getLocalAgent(long) will return the LocalBuildAgent returns with
the new definitionsavePipeline in interface AgentManagerpipelineDefinition - - Must not be nullpublic void savePipeline(@NotNull
@NotNull PipelineDefinition pipelineDefinition,
@Nullable
@Nullable AgentConfigurationUpdatedEventFactory eventFactory)
AgentManagerPipelineDefinition. Updates any caches so calls to AgentManager.getLocalAgent(long) will return the LocalBuildAgent returns with
the new definitionsavePipeline in interface AgentManagerpipelineDefinition - - Must not be nulleventFactory - event factory used to create event sent after the pipeline is savedpublic void saveElasticPipeline(@NotNull
@NotNull ElasticAgentDefinition elasticDefinition)
AgentManagerPipelineDefinitionsaveElasticPipeline in interface AgentManagerelasticDefinition - - Must not be nullpublic void saveReturningElasticPipeline(@NotNull
@NotNull ElasticAgentDefinition elasticDefinition)
AgentManagerPipelineDefinition of a returning elastic agent.saveReturningElasticPipeline in interface AgentManagerelasticDefinition - returning elastic agent definitionpublic List<PipelineDefinition> getAllPersistedAgentDefinitions()
AgentManagergetAllPersistedAgentDefinitions in interface AgentManagerpublic void abandonBuild(@NotNull
@NotNull BuildAgent remoteAgent,
boolean agentStartingUp)
abandonBuild in interface AgentManagerpublic void onAgentReturning(@NotNull
@NotNull BuildAgent agent)
AgentManageronAgentReturning in interface AgentManageragent - to be stoppedpublic void stopAgent(@NotNull
@NotNull BuildAgent agent)
AgentManagerstopAgent in interface AgentManageragent - to be stoppedpublic LocalBuildAgent getLocalAgent(long pipelineId)
AgentManagergetLocalAgent in interface AgentManagerLocalBuildAgent object. Null if pipeline does not
exist@Nullable public @Nullable BuildAgent getAgent(long agentId)
getAgent in interface AgentManager@Nullable public @Nullable PipelineDefinition getAgentDefinition(@NotNull @NotNull Long agentId)
getAgentDefinition in interface AgentManagerpublic Map<Long,PipelineDefinition> findAllAgentsForAgentIds(@NotNull @NotNull Collection<Long> agentIds)
AgentManagerPipelineDefinitions keyed by their idfindAllAgentsForAgentIds in interface AgentManager@Nullable public @Nullable PipelineDefinition getAgentDefinitionByName(@NotNull @NotNull String name)
AgentManagergetAgentDefinitionByName in interface AgentManagername - of the agent to find@NotNull public @NotNull List<PipelineDefinition> getAgentDefinitionsWithNameLike(@NotNull @NotNull String likeName)
AgentManagergetAgentDefinitionsWithNameLike in interface AgentManagerlikeName - the string to matchpublic void saveAnyPipeline(@NotNull
@NotNull PipelineDefinition pipelineDefinition)
AgentManagerPipelineDefinition of any type (elastic, local, remote)
AgentConfigurationUpdateEvent is fired after the pipeline is savedsaveAnyPipeline in interface AgentManagerpipelineDefinition - - Must not be nullpublic void saveAnyPipeline(@NotNull
@NotNull PipelineDefinition pipelineDefinition,
@Nullable
@Nullable AgentConfigurationUpdatedEventFactory eventFactory)
AgentManagerPipelineDefinition of any type (elastic, local,
remote)saveAnyPipeline in interface AgentManagerpipelineDefinition - Must not be nulleventFactory - event factory used to create event sent after the pipeline is savedpublic void disableAllAgents()
AgentManagerdisableAllAgents in interface AgentManagerpublic void enableAllAgents()
AgentManagerenableAllAgents in interface AgentManagerpublic boolean checkPipelinesAreDisabled()
checkPipelinesAreDisabled in interface AgentManagerpublic <T> T executeIfIdle(Callable<T> callable) throws Exception
AgentManagerExecutes a given Callable only if no builds are in progress. Builds are
prevented from starting while the Callable executes.
executeIfIdle in interface AgentManagercallable - the Callable to be executedcallableBambooBusyException - if builds are in progressException - if thrown by callablepublic void removeAgent(long agentId)
throws TimeoutException
AgentManagerremoveAgent in interface AgentManagerTimeoutExceptionpublic boolean allowNewRemoteAgent()
AgentManagerallowNewRemoteAgent in interface AgentManagerpublic boolean allowNewRemoteAgents(int numOfAgentsToCreate)
AgentManagerallowNewRemoteAgents in interface AgentManagerpublic boolean allowNewElasticAgent()
AgentManagerallowNewElasticAgent in interface AgentManagerpublic boolean allowNewElasticAgents(int numOfAgentsToCreate)
AgentManagerallowNewElasticAgents in interface AgentManagerpublic boolean allowNewLocalAgent()
AgentManagerallowNewLocalAgent in interface AgentManagerpublic boolean updateAgentStatusIfResultReturnPossibleAfterServerRestart(long agentId,
ResultKey resultKey,
String displayName,
long deploymentResultId)
AgentManagerupdateAgentStatusIfResultReturnPossibleAfterServerRestart in interface AgentManagerCopyright © 2023 Atlassian Software Systems Pty Ltd. All rights reserved.