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) |
Modifier and Type | Method and Description |
---|---|
void |
abandonBuild(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(Collection<Long> agentIds)
Returns a Map of
PipelineDefinition s keyed by their id |
Collection<BuildAgent> |
getActiveAndEnabledAgents()
Returns agents that are enabled and online
|
BuildAgent |
getAgent(long agentId) |
long |
getAgentCount(Class<? extends PipelineDefinition> agentDefinitionClass)
Retrieves the amount of agents of given type stored in the database
|
PipelineDefinition |
getAgentDefinition(Long agentId) |
PipelineDefinition |
getAgentDefinitionByName(String name)
Retrieve a pipelineDefinition by name.
|
List<PipelineDefinition> |
getAgentDefinitionsWithNameLike(String likeName)
Return a list of agents whose name is like the provided string.
|
List<BuildAgent> |
getAllAgents() |
List<ElasticAgentDefinition> |
getAllElasticAgentDefinitions(Collection<String> instanceIds)
Retrieve elastic agent definitions from db.
|
List<ElasticAgentDefinition> |
getAllElasticAgentDefinitions(int firstResult,
int maxResults)
Retrieve most recently terminated elastic agent definitions from db, ordered by termination time, descending.
|
List<LocalBuildAgent> |
getAllLocalAgents()
Returns all
LocalBuildAgent objects |
List<BuildAgent> |
getAllNonElasticAgents() |
List<PipelineDefinition> |
getAllPersistedAgentDefinitions()
Retrieves a list of all agent definitions stored in the database.
|
List<BuildAgent> |
getAllRemoteAgents()
Gets all remote agents in the system.
|
List<BuildAgent> |
getAllRemoteAgents(boolean onlineOnly)
Get remote agents.
|
Collection<BuildAgent> |
getBusyBuildAgents()
Gets a collection agents that are currently building or cancelling a build
|
Collection<BuildAgent> |
getElasticActiveAndEnabledAgents()
Returns elastic agents that are enabled and online
|
Collection<LocalBuildAgent> |
getLocalActiveAndEnabledAgents()
Returns local agents that are enabled and online
|
LocalBuildAgent |
getLocalAgent(long pipelineId)
Returns the pipeline that matches the passed id
|
List<BuildAgent> |
getOnlineElasticAgents()
Retrieve all online elastic build agents.
|
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 |
removeAgent(long agentId)
Removes the passed agent
|
void |
saveAnyPipeline(PipelineDefinition pipelineDefinition)
Stores a pipeline
PipelineDefinition of any type (elastic, local, remote)
AgentConfigurationUpdateEvent is fired after the pipeline is saved |
void |
saveAnyPipeline(PipelineDefinition pipelineDefinition,
AgentConfigurationUpdatedEventFactory eventFactory)
Stores a pipeline
PipelineDefinition of any type (elastic, local,
remote) |
void |
saveElasticPipeline(ElasticAgentDefinition elasticDefinition)
Stores the elastic
PipelineDefinition |
void |
savePipeline(PipelineDefinition pipelineDefinition)
Stores the
PipelineDefinition . |
void |
savePipeline(PipelineDefinition pipelineDefinition,
AgentConfigurationUpdatedEventFactory eventFactory)
Stores the
PipelineDefinition . |
void |
startLocalAgents()
Starts all current
LocalBuildAgent objects |
void |
stopAgent(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)
public void createDefaultAgent()
AgentManager
createDefaultAgent
in interface AgentManager
public void initAgents()
AgentManager
initAgents
in interface AgentManager
public void startLocalAgents()
AgentManager
LocalBuildAgent
objectsstartLocalAgents
in interface AgentManager
public void stopLocalAgents()
AgentManager
LocalBuildAgent
stopLocalAgents
in interface AgentManager
@NotNull public List<LocalBuildAgent> getAllLocalAgents()
AgentManager
LocalBuildAgent
objectsgetAllLocalAgents
in interface AgentManager
LocalBuildAgent
objects, or an empty
collection if none exists.@NotNull public List<BuildAgent> getOnlineElasticAgents()
AgentManager
getOnlineElasticAgents
in interface AgentManager
@NotNull public List<ElasticAgentDefinition> getAllElasticAgentDefinitions(int firstResult, int maxResults)
AgentManager
getAllElasticAgentDefinitions
in interface AgentManager
public long getAgentCount(Class<? extends PipelineDefinition> agentDefinitionClass)
AgentManager
getAgentCount
in interface AgentManager
agentDefinitionClass
- agent type@NotNull public List<ElasticAgentDefinition> getAllElasticAgentDefinitions(@NotNull Collection<String> instanceIds)
AgentManager
getAllElasticAgentDefinitions
in interface AgentManager
instanceIds
- the instances ids on which the agents were running@NotNull public List<BuildAgent> getAllRemoteAgents(boolean onlineOnly)
AgentManager
getAllRemoteAgents
in interface AgentManager
onlineOnly
- - only return those agents which are online currently.@NotNull public List<BuildAgent> getAllRemoteAgents()
AgentManager
getAllRemoteAgents
in interface AgentManager
@NotNull public List<BuildAgent> getAllAgents()
getAllAgents
in interface AgentManager
@NotNull public List<BuildAgent> getAllNonElasticAgents()
getAllNonElasticAgents
in interface AgentManager
@NotNull public Collection<BuildAgent> getBusyBuildAgents()
AgentManager
getBusyBuildAgents
in interface AgentManager
BuildAgent
@NotNull public Collection<BuildAgent> getActiveAndEnabledAgents()
AgentManager
getActiveAndEnabledAgents
in interface AgentManager
BuildAgent
@NotNull public Collection<BuildAgent> getRemoteActiveAndEnabledAgents()
AgentManager
getRemoteActiveAndEnabledAgents
in interface AgentManager
BuildAgent
@NotNull public Collection<BuildAgent> getElasticActiveAndEnabledAgents()
AgentManager
getElasticActiveAndEnabledAgents
in interface AgentManager
BuildAgent
@NotNull public Collection<LocalBuildAgent> getLocalActiveAndEnabledAgents()
AgentManager
getLocalActiveAndEnabledAgents
in interface AgentManager
LocalBuildAgent
public void createLocalAgent(LocalAgentDefinition definition) throws BambooLicenseException
AgentManager
createLocalAgent
in interface AgentManager
BambooLicenseException
public void savePipeline(@NotNull PipelineDefinition pipelineDefinition)
AgentManager
PipelineDefinition
. Updates any caches so calls to AgentManager.getLocalAgent(long)
will return the LocalBuildAgent
returns with
the new definitionsavePipeline
in interface AgentManager
pipelineDefinition
- - Must not be nullpublic void savePipeline(@NotNull PipelineDefinition pipelineDefinition, @Nullable AgentConfigurationUpdatedEventFactory eventFactory)
AgentManager
PipelineDefinition
. Updates any caches so calls to AgentManager.getLocalAgent(long)
will return the LocalBuildAgent
returns with
the new definitionsavePipeline
in interface AgentManager
pipelineDefinition
- - Must not be nulleventFactory
- event factory used to create event sent after the pipeline is savedpublic void saveElasticPipeline(@NotNull ElasticAgentDefinition elasticDefinition)
AgentManager
PipelineDefinition
saveElasticPipeline
in interface AgentManager
elasticDefinition
- - Must not be nullpublic List<PipelineDefinition> getAllPersistedAgentDefinitions()
AgentManager
getAllPersistedAgentDefinitions
in interface AgentManager
public void abandonBuild(@NotNull BuildAgent remoteAgent, boolean agentStartingUp)
abandonBuild
in interface AgentManager
public void stopAgent(@NotNull BuildAgent agent)
AgentManager
stopAgent
in interface AgentManager
agent
- to be stoppedpublic LocalBuildAgent getLocalAgent(long pipelineId)
AgentManager
getLocalAgent
in interface AgentManager
LocalBuildAgent
object. Null if pipeline does not
exist@Nullable public BuildAgent getAgent(long agentId)
getAgent
in interface AgentManager
@Nullable public PipelineDefinition getAgentDefinition(@NotNull Long agentId)
getAgentDefinition
in interface AgentManager
public Map<Long,PipelineDefinition> findAllAgentsForAgentIds(@NotNull Collection<Long> agentIds)
AgentManager
PipelineDefinition
s keyed by their idfindAllAgentsForAgentIds
in interface AgentManager
@Nullable public PipelineDefinition getAgentDefinitionByName(@NotNull String name)
AgentManager
getAgentDefinitionByName
in interface AgentManager
name
- of the agent to find@NotNull public List<PipelineDefinition> getAgentDefinitionsWithNameLike(@NotNull String likeName)
AgentManager
getAgentDefinitionsWithNameLike
in interface AgentManager
likeName
- the string to matchpublic void saveAnyPipeline(@NotNull PipelineDefinition pipelineDefinition)
AgentManager
PipelineDefinition
of any type (elastic, local, remote)
AgentConfigurationUpdateEvent is fired after the pipeline is savedsaveAnyPipeline
in interface AgentManager
pipelineDefinition
- - Must not be nullpublic void saveAnyPipeline(@NotNull PipelineDefinition pipelineDefinition, @Nullable AgentConfigurationUpdatedEventFactory eventFactory)
AgentManager
PipelineDefinition
of any type (elastic, local,
remote)saveAnyPipeline
in interface AgentManager
pipelineDefinition
- Must not be nulleventFactory
- event factory used to create event sent after the pipeline is savedpublic void disableAllAgents()
AgentManager
disableAllAgents
in interface AgentManager
public void enableAllAgents()
AgentManager
enableAllAgents
in interface AgentManager
public boolean checkPipelinesAreDisabled()
checkPipelinesAreDisabled
in interface AgentManager
public <T> T executeIfIdle(Callable<T> callable) throws Exception
AgentManager
Executes a given Callable
only if no builds are in progress. Builds are
prevented from starting while the Callable
executes.
executeIfIdle
in interface AgentManager
callable
- the Callable
to be executedcallable
BambooBusyException
- if builds are in progressException
- if thrown by callable
public void removeAgent(long agentId) throws TimeoutException
AgentManager
removeAgent
in interface AgentManager
TimeoutException
public boolean allowNewRemoteAgent()
AgentManager
allowNewRemoteAgent
in interface AgentManager
public boolean allowNewRemoteAgents(int numOfAgentsToCreate)
AgentManager
allowNewRemoteAgents
in interface AgentManager
public boolean allowNewElasticAgent()
AgentManager
allowNewElasticAgent
in interface AgentManager
public boolean allowNewElasticAgents(int numOfAgentsToCreate)
AgentManager
allowNewElasticAgents
in interface AgentManager
public boolean allowNewLocalAgent()
AgentManager
allowNewLocalAgent
in interface AgentManager
public boolean updateAgentStatusIfResultReturnPossibleAfterServerRestart(long agentId, ResultKey resultKey, String displayName, long deploymentResultId)
AgentManager
updateAgentStatusIfResultReturnPossibleAfterServerRestart
in interface AgentManager
Copyright © 2019 Atlassian Software Systems Pty Ltd. All rights reserved.