Interface AgentPoolManager
-
- All Known Implementing Classes:
AgentPoolManagerImpl
,FakeAgentPoolManager
,SecuredAgentPoolManager
public interface AgentPoolManager
- Since:
- 7.0
- Author:
- Maxim.Manuylov, Leonid.Bushuev
-
-
Method Summary
All Methods Instance Methods Abstract Methods Modifier and Type Method Description void
addListener(AgentPoolListener listener)
Adds listener for agent pool events.boolean
agentPoolContainsProject(int poolId, String projectId)
Returns true if agent pool with specified id exists and contains project with specified internal id.void
associateProjectsWithPool(int agentPoolId, Set<String> projectIds)
Associates specified projects with the specified pool.boolean
canAddAgent(int poolId)
Returns true if this pool can add least one more agentboolean
canAddAgents(int poolId, int count)
Returns true if this pool can add desired # of agentsString
checkAgentPoolCanBeUsedByCloudProfile(String cloudProfileId, AgentPool agentPool)
Checks if agent from the given cloud profile can be used with a specified pool.void
copyPoolAssociations(String sourceProjectId, String targetProjectId)
Copies set of pools associations from one project to the other.AgentPool
createNewAgentPool(String agentPoolName)
Creates new agent pool with the specified name and no limits.AgentPool
createNewAgentPool(String agentPoolName, AgentPoolLimits poolLimits)
Creates new agent pool with the specified name and specific limitsAgentPool
createUnknownPool(int agentPoolId)
Creates an instance of "unknown" pool without writing anything to DB.AgentPool
deleteAgentPool(int agentPoolId)
Deletes agent pool with the specified identifier.void
dissociateProjectsFromOtherPools(int agentPoolId, Set<String> projectIds)
Dissociates specified projects from all the pools except the specified one.void
dissociateProjectsFromPool(int agentPoolId, Set<String> projectIds)
Dissociates specified projects from the specified pool.void
ensureAgentTypeIsAssignedToPool(int agentTypeId)
This method ensures that agent type with specified id belongs at least to the default agent pool.AgentPool
findAgentPoolById(int agentPoolId)
Returns agent pool with the specified identifier.AgentPool
findAgentPoolByTypeId(int agentTypeId)
Searches for agent pool by agent type id.int
findAgentPoolIdByTypeId(int agentTypeId)
Returns agent pool id for the specified agent type id or -1 if there is no such pool or agent type.Map<Integer,AgentPool>
findAgentPoolsByIds(Collection<Integer> agentPoolIds)
Returns a map of agent pools corresponding to the specified agent pool idsAgentPool
findProjectPoolByProjectId(String projectId)
Creates pool for project in memory, without persisting it to DBSet<Integer>
getAgentPoolsWithProject(String projectId)
Returns all associated pools for the specified project.Collection<Integer>
getAgentTypeIdsByPool(int agentPoolId)
Returns agent type ids associated with the specified poolList<AgentPool>
getAllAgentPools()
Returns all agent pools.List<AgentPool>
getAllAgentPoolsEx(boolean includeProjectPools)
returns list of agent pools (see options)Collection<Pair<Integer,String>>
getAllPoolProjectRelations()
Returns all pool--project relations.int
getNumberOfAgentPools()
Returns number of agent pools.AgentPool
getOrCreateProjectPool(String projectId)
Creates pool for project in memory, without persisting it to DBSet<String>
getPoolProjects(int poolId)
Returns projects that are associated with the specified pool.Set<Integer>
getProjectAgentTypes(String projectId)
Returns all agents from pools the given projects associated with.Collection<AgentPool>
getProjectOwnedAgentPools(String projectExternalId)
Returns agent pools that include only projects that are under this project's tree (including the project itself).boolean
hasSeveralPools()
Returns true if number of agent pools is greater than one.void
moveAgentToPool(int agentPoolId, BuildAgentEx agent)
Moves specified agent to the specified pool.void
moveAgentTypesToPool(int agentPoolId, Set<Integer> agentTypeIds)
Moves specified agent types to the specified pool.void
moveAgentTypesToProjectPool(String projectId, Set<Integer> agentTypeIds)
Moves the specified agent types to the project agents pool corresponding to the specified project id (pool will be created if it does not exist)AgentPool
updateAgentPool(int agentPoolId, String newAgentPoolName, AgentPoolLimits poolLimits)
Renames agent pool with the specified identifier.
-
-
-
Method Detail
-
getAllAgentPoolsEx
@NotNull List<AgentPool> getAllAgentPoolsEx(boolean includeProjectPools)
returns list of agent pools (see options)- Parameters:
includeProjectPools
- - true to include project pools- Returns:
-
getAllAgentPools
@NotNull List<AgentPool> getAllAgentPools()
Returns all agent pools. Sorting is by name, but default pool is always the last.- Returns:
- see above
-
getNumberOfAgentPools
int getNumberOfAgentPools()
Returns number of agent pools.- Returns:
- see above
-
hasSeveralPools
boolean hasSeveralPools()
Returns true if number of agent pools is greater than one.- Returns:
- see above
-
findAgentPoolById
@Nullable AgentPool findAgentPoolById(int agentPoolId)
Returns agent pool with the specified identifier.- Parameters:
agentPoolId
- agent pool id- Returns:
- agent pool or null if it does not exist
-
findAgentPoolsByIds
@NotNull Map<Integer,AgentPool> findAgentPoolsByIds(@NotNull Collection<Integer> agentPoolIds)
Returns a map of agent pools corresponding to the specified agent pool ids- Parameters:
agentPoolIds
-- Returns:
- see above
- Since:
- 2024.12
-
createNewAgentPool
@NotNull AgentPool createNewAgentPool(@NotNull String agentPoolName) throws AgentPoolCannotBeRenamedException
Creates new agent pool with the specified name and no limits.- Parameters:
agentPoolName
- agent pool name- Returns:
- identifier of the created agent pool
- Throws:
AgentPoolCannotBeRenamedException
- if the agent pool with such name already exists
-
createNewAgentPool
@NotNull AgentPool createNewAgentPool(@NotNull String agentPoolName, @NotNull AgentPoolLimits poolLimits) throws AgentPoolCannotBeRenamedException
Creates new agent pool with the specified name and specific limits- Parameters:
agentPoolName
- agent pool namepoolLimits
- - agent pool limits- Returns:
- identifier of the created agent pool
- Throws:
AgentPoolCannotBeRenamedException
- if the agent pool with such name already exists- Since:
- 10.0
-
createUnknownPool
@NotNull AgentPool createUnknownPool(int agentPoolId)
Creates an instance of "unknown" pool without writing anything to DB. Used in special cases- Parameters:
agentPoolId
- agent pool id- Returns:
- identifier of the created agent pool
- Since:
- 2017.2.4
-
updateAgentPool
@NotNull AgentPool updateAgentPool(int agentPoolId, @NotNull String newAgentPoolName, @NotNull AgentPoolLimits poolLimits) throws NoSuchAgentPoolException, AgentPoolCannotBeRenamedException
Renames agent pool with the specified identifier.- Parameters:
agentPoolId
- agent pool idnewAgentPoolName
- new agent pool namepoolLimits
- - agent pool limits- Returns:
- previous state of the agent pool
- Throws:
NoSuchAgentPoolException
- if the specified agent pool does not existAgentPoolCannotBeRenamedException
- if it is an attempt to rename default agent pool or the agent pool with such name already exists- Since:
- 10.0
-
deleteAgentPool
@NotNull AgentPool deleteAgentPool(int agentPoolId) throws NoSuchAgentPoolException, AgentPoolCannotBeDeletedException
Deletes agent pool with the specified identifier. If there are some agent types those belong to this pool, they will be moved to default pool.- Parameters:
agentPoolId
- agent pool id- Returns:
- previous state of the agent pool
- Throws:
NoSuchAgentPoolException
- if the specified agent pool does not existAgentPoolCannotBeDeletedException
- if it is an attempt to delete default agent pool
-
addListener
void addListener(@NotNull AgentPoolListener listener)
Adds listener for agent pool events.- Parameters:
listener
- listener
-
moveAgentTypesToPool
void moveAgentTypesToPool(int agentPoolId, @NotNull Set<Integer> agentTypeIds) throws NoSuchAgentPoolException, PoolQuotaExceededException, AgentTypeCannotBeMovedException
Moves specified agent types to the specified pool.- Parameters:
agentPoolId
- agent pool idagentTypeIds
- agent type ids- Throws:
NoSuchAgentPoolException
- if the specified agent pool does not existPoolQuotaExceededException
- if pool quota cannot accept desired # of agentsAgentTypeCannotBeMovedException
-
moveAgentTypesToProjectPool
void moveAgentTypesToProjectPool(@NotNull String projectId, @NotNull Set<Integer> agentTypeIds) throws PoolQuotaExceededException, AgentTypeCannotBeMovedException
Moves the specified agent types to the project agents pool corresponding to the specified project id (pool will be created if it does not exist)- Parameters:
projectId
-agentTypeIds
-- Throws:
PoolQuotaExceededException
AgentTypeCannotBeMovedException
-
checkAgentPoolCanBeUsedByCloudProfile
@Nullable String checkAgentPoolCanBeUsedByCloudProfile(@NotNull String cloudProfileId, @NotNull AgentPool agentPool)
Checks if agent from the given cloud profile can be used with a specified pool.- Parameters:
cloudProfileId
- - agent's cloud profile idagentPool
- - destination pool- Returns:
- - reason why agents from the given cloud profile cannot be used with specified pool or 'null' otherwise
- Since:
- 2024.03
-
moveAgentToPool
void moveAgentToPool(int agentPoolId, @NotNull BuildAgentEx agent) throws NoSuchAgentPoolException, PoolQuotaExceededException, AgentTypeCannotBeMovedException
Moves specified agent to the specified pool.- Parameters:
agentPoolId
- agent pool idagent
- agent- Throws:
NoSuchAgentPoolException
- if the specified agent pool does not existPoolQuotaExceededException
- if pool quota cannot accept desired # of agentsAgentTypeCannotBeMovedException
-
associateProjectsWithPool
void associateProjectsWithPool(int agentPoolId, @NotNull Set<String> projectIds) throws NoSuchAgentPoolException
Associates specified projects with the specified pool. Does not affect projects which are not specified in parameters.- Parameters:
agentPoolId
- agent pool idprojectIds
- project ids to associate with the specified pool- Throws:
NoSuchAgentPoolException
- if the specified agent pool does not exist
-
dissociateProjectsFromPool
void dissociateProjectsFromPool(int agentPoolId, @NotNull Set<String> projectIds) throws NoSuchAgentPoolException
Dissociates specified projects from the specified pool. Does not affect projects which are not specified in parameters.- Parameters:
agentPoolId
- agent pool idprojectIds
- project ids to dissociate from the specified pool- Throws:
NoSuchAgentPoolException
- if the specified agent pool does not exist
-
dissociateProjectsFromOtherPools
void dissociateProjectsFromOtherPools(int agentPoolId, @NotNull Set<String> projectIds)
Dissociates specified projects from all the pools except the specified one. Does not affect projects which are not specified in parameters. Does not affect agent pool which is specified in parameters.- Parameters:
agentPoolId
- agent pool idprojectIds
- project ids to dissociate from all the pools except the specified one
-
copyPoolAssociations
void copyPoolAssociations(@NotNull String sourceProjectId, @NotNull String targetProjectId)
Copies set of pools associations from one project to the other.- Parameters:
sourceProjectId
- sourcetargetProjectId
- target
-
getAllPoolProjectRelations
@NotNull Collection<Pair<Integer,String>> getAllPoolProjectRelations()
Returns all pool--project relations.- Returns:
- pool--project relations as an unsorted collection of pairs where first element is a pool id and second element is a project id.
-
getAgentPoolsWithProject
@NotNull Set<Integer> getAgentPoolsWithProject(@NotNull String projectId)
Returns all associated pools for the specified project.- Parameters:
projectId
- project id- Returns:
- set of agent pool ids
- Since:
- 2018.1
-
getProjectOwnedAgentPools
@NotNull Collection<AgentPool> getProjectOwnedAgentPools(@NotNull String projectExternalId)
Returns agent pools that include only projects that are under this project's tree (including the project itself).- Parameters:
projectExternalId
-- Returns:
-
getProjectAgentTypes
@NotNull Set<Integer> getProjectAgentTypes(@NotNull String projectId)
Returns all agents from pools the given projects associated with.- Parameters:
projectId
- project id- Returns:
- set of agent tyeps ids
-
getPoolProjects
@NotNull Set<String> getPoolProjects(int poolId)
Returns projects that are associated with the specified pool.- Parameters:
poolId
- pool identifier we want projects for.- Returns:
- set of internal project ids.
-
agentPoolContainsProject
boolean agentPoolContainsProject(int poolId, @NotNull String projectId)
Returns true if agent pool with specified id exists and contains project with specified internal id.- Parameters:
poolId
- pool idprojectId
- project id- Returns:
- see above
- Since:
- 2020.2
-
canAddAgent
boolean canAddAgent(int poolId) throws NoSuchAgentPoolException
Returns true if this pool can add least one more agent- Returns:
- see above
- Throws:
NoSuchAgentPoolException
- Since:
- 10.0
-
canAddAgents
boolean canAddAgents(int poolId, int count) throws NoSuchAgentPoolException
Returns true if this pool can add desired # of agents- Parameters:
count
- number of agents to add- Returns:
- Throws:
NoSuchAgentPoolException
- Since:
- 10.0
-
getAgentTypeIdsByPool
@NotNull Collection<Integer> getAgentTypeIdsByPool(int agentPoolId)
Returns agent type ids associated with the specified pool- Parameters:
agentPoolId
- - agent pool internal id- Since:
- 10.0
-
findAgentPoolByTypeId
@Nullable AgentPool findAgentPoolByTypeId(int agentTypeId)
Searches for agent pool by agent type id.- Parameters:
agentTypeId
- agent type id- Returns:
- found agent pool or null
- Since:
- 2018.1
-
findAgentPoolIdByTypeId
int findAgentPoolIdByTypeId(int agentTypeId)
Returns agent pool id for the specified agent type id or -1 if there is no such pool or agent type.- Parameters:
agentTypeId
- agent type id- Returns:
- found agent pool id or -1
- Since:
- 2018.1.2
-
getOrCreateProjectPool
@NotNull AgentPool getOrCreateProjectPool(@NotNull String projectId)
Creates pool for project in memory, without persisting it to DB- Parameters:
projectId
-- Since:
- 2017.1
-
findProjectPoolByProjectId
@Nullable AgentPool findProjectPoolByProjectId(@NotNull String projectId)
Creates pool for project in memory, without persisting it to DB- Parameters:
projectId
-- Since:
- 2017.1.3
-
ensureAgentTypeIsAssignedToPool
void ensureAgentTypeIsAssignedToPool(int agentTypeId)
This method ensures that agent type with specified id belongs at least to the default agent pool. A call of this method is required for every new agent type, because newly created agent types no longer belong to default pool by default.- Parameters:
agentTypeId
-
-
-