Class BuildAgentManagerImpl
- java.lang.Object
-
- jetbrains.buildServer.serverSide.impl.BuildAgentManagerImpl
-
- All Implemented Interfaces:
BuildAgentManager
,BuildAgentManagerEx
public class BuildAgentManagerImpl extends Object implements BuildAgentManagerEx
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static class
BuildAgentManagerImpl.AgentVersions
class
BuildAgentManagerImpl.OtherNodeEventsHandler
-
Nested classes/interfaces inherited from interface jetbrains.buildServer.serverSide.BuildAgentManager
BuildAgentManager.RunConfigurationPolicy
-
-
Field Summary
Fields Modifier and Type Field Description static String
AGENT_WILL_UPGRADE
static String
TEAMCITY_REGISTER_AGENTS_ON_SECONDARY_NODES
static String
TEAMCITY_UNREGISTER_AGENTS_ON_SECONDARY_NODES
static String
TEAMCITY_UPDATE_AGENT_PARAMS_ON_SECONDARY_NODES
-
Constructor Summary
Constructors Constructor Description BuildAgentManagerImpl(SQLRunnerEx sqlRunner, ServerResponsibilityEx serverResponsibility, EventDispatcher<BuildServerListener> dispatcher, MultiNodesEvents multiNodesEvents, ExecutorServices executorServices)
-
Method Summary
All Methods Instance Methods Concrete Methods Deprecated Methods Modifier and Type Method Description BuildAgentEx
findAgentById(int agentId, boolean searchUnregistered)
Searches for an agent with specified id among registered and unregistered agents.BuildAgentEx
findAgentByName(String agentName, boolean searchUnregistered)
Searches for an agent with specified name among registered and unregistered agents.List<BuildAgentEx>
findAgentsByAgentTypeIds(Set<Integer> agentTypeIds, boolean searchUnregistered)
<T extends SBuildAgent>
List<AgentCompatibility>getAgentCompatibilities(T agent)
Returns build configuration compatibility information for the specified agentList<BuildAgentEx>
getAllAgents()
List<BuildAgentEx>
getAllAgents(boolean includeUnauthorized)
Set<String>
getCanRunConfigurations(SBuildAgent agent)
Returns list of build configurations this agent can potentially run.<T extends SBuildAgent>
intgetNumberOfCompatibleConfigurations(T agent)
Returns number of configurations compatible with specified agent<T extends SBuildAgent>
intgetNumberOfIncompatibleConfigurations(T agent)
Returns number of configurations incompatible with specified agentint
getNumberOfRegisteredAgents()
Returns number of registered and authorized agentsList<BuildAgentEx>
getRegisteredAgents()
Returns all registered authorized agents.List<BuildAgentEx>
getRegisteredAgents(boolean includeUnauthorized)
Returns all registered agents.BuildAgentManager.RunConfigurationPolicy
getRunConfigurationPolicy(SBuildAgent agent)
Returns run configuration policy for an agent.List<BuildAgentEx>
getUnregisteredAgents()
Returns list of all currently unregistered and authorized agents, i.e.List<BuildAgentEx>
getUnregisteredAgents(boolean includeUnauthorized)
Returns list of all currently unregistered agents, with additional filter based on authorization status.boolean
isCanRunConfiguration(SBuildAgent agent, BuildTypeDescriptor buildType)
Returns true if specified agent can run specified build configuration.void
pingAllAgents()
BuildAgentEx
registerAgent(BuildAgentEx agent, long buildIdReportedByAgent)
Returns the registered agent - the same instance as was passed in the parameters if this is a new registration, or another instance if such agent is already registered.boolean
registrationIsTemporallyNotAvailable()
void
rememberAndSendRegistered(BuildAgentEx agent)
void
removeAgent(SBuildAgent agent, SUser user)
Removes specified agent and cleans up this agent state from the database.void
setAgentDistributionMonitor(AgentDistributionMonitor agentDistributionMonitor)
void
setAgentPersister(AgentPersister agentPersister)
void
setAgentPoolManager(AgentPoolManager agentPoolManager)
void
setAgentTypeManager(AgentTypeManager agentTypeManager)
void
setAgentTypeStorage(AgentTypeStorage agentTypeStorage)
void
setAuditLogFactory(AuditLogFactory auditLogFactory)
void
setAutomaticAgentAuthorizationTokens(AutomaticAgentAuthorizationTokens automaticAgentAuthorizationTokens)
void
setBuildAgentFactory(BuildAgentFactory buildAgentFactory)
void
setBuildAgentUpgrader(BuildAgentUpgrader agentUpgrader)
void
setBuildQueue(BuildQueueEx buildQueue)
void
setCanRunConfiguration(SBuildAgent agent, String buildTypeId, boolean canRun)
Deprecated.void
setDispatcher(EventDispatcher<BuildServerListener> dispatcher)
void
setRunConfigurationPolicy(SBuildAgent agent, BuildAgentManager.RunConfigurationPolicy policy)
Sets build configuration run policy for an agent.void
setRunningBuildManager(RunningBuildsManagerEx runningBuildManager)
void
setUnregisteredAgentsManager(UnregisteredAgentsManager unregisteredAgentsManager)
void
unregisterAgent(int id)
void
unregisterAgent(int id, String reason)
void
unregisterAllAgents(String reason, boolean shouldCancelRunningBuilds)
void
updateAgentParameters(int agentId, String authorizationToken, AgentDescription newAgentDescription)
Sets agent parameters to the database.
-
-
-
Field Detail
-
AGENT_WILL_UPGRADE
public static final String AGENT_WILL_UPGRADE
- See Also:
- Constant Field Values
-
TEAMCITY_REGISTER_AGENTS_ON_SECONDARY_NODES
public static final String TEAMCITY_REGISTER_AGENTS_ON_SECONDARY_NODES
- See Also:
- Constant Field Values
-
TEAMCITY_UNREGISTER_AGENTS_ON_SECONDARY_NODES
public static final String TEAMCITY_UNREGISTER_AGENTS_ON_SECONDARY_NODES
- See Also:
- Constant Field Values
-
TEAMCITY_UPDATE_AGENT_PARAMS_ON_SECONDARY_NODES
public static final String TEAMCITY_UPDATE_AGENT_PARAMS_ON_SECONDARY_NODES
- See Also:
- Constant Field Values
-
-
Constructor Detail
-
BuildAgentManagerImpl
public BuildAgentManagerImpl(@NotNull SQLRunnerEx sqlRunner, @NotNull ServerResponsibilityEx serverResponsibility, @NotNull EventDispatcher<BuildServerListener> dispatcher, @NotNull MultiNodesEvents multiNodesEvents, @NotNull ExecutorServices executorServices)
-
-
Method Detail
-
setAuditLogFactory
public void setAuditLogFactory(@NotNull AuditLogFactory auditLogFactory)
-
setBuildAgentUpgrader
public void setBuildAgentUpgrader(@NotNull BuildAgentUpgrader agentUpgrader)
-
setRunningBuildManager
public void setRunningBuildManager(@NotNull RunningBuildsManagerEx runningBuildManager)
-
setDispatcher
public void setDispatcher(@NotNull EventDispatcher<BuildServerListener> dispatcher)
-
setUnregisteredAgentsManager
public void setUnregisteredAgentsManager(@NotNull UnregisteredAgentsManager unregisteredAgentsManager)
-
setAgentPersister
public void setAgentPersister(AgentPersister agentPersister)
-
setAgentTypeManager
public void setAgentTypeManager(AgentTypeManager agentTypeManager)
-
setAgentTypeStorage
public void setAgentTypeStorage(AgentTypeStorage agentTypeStorage)
-
setBuildAgentFactory
public void setBuildAgentFactory(BuildAgentFactory buildAgentFactory)
-
setAgentDistributionMonitor
public void setAgentDistributionMonitor(@NotNull AgentDistributionMonitor agentDistributionMonitor)
- Specified by:
setAgentDistributionMonitor
in interfaceBuildAgentManagerEx
-
setBuildQueue
public void setBuildQueue(BuildQueueEx buildQueue)
-
setAutomaticAgentAuthorizationTokens
public void setAutomaticAgentAuthorizationTokens(@NotNull AutomaticAgentAuthorizationTokens automaticAgentAuthorizationTokens)
-
setAgentPoolManager
public void setAgentPoolManager(@NotNull AgentPoolManager agentPoolManager)
-
registrationIsTemporallyNotAvailable
public boolean registrationIsTemporallyNotAvailable()
- Specified by:
registrationIsTemporallyNotAvailable
in interfaceBuildAgentManagerEx
-
getRegisteredAgents
public List<BuildAgentEx> getRegisteredAgents()
Description copied from interface:BuildAgentManager
Returns all registered authorized agents. Registered means connected at the moment of call.- Specified by:
getRegisteredAgents
in interfaceBuildAgentManager
- Specified by:
getRegisteredAgents
in interfaceBuildAgentManagerEx
- Returns:
- see above
-
getRegisteredAgents
public List<BuildAgentEx> getRegisteredAgents(boolean includeUnauthorized)
Description copied from interface:BuildAgentManager
Returns all registered agents. Registered means connected at the moment of call.- Specified by:
getRegisteredAgents
in interfaceBuildAgentManager
- Specified by:
getRegisteredAgents
in interfaceBuildAgentManagerEx
- Parameters:
includeUnauthorized
- if true, unauthorized agents, i.e. agents which cannot run builds until authorized by admin- Returns:
- see above
-
getUnregisteredAgents
public List<BuildAgentEx> getUnregisteredAgents()
Description copied from interface:BuildAgentManager
Returns list of all currently unregistered and authorized agents, i.e. agents registered on server some time ago, but currently unregistered by server because they are either not responding, or upgrading. This list doesn't include unauthorized agents. The list is sorted by agent registration date in reverse order.- Specified by:
getUnregisteredAgents
in interfaceBuildAgentManager
- Specified by:
getUnregisteredAgents
in interfaceBuildAgentManagerEx
- Returns:
- list of all currently unregistered agents
-
getUnregisteredAgents
public List<BuildAgentEx> getUnregisteredAgents(boolean includeUnauthorized)
Description copied from interface:BuildAgentManager
Returns list of all currently unregistered agents, with additional filter based on authorization status. See alsoBuildAgentManager.getUnregisteredAgents()
- Specified by:
getUnregisteredAgents
in interfaceBuildAgentManager
- Specified by:
getUnregisteredAgents
in interfaceBuildAgentManagerEx
- Parameters:
includeUnauthorized
- whether to include or exclude unauthorized agents- Returns:
- list of all currently unregistered agents
-
getAllAgents
public List<BuildAgentEx> getAllAgents()
- Specified by:
getAllAgents
in interfaceBuildAgentManagerEx
-
getAllAgents
public List<BuildAgentEx> getAllAgents(boolean includeUnauthorized)
- Specified by:
getAllAgents
in interfaceBuildAgentManagerEx
-
findAgentById
@Nullable public BuildAgentEx findAgentById(int agentId, boolean searchUnregistered)
Description copied from interface:BuildAgentManager
Searches for an agent with specified id among registered and unregistered agents.- Specified by:
findAgentById
in interfaceBuildAgentManager
- Specified by:
findAgentById
in interfaceBuildAgentManagerEx
- Parameters:
agentId
- id of the agent to searchsearchUnregistered
- true if unregistered agents should be searched too- Returns:
- found agent or null
-
findAgentByName
@Nullable public BuildAgentEx findAgentByName(@NotNull String agentName, boolean searchUnregistered)
Description copied from interface:BuildAgentManager
Searches for an agent with specified name among registered and unregistered agents.- Specified by:
findAgentByName
in interfaceBuildAgentManager
- Specified by:
findAgentByName
in interfaceBuildAgentManagerEx
- Parameters:
agentName
- name of the agent to searchsearchUnregistered
- true if unregistered agents should be searched too- Returns:
- found agent or null
-
findAgentsByAgentTypeIds
@NotNull public List<BuildAgentEx> findAgentsByAgentTypeIds(@NotNull Set<Integer> agentTypeIds, boolean searchUnregistered)
- Specified by:
findAgentsByAgentTypeIds
in interfaceBuildAgentManagerEx
-
registerAgent
@NotNull public BuildAgentEx registerAgent(BuildAgentEx agent, long buildIdReportedByAgent) throws TeamCityRuntimeException
Description copied from interface:BuildAgentManagerEx
Returns the registered agent - the same instance as was passed in the parameters if this is a new registration, or another instance if such agent is already registered.- Specified by:
registerAgent
in interfaceBuildAgentManagerEx
- Throws:
TeamCityRuntimeException
-
updateAgentParameters
public void updateAgentParameters(int agentId, @NotNull String authorizationToken, @NotNull AgentDescription newAgentDescription)
Description copied from interface:BuildAgentManagerEx
Sets agent parameters to the database.This method is called by an agent when its parameters are changes, i.e. if one of agent-side plugins has changed agents parameters.
- Specified by:
updateAgentParameters
in interfaceBuildAgentManagerEx
-
rememberAndSendRegistered
public void rememberAndSendRegistered(@NotNull BuildAgentEx agent)
-
unregisterAgent
public void unregisterAgent(int id)
- Specified by:
unregisterAgent
in interfaceBuildAgentManagerEx
-
unregisterAgent
public void unregisterAgent(int id, String reason)
- Specified by:
unregisterAgent
in interfaceBuildAgentManagerEx
-
unregisterAllAgents
public void unregisterAllAgents(String reason, boolean shouldCancelRunningBuilds)
- Specified by:
unregisterAllAgents
in interfaceBuildAgentManagerEx
-
getRunConfigurationPolicy
public BuildAgentManager.RunConfigurationPolicy getRunConfigurationPolicy(SBuildAgent agent)
Description copied from interface:BuildAgentManager
Returns run configuration policy for an agent.- Specified by:
getRunConfigurationPolicy
in interfaceBuildAgentManager
- Parameters:
agent
- the agent- Returns:
- current run configuration policy
-
setCanRunConfiguration
@Deprecated public void setCanRunConfiguration(@NotNull SBuildAgent agent, String buildTypeId, boolean canRun)
Deprecated.Description copied from interface:BuildAgentManager
IfBuildAgentManager.RunConfigurationPolicy.SELECTED_COMPATIBLE_CONFIGURATIONS
policy is selected for the agent, sets whether configuration with specified id can or can't run on the agent.- Specified by:
setCanRunConfiguration
in interfaceBuildAgentManager
- Parameters:
agent
- the agentbuildTypeId
- id of the configurationcanRun
- if true then this configuration can run on the agent, if false it can't
-
isCanRunConfiguration
public boolean isCanRunConfiguration(@NotNull SBuildAgent agent, BuildTypeDescriptor buildType)
Description copied from interface:BuildAgentManager
Returns true if specified agent can run specified build configuration.- Specified by:
isCanRunConfiguration
in interfaceBuildAgentManager
- Parameters:
agent
- the agentbuildType
- build configuration- Returns:
- true if
BuildAgentManager.RunConfigurationPolicy.ALL_COMPATIBLE_CONFIGURATIONS
policy selected or configuration was explicitly marked as accessible by the agent. Please note that compatibility check is not performed.
-
getCanRunConfigurations
public Set<String> getCanRunConfigurations(SBuildAgent agent)
Description copied from interface:BuildAgentManager
Returns list of build configurations this agent can potentially run.- Specified by:
getCanRunConfigurations
in interfaceBuildAgentManager
- Parameters:
agent
- the agent- Returns:
- list of ids of potentially available for this agent configurations
-
setRunConfigurationPolicy
public void setRunConfigurationPolicy(@NotNull SBuildAgent agent, @NotNull BuildAgentManager.RunConfigurationPolicy policy)
Description copied from interface:BuildAgentManager
Sets build configuration run policy for an agent. Possible values are:-
BuildAgentManager.RunConfigurationPolicy.ALL_COMPATIBLE_CONFIGURATIONS
- all compatible configurations can run on this agent -
BuildAgentManager.RunConfigurationPolicy.SELECTED_COMPATIBLE_CONFIGURATIONS
- only selected configurations can run on this agent (configuration needs to be compatible too)
- Specified by:
setRunConfigurationPolicy
in interfaceBuildAgentManager
- Parameters:
agent
- the agentpolicy
- policy to set
-
-
pingAllAgents
public void pingAllAgents()
- Specified by:
pingAllAgents
in interfaceBuildAgentManagerEx
-
removeAgent
public void removeAgent(@NotNull SBuildAgent agent, @Nullable SUser user) throws AgentCannotBeRemovedException
Description copied from interface:BuildAgentManager
Removes specified agent and cleans up this agent state from the database. Only unregistered agents can be removed.- Specified by:
removeAgent
in interfaceBuildAgentManager
- Parameters:
agent
- agentuser
- user who removes agent (can be null)- Throws:
AgentCannotBeRemovedException
- if agent is connected/registered
-
getNumberOfCompatibleConfigurations
public <T extends SBuildAgent> int getNumberOfCompatibleConfigurations(T agent)
Description copied from interface:BuildAgentManager
Returns number of configurations compatible with specified agent- Specified by:
getNumberOfCompatibleConfigurations
in interfaceBuildAgentManager
- Parameters:
agent
- agent- Returns:
- number of compatible configurations
-
getNumberOfIncompatibleConfigurations
public <T extends SBuildAgent> int getNumberOfIncompatibleConfigurations(T agent)
Description copied from interface:BuildAgentManager
Returns number of configurations incompatible with specified agent- Specified by:
getNumberOfIncompatibleConfigurations
in interfaceBuildAgentManager
- Parameters:
agent
- agent- Returns:
- number of incompatible configurations
-
getAgentCompatibilities
public <T extends SBuildAgent> List<AgentCompatibility> getAgentCompatibilities(T agent)
Description copied from interface:BuildAgentManager
Returns build configuration compatibility information for the specified agent- Specified by:
getAgentCompatibilities
in interfaceBuildAgentManager
- Parameters:
agent
- agent- Returns:
- build configuration compatibility information
-
getNumberOfRegisteredAgents
public int getNumberOfRegisteredAgents()
Description copied from interface:BuildAgentManager
Returns number of registered and authorized agents- Specified by:
getNumberOfRegisteredAgents
in interfaceBuildAgentManager
- Returns:
- see above
-
-