Class SecuredBuildAgentManager
- java.lang.Object
-
- jetbrains.buildServer.serverSide.impl.auth.SecuredBuildAgentManager
-
- All Implemented Interfaces:
AgentDistributionMonitorAware,BuildAgentManager,BuildAgentManagerEx,BuildAgentDistributionMonitorAware
public class SecuredBuildAgentManager extends Object implements BuildAgentManagerEx, BuildAgentDistributionMonitorAware
- Author:
- Sergey.Anchipolevsky Date: 24.09.2007
-
-
Nested Class Summary
-
Nested classes/interfaces inherited from interface jetbrains.buildServer.serverSide.BuildAgentManager
BuildAgentManager.RunConfigurationPolicy
-
-
Constructor Summary
Constructors Constructor Description SecuredBuildAgentManager(SecurityContextEx securityContext)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description BuildAgentExfindAgentById(int agentId, boolean searchUnregistered)Searches for an agent with specified id among registered and unregistered agents.BuildAgentExfindAgentByName(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)<T extends SBuildAgent>
Set<String>getCanRunConfigurations(T 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 agentintgetNumberOfRegisteredAgents()Returns number of registered and authorized agentsList<BuildAgentEx>getRegisteredAgents()Returns all registered authorized agents.List<BuildAgentEx>getRegisteredAgents(boolean includeUnauthorized)Returns all registered agents.<T extends SBuildAgent>
BuildAgentManager.RunConfigurationPolicygetRunConfigurationPolicy(T 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.<T extends SBuildAgent>
booleanisCanRunConfiguration(T agent, BuildTypeDescriptor buildType)Returns true if specified agent can run specified build configuration.voidpingAllAgents()BuildAgentExregisterAgent(BuildAgentEx agent, long currentlyRunningBuildId)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.booleanregistrationIsTemporallyNotAvailable()voidremoveAgent(SBuildAgent agent, SUser user)Removes specified agent and cleans up this agent state from the database.voidsetAgentDistributionMonitor(AgentDistributionMonitor monitor)voidsetAgentPoolManager(AgentPoolManager agentPoolManager)voidsetAgentTypeManager(AgentTypeManager agentTypeManager)<T extends SBuildAgent>
voidsetCanRunConfiguration(T agent, String buildTypeId, boolean canRun)IfBuildAgentManager.RunConfigurationPolicy.SELECTED_COMPATIBLE_CONFIGURATIONSpolicy is selected for the agent, sets whether configuration with specified id can or can't run on the agent.voidsetDelegate(BuildAgentManagerEx delegate)voidsetProjectManager(ProjectManager projectManager)<T extends SBuildAgent>
voidsetRunConfigurationPolicy(T agent, BuildAgentManager.RunConfigurationPolicy policy)Sets build configuration run policy for an agent.voidunregisterAgent(int agentId)voidunregisterAgent(int id, String reason)voidunregisterAllAgents(String reason, boolean shouldCancelRunningBuilds)voidupdateAgentParameters(int agentId, String authorizationToken, AgentDescription newAgentDescription)Sets agent parameters to the database.
-
-
-
Constructor Detail
-
SecuredBuildAgentManager
public SecuredBuildAgentManager(@NotNull SecurityContextEx securityContext)
-
-
Method Detail
-
setDelegate
public void setDelegate(@NotNull BuildAgentManagerEx delegate)
-
setProjectManager
public void setProjectManager(@NotNull ProjectManager projectManager)
-
setAgentPoolManager
public void setAgentPoolManager(@NotNull AgentPoolManager agentPoolManager)
-
setAgentTypeManager
public void setAgentTypeManager(@NotNull AgentTypeManager agentTypeManager)
-
registerAgent
@NotNull public BuildAgentEx registerAgent(BuildAgentEx agent, long currentlyRunningBuildId) throws TeamCityRuntimeException
Description copied from interface:BuildAgentManagerExReturns 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:
registerAgentin interfaceBuildAgentManagerEx- Throws:
TeamCityRuntimeException
-
updateAgentParameters
public void updateAgentParameters(int agentId, @NotNull String authorizationToken, @NotNull AgentDescription newAgentDescription)Description copied from interface:BuildAgentManagerExSets 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:
updateAgentParametersin interfaceBuildAgentManagerEx
-
unregisterAgent
public void unregisterAgent(int agentId)
- Specified by:
unregisterAgentin interfaceBuildAgentManagerEx
-
unregisterAgent
public void unregisterAgent(int id, String reason)- Specified by:
unregisterAgentin interfaceBuildAgentManagerEx
-
unregisterAllAgents
public void unregisterAllAgents(String reason, boolean shouldCancelRunningBuilds)
- Specified by:
unregisterAllAgentsin interfaceBuildAgentManagerEx
-
pingAllAgents
public void pingAllAgents()
- Specified by:
pingAllAgentsin interfaceBuildAgentManagerEx
-
getRegisteredAgents
public List<BuildAgentEx> getRegisteredAgents(boolean includeUnauthorized)
Description copied from interface:BuildAgentManagerReturns all registered agents. Registered means connected at the moment of call.- Specified by:
getRegisteredAgentsin interfaceBuildAgentManager- Specified by:
getRegisteredAgentsin interfaceBuildAgentManagerEx- Parameters:
includeUnauthorized- if true, unauthorized agents, i.e. agents which cannot run builds until authorized by admin- Returns:
- see above
-
getRegisteredAgents
public List<BuildAgentEx> getRegisteredAgents()
Description copied from interface:BuildAgentManagerReturns all registered authorized agents. Registered means connected at the moment of call.- Specified by:
getRegisteredAgentsin interfaceBuildAgentManager- Specified by:
getRegisteredAgentsin interfaceBuildAgentManagerEx- Returns:
- see above
-
getUnregisteredAgents
public List<BuildAgentEx> getUnregisteredAgents(boolean includeUnauthorized)
Description copied from interface:BuildAgentManagerReturns list of all currently unregistered agents, with additional filter based on authorization status. See alsoBuildAgentManager.getUnregisteredAgents()- Specified by:
getUnregisteredAgentsin interfaceBuildAgentManager- Specified by:
getUnregisteredAgentsin interfaceBuildAgentManagerEx- Parameters:
includeUnauthorized- whether to include or exclude unauthorized agents- Returns:
- list of all currently unregistered agents
-
getUnregisteredAgents
public List<BuildAgentEx> getUnregisteredAgents()
Description copied from interface:BuildAgentManagerReturns 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:
getUnregisteredAgentsin interfaceBuildAgentManager- Specified by:
getUnregisteredAgentsin interfaceBuildAgentManagerEx- Returns:
- list of all currently unregistered agents
-
getAllAgents
public List<BuildAgentEx> getAllAgents()
- Specified by:
getAllAgentsin interfaceBuildAgentManagerEx
-
getAllAgents
public List<BuildAgentEx> getAllAgents(boolean includeUnauthorized)
- Specified by:
getAllAgentsin interfaceBuildAgentManagerEx
-
findAgentById
@Nullable public BuildAgentEx findAgentById(int agentId, boolean searchUnregistered)
Description copied from interface:BuildAgentManagerSearches for an agent with specified id among registered and unregistered agents.- Specified by:
findAgentByIdin interfaceBuildAgentManager- Specified by:
findAgentByIdin 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:BuildAgentManagerSearches for an agent with specified name among registered and unregistered agents.- Specified by:
findAgentByNamein interfaceBuildAgentManager- Specified by:
findAgentByNamein 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:
findAgentsByAgentTypeIdsin interfaceBuildAgentManagerEx
-
removeAgent
public void removeAgent(@NotNull SBuildAgent agent, @Nullable SUser user) throws AgentCannotBeRemovedExceptionDescription copied from interface:BuildAgentManagerRemoves specified agent and cleans up this agent state from the database. Only unregistered agents can be removed.- Specified by:
removeAgentin interfaceBuildAgentManager- Parameters:
agent- agentuser- user who removes agent (can be null)- Throws:
AgentCannotBeRemovedException- if agent is connected/registered
-
setRunConfigurationPolicy
public <T extends SBuildAgent> void setRunConfigurationPolicy(T agent, BuildAgentManager.RunConfigurationPolicy policy)
Description copied from interface:BuildAgentManagerSets 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:
setRunConfigurationPolicyin interfaceBuildAgentManager- Parameters:
agent- the agentpolicy- policy to set
-
-
getRunConfigurationPolicy
public <T extends SBuildAgent> BuildAgentManager.RunConfigurationPolicy getRunConfigurationPolicy(T agent)
Description copied from interface:BuildAgentManagerReturns run configuration policy for an agent.- Specified by:
getRunConfigurationPolicyin interfaceBuildAgentManager- Parameters:
agent- the agent- Returns:
- current run configuration policy
-
setCanRunConfiguration
public <T extends SBuildAgent> void setCanRunConfiguration(T agent, String buildTypeId, boolean canRun)
Description copied from interface:BuildAgentManagerIfBuildAgentManager.RunConfigurationPolicy.SELECTED_COMPATIBLE_CONFIGURATIONSpolicy is selected for the agent, sets whether configuration with specified id can or can't run on the agent.- Specified by:
setCanRunConfigurationin 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 <T extends SBuildAgent> boolean isCanRunConfiguration(T agent, BuildTypeDescriptor buildType)
Description copied from interface:BuildAgentManagerReturns true if specified agent can run specified build configuration.- Specified by:
isCanRunConfigurationin interfaceBuildAgentManager- Parameters:
agent- the agentbuildType- build configuration- Returns:
- true if
BuildAgentManager.RunConfigurationPolicy.ALL_COMPATIBLE_CONFIGURATIONSpolicy selected or configuration was explicitly marked as accessible by the agent. Please note that compatibility check is not performed.
-
getCanRunConfigurations
public <T extends SBuildAgent> Set<String> getCanRunConfigurations(T agent)
Description copied from interface:BuildAgentManagerReturns list of build configurations this agent can potentially run.- Specified by:
getCanRunConfigurationsin interfaceBuildAgentManager- Parameters:
agent- the agent- Returns:
- list of ids of potentially available for this agent configurations
-
getNumberOfCompatibleConfigurations
public <T extends SBuildAgent> int getNumberOfCompatibleConfigurations(T agent)
Description copied from interface:BuildAgentManagerReturns number of configurations compatible with specified agent- Specified by:
getNumberOfCompatibleConfigurationsin interfaceBuildAgentManager- Parameters:
agent- agent- Returns:
- number of compatible configurations
-
getNumberOfIncompatibleConfigurations
public <T extends SBuildAgent> int getNumberOfIncompatibleConfigurations(T agent)
Description copied from interface:BuildAgentManagerReturns number of configurations incompatible with specified agent- Specified by:
getNumberOfIncompatibleConfigurationsin interfaceBuildAgentManager- Parameters:
agent- agent- Returns:
- number of incompatible configurations
-
getAgentCompatibilities
public <T extends SBuildAgent> List<AgentCompatibility> getAgentCompatibilities(T agent)
Description copied from interface:BuildAgentManagerReturns build configuration compatibility information for the specified agent- Specified by:
getAgentCompatibilitiesin interfaceBuildAgentManager- Parameters:
agent- agent- Returns:
- build configuration compatibility information
-
getNumberOfRegisteredAgents
public int getNumberOfRegisteredAgents()
Description copied from interface:BuildAgentManagerReturns number of registered and authorized agents- Specified by:
getNumberOfRegisteredAgentsin interfaceBuildAgentManager- Returns:
- see above
-
setAgentDistributionMonitor
public void setAgentDistributionMonitor(@NotNull AgentDistributionMonitor monitor)- Specified by:
setAgentDistributionMonitorin interfaceAgentDistributionMonitorAware- Specified by:
setAgentDistributionMonitorin interfaceBuildAgentManagerEx
-
registrationIsTemporallyNotAvailable
public boolean registrationIsTemporallyNotAvailable()
- Specified by:
registrationIsTemporallyNotAvailablein interfaceBuildAgentManagerEx
-
-