Class AgentTypeManagerImpl
- java.lang.Object
-
- jetbrains.buildServer.serverSide.agentTypes.AgentTypeManagerImpl
-
- All Implemented Interfaces:
AgentTypeManager
,AgentTypeStorage
public class AgentTypeManagerImpl extends Object implements AgentTypeManager
- Author:
- Eugene Petrenko Created: 04.09.2009 12:38:26
-
-
Constructor Summary
Constructors Constructor Description AgentTypeManagerImpl(EventDispatcher<BuildServerListener> dispatcher)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description int
assignAgentType(BuildAgentEx agent)
Creates agent type for specified agent if agent does not have one and assigns it to the agent.void
copyAgentTypeRestrictions(String originalBuildTypeId, String newBuildTypeId)
void
copyAgentTypeRestrictions(BuildTypeDescriptor originalBuildType, BuildTypeDescriptor newBuildType)
void
deleteAgentType(int agentTypeId)
void
excludeBuildTypesFromAllowed(int agentTypeId, Set<String> buildTypeIds)
Removes the given build configurations from the list of allowed ones.void
excludeRunConfigurationsFromAllowed(int agentTypeId, String[] buildTypeIds)
AgentType
findAgentTypeById(int agentTypeId)
Finds agent type in agent type id.AgentType
findAgentTypeByKey(AgentTypeKey agentTypeKey)
Finds agent type in database by specified key.Map<Integer,AgentType>
findAgentTypesByIds(Collection<Integer> agentTypeIds)
Returns map of agent types corresponding to the specified agent type idsList<AgentCompatibility>
getAgentTypeCompatibilities(SAgentType agentType)
Set<Integer>
getAgentTypeIds()
Returns all known agent type identifiers.Collection<Integer>
getAgentTypeIdsByPool(int agentPoolId)
Map<Integer,AgentTypeKey>
getAgentTypePairs()
Set<String>
getCanRunConfigurations(int agentTypeId)
int
getNumberOfCompatibleConfigurations(SAgentType agentType)
int
getNumberOfIncompatibleConfigurations(SAgentType agentType)
int
getOrCreateAgentTypeId(AgentTypeKey key)
similar toAgentTypeManager.getOrCreateAgentTypeId(jetbrains.buildServer.serverSide.agentTypes.AgentTypeKey, int)
, puts agentType to the "Default" pool, if it doesn't existint
getOrCreateAgentTypeId(AgentTypeKey key, int defaultRawPoolId)
Maps created agent type key into agentTypeId.AgentTypePolicy
getPolicy(int agentTypeId)
Loads the policy from database (if not loaded yet) and returns it.BuildAgentManager.RunConfigurationPolicy
getRunConfigurationPolicy(int agentTypeId)
void
includeBuildTypesToAllowed(int agentTypeId, Set<String> buildTypeIds)
Adds the given build configurations to the list of allowed ones.void
includeRunConfigurationsToAllowed(int agentTypeId, String[] buildTypeIds)
void
invalidateCacheForAgentTypesFromPools(Set<Integer> agentPoolIds, CacheClearPolicy policy)
void
invalidateCacheForAllAgentTypes()
void
invalidateCacheForOneAgentType(int agentTypeId, CacheClearPolicy policy)
boolean
isAllowedToRun(int agentTypeId, String projectId, String buildTypeId)
Checks whether the given build configuration (buildTypeId) is allowed to run on the specified agent type (agentTypeId).boolean
isCanRunConfiguration(int agentTypeId, BuildTypeDescriptor buildType)
void
migrateAgentTypeKey(AgentTypeKey currentKey, AgentTypeKey newKey)
void
removeBuildTypeFromAllLists(String buildTypeId)
Removes the specified build configuration from all allowed configurations lists, and invalidates internal cache.void
setAgentTypeProviderRegistry(AgentTypeProviderRegistry agentTypeProviderRegistry)
void
setAuditLogFactory(AuditLogFactory auditLogFactory)
void
setExtensionsHolder(ExtensionsProvider extensionsHolder)
void
setPolicyKind(int agentTypeId, int newPolicyKind)
Changes policy kind for the specified agent.void
setProjectManager(ProjectManagerEx projectManager)
void
setRunConfigurationPolicy(int agentTypeId, BuildAgentManager.RunConfigurationPolicy policy)
void
setStorage(AgentTypeDatabaseStorage storage)
void
updateAgentType(int agentTypeId, AgentDescription agentDescription, boolean isInitialUpdate)
updates agent type parameters from the agent's parametersvoid
updateAgentType(BuildAgentEx agent, boolean isInitialUpdate)
updates agent type parameters from the agent's parametersvoid
updateAgentTypeFromDB(int agentTypeId)
-
-
-
Constructor Detail
-
AgentTypeManagerImpl
public AgentTypeManagerImpl(@NotNull EventDispatcher<BuildServerListener> dispatcher)
-
-
Method Detail
-
setAgentTypeProviderRegistry
public void setAgentTypeProviderRegistry(@NotNull AgentTypeProviderRegistry agentTypeProviderRegistry)
-
setStorage
public void setStorage(@NotNull AgentTypeDatabaseStorage storage)
-
setAuditLogFactory
public void setAuditLogFactory(@NotNull AuditLogFactory auditLogFactory)
-
setProjectManager
public void setProjectManager(@NotNull ProjectManagerEx projectManager)
-
setExtensionsHolder
public void setExtensionsHolder(@NotNull ExtensionsProvider extensionsHolder)
-
updateAgentType
public void updateAgentType(@NotNull BuildAgentEx agent, boolean isInitialUpdate)
Description copied from interface:AgentTypeManager
updates agent type parameters from the agent's parameters- Specified by:
updateAgentType
in interfaceAgentTypeManager
- Parameters:
agent
- the agentisInitialUpdate
- if then this is the update of agent type parameters when the agent is first registered, if false then this is a periodical update which happens while the agent is already registered and runs some builds
-
updateAgentType
public void updateAgentType(int agentTypeId, @NotNull AgentDescription agentDescription, boolean isInitialUpdate)
Description copied from interface:AgentTypeManager
updates agent type parameters from the agent's parameters- Specified by:
updateAgentType
in interfaceAgentTypeManager
- Parameters:
agentTypeId
- agent type idagentDescription
- agent description
-
assignAgentType
public int assignAgentType(@NotNull BuildAgentEx agent)
Description copied from interface:AgentTypeManager
Creates agent type for specified agent if agent does not have one and assigns it to the agent.- Specified by:
assignAgentType
in interfaceAgentTypeManager
- Returns:
- id of new agent type
-
getOrCreateAgentTypeId
public int getOrCreateAgentTypeId(@NotNull AgentTypeKey key)
Description copied from interface:AgentTypeManager
similar toAgentTypeManager.getOrCreateAgentTypeId(jetbrains.buildServer.serverSide.agentTypes.AgentTypeKey, int)
, puts agentType to the "Default" pool, if it doesn't exist- Specified by:
getOrCreateAgentTypeId
in interfaceAgentTypeManager
- Specified by:
getOrCreateAgentTypeId
in interfaceAgentTypeStorage
- Parameters:
key
- agent type key which identifier is requested.- Returns:
- agent type identifier.
-
getOrCreateAgentTypeId
public int getOrCreateAgentTypeId(@NotNull AgentTypeKey key, int defaultRawPoolId)
Maps created agent type key into agentTypeId. This method should lookup to the storage or allocate new item.- Specified by:
getOrCreateAgentTypeId
in interfaceAgentTypeManager
- Specified by:
getOrCreateAgentTypeId
in interfaceAgentTypeStorage
- Parameters:
key
- agent type key recieved from plugindefaultRawPoolId
-- Returns:
- agent type id
-
findAgentTypeById
@Nullable public AgentType findAgentTypeById(int agentTypeId)
Finds agent type in agent type id.- Specified by:
findAgentTypeById
in interfaceAgentTypeStorage
- Parameters:
agentTypeId
- agent type id.- Returns:
- loaded
AgentType
or null if agent type not found. - Since:
- 7.0
-
findAgentTypesByIds
@NotNull public Map<Integer,AgentType> findAgentTypesByIds(@NotNull Collection<Integer> agentTypeIds)
Description copied from interface:AgentTypeStorage
Returns map of agent types corresponding to the specified agent type ids- Specified by:
findAgentTypesByIds
in interfaceAgentTypeStorage
- Parameters:
agentTypeIds
- ids of agent types- Returns:
- see above
-
findAgentTypeByKey
@Nullable public AgentType findAgentTypeByKey(@NotNull AgentTypeKey agentTypeKey)
Finds agent type in database by specified key.- Specified by:
findAgentTypeByKey
in interfaceAgentTypeStorage
- Parameters:
agentTypeKey
- agent type key.- Returns:
- loaded
AgentType
or null if agent type not found. - Since:
- 9.1
-
getAgentTypeIds
@NotNull public Set<Integer> getAgentTypeIds()
Returns all known agent type identifiers. This function should be fast.- Specified by:
getAgentTypeIds
in interfaceAgentTypeStorage
- Returns:
- set of agent type identifiers.
-
getAgentTypePairs
public Map<Integer,AgentTypeKey> getAgentTypePairs()
- Specified by:
getAgentTypePairs
in interfaceAgentTypeStorage
-
getAgentTypeIdsByPool
@NotNull public Collection<Integer> getAgentTypeIdsByPool(int agentPoolId)
- Specified by:
getAgentTypeIdsByPool
in interfaceAgentTypeStorage
-
getPolicy
@NotNull public AgentTypePolicy getPolicy(int agentTypeId)
Loads the policy from database (if not loaded yet) and returns it.- Specified by:
getPolicy
in interfaceAgentTypeStorage
- Parameters:
agentTypeId
- agent type.- Returns:
- policy.
- Since:
- 7.0
-
setPolicyKind
public void setPolicyKind(int agentTypeId, int newPolicyKind)
Changes policy kind for the specified agent.- Specified by:
setPolicyKind
in interfaceAgentTypeStorage
- Parameters:
agentTypeId
- agent which policy to change.newPolicyKind
- new policy kind.- Since:
- 7.0
-
includeBuildTypesToAllowed
public void includeBuildTypesToAllowed(int agentTypeId, @NotNull Set<String> buildTypeIds)
Adds the given build configurations to the list of allowed ones.- Specified by:
includeBuildTypesToAllowed
in interfaceAgentTypeStorage
- Parameters:
agentTypeId
- agent type.buildTypeIds
- build configurations to add to the list of allowed.- Since:
- 7.0
-
excludeBuildTypesFromAllowed
public void excludeBuildTypesFromAllowed(int agentTypeId, @NotNull Set<String> buildTypeIds)
Removes the given build configurations from the list of allowed ones.- Specified by:
excludeBuildTypesFromAllowed
in interfaceAgentTypeStorage
- Parameters:
agentTypeId
- agent type.buildTypeIds
- build configurations to remove from the list of allowed.- Since:
- 7.0
-
isAllowedToRun
public boolean isAllowedToRun(int agentTypeId, @NotNull String projectId, @NotNull String buildTypeId)
Checks whether the given build configuration (buildTypeId) is allowed to run on the specified agent type (agentTypeId).- Specified by:
isAllowedToRun
in interfaceAgentTypeStorage
- Parameters:
agentTypeId
- agent type.projectId
-buildTypeId
- build configuration. @return true if allowed.- Since:
- 7.0
-
removeBuildTypeFromAllLists
public void removeBuildTypeFromAllLists(@NotNull String buildTypeId)
Removes the specified build configuration from all allowed configurations lists, and invalidates internal cache. This method is designed to call it when a build configuration is being deleted.- Specified by:
removeBuildTypeFromAllLists
in interfaceAgentTypeStorage
- Parameters:
buildTypeId
- build configuration identifier.- Since:
- 7.0
-
copyAgentTypeRestrictions
public void copyAgentTypeRestrictions(@NotNull String originalBuildTypeId, @NotNull String newBuildTypeId)
- Specified by:
copyAgentTypeRestrictions
in interfaceAgentTypeStorage
-
invalidateCacheForAllAgentTypes
public void invalidateCacheForAllAgentTypes()
- Specified by:
invalidateCacheForAllAgentTypes
in interfaceAgentTypeStorage
-
invalidateCacheForAgentTypesFromPools
public void invalidateCacheForAgentTypesFromPools(@NotNull Set<Integer> agentPoolIds, @NotNull CacheClearPolicy policy)
- Specified by:
invalidateCacheForAgentTypesFromPools
in interfaceAgentTypeStorage
-
invalidateCacheForOneAgentType
public void invalidateCacheForOneAgentType(int agentTypeId, @NotNull CacheClearPolicy policy)
- Specified by:
invalidateCacheForOneAgentType
in interfaceAgentTypeStorage
-
updateAgentTypeFromDB
public void updateAgentTypeFromDB(int agentTypeId)
- Specified by:
updateAgentTypeFromDB
in interfaceAgentTypeStorage
-
deleteAgentType
public void deleteAgentType(int agentTypeId)
- Specified by:
deleteAgentType
in interfaceAgentTypeStorage
-
setRunConfigurationPolicy
public void setRunConfigurationPolicy(int agentTypeId, @NotNull BuildAgentManager.RunConfigurationPolicy policy)
- Specified by:
setRunConfigurationPolicy
in interfaceAgentTypeManager
-
getRunConfigurationPolicy
@NotNull public BuildAgentManager.RunConfigurationPolicy getRunConfigurationPolicy(int agentTypeId)
- Specified by:
getRunConfigurationPolicy
in interfaceAgentTypeManager
-
includeRunConfigurationsToAllowed
public void includeRunConfigurationsToAllowed(int agentTypeId, @NotNull String[] buildTypeIds)
- Specified by:
includeRunConfigurationsToAllowed
in interfaceAgentTypeManager
-
excludeRunConfigurationsFromAllowed
public void excludeRunConfigurationsFromAllowed(int agentTypeId, @NotNull String[] buildTypeIds)
- Specified by:
excludeRunConfigurationsFromAllowed
in interfaceAgentTypeManager
-
isCanRunConfiguration
public boolean isCanRunConfiguration(int agentTypeId, @NotNull BuildTypeDescriptor buildType)
- Specified by:
isCanRunConfiguration
in interfaceAgentTypeManager
-
getCanRunConfigurations
@NotNull public Set<String> getCanRunConfigurations(int agentTypeId)
- Specified by:
getCanRunConfigurations
in interfaceAgentTypeManager
-
getNumberOfCompatibleConfigurations
public int getNumberOfCompatibleConfigurations(@NotNull SAgentType agentType)
- Specified by:
getNumberOfCompatibleConfigurations
in interfaceAgentTypeManager
-
getNumberOfIncompatibleConfigurations
public int getNumberOfIncompatibleConfigurations(@NotNull SAgentType agentType)
- Specified by:
getNumberOfIncompatibleConfigurations
in interfaceAgentTypeManager
-
getAgentTypeCompatibilities
@NotNull public List<AgentCompatibility> getAgentTypeCompatibilities(@NotNull SAgentType agentType)
- Specified by:
getAgentTypeCompatibilities
in interfaceAgentTypeManager
-
copyAgentTypeRestrictions
public void copyAgentTypeRestrictions(@NotNull BuildTypeDescriptor originalBuildType, @NotNull BuildTypeDescriptor newBuildType)
- Specified by:
copyAgentTypeRestrictions
in interfaceAgentTypeManager
-
migrateAgentTypeKey
public void migrateAgentTypeKey(@NotNull AgentTypeKey currentKey, @NotNull AgentTypeKey newKey)
- Specified by:
migrateAgentTypeKey
in interfaceAgentTypeManager
-
-