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 intassignAgentType(BuildAgentEx agent)Creates agent type for specified agent if agent does not have one and assigns it to the agent.voidcopyAgentTypeRestrictions(String originalBuildTypeId, String newBuildTypeId)voidcopyAgentTypeRestrictions(BuildTypeDescriptor originalBuildType, BuildTypeDescriptor newBuildType)voiddeleteAgentType(int agentTypeId)voidexcludeBuildTypesFromAllowed(int agentTypeId, Set<String> buildTypeIds)Removes the given build configurations from the list of allowed ones.voidexcludeRunConfigurationsFromAllowed(int agentTypeId, String[] buildTypeIds)AgentTypefindAgentTypeById(int agentTypeId)Finds agent type in agent type id.AgentTypefindAgentTypeByKey(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)intgetNumberOfCompatibleConfigurations(SAgentType agentType)intgetNumberOfIncompatibleConfigurations(SAgentType agentType)intgetOrCreateAgentTypeId(AgentTypeKey key)similar toAgentTypeManager.getOrCreateAgentTypeId(jetbrains.buildServer.serverSide.agentTypes.AgentTypeKey, int), puts agentType to the "Default" pool, if it doesn't existintgetOrCreateAgentTypeId(AgentTypeKey key, int defaultRawPoolId)Maps created agent type key into agentTypeId.AgentTypePolicygetPolicy(int agentTypeId)Loads the policy from database (if not loaded yet) and returns it.BuildAgentManager.RunConfigurationPolicygetRunConfigurationPolicy(int agentTypeId)voidincludeBuildTypesToAllowed(int agentTypeId, Set<String> buildTypeIds)Adds the given build configurations to the list of allowed ones.voidincludeRunConfigurationsToAllowed(int agentTypeId, String[] buildTypeIds)voidinvalidateCacheForAgentTypesFromPools(Set<Integer> agentPoolIds, CacheClearPolicy policy)voidinvalidateCacheForAllAgentTypes()voidinvalidateCacheForOneAgentType(int agentTypeId, CacheClearPolicy policy)booleanisAllowedToRun(int agentTypeId, String projectId, String buildTypeId)Checks whether the given build configuration (buildTypeId) is allowed to run on the specified agent type (agentTypeId).booleanisCanRunConfiguration(int agentTypeId, BuildTypeDescriptor buildType)voidmigrateAgentTypeKey(AgentTypeKey currentKey, AgentTypeKey newKey)voidremoveBuildTypeFromAllLists(String buildTypeId)Removes the specified build configuration from all allowed configurations lists, and invalidates internal cache.voidsetAgentTypeProviderRegistry(AgentTypeProviderRegistry agentTypeProviderRegistry)voidsetAuditLogFactory(AuditLogFactory auditLogFactory)voidsetExtensionsHolder(ExtensionsProvider extensionsHolder)voidsetPolicyKind(int agentTypeId, int newPolicyKind)Changes policy kind for the specified agent.voidsetProjectManager(ProjectManagerEx projectManager)voidsetRunConfigurationPolicy(int agentTypeId, BuildAgentManager.RunConfigurationPolicy policy)voidsetStorage(AgentTypeDatabaseStorage storage)voidupdateAgentType(int agentTypeId, AgentDescription agentDescription, boolean isInitialUpdate)updates agent type parameters from the agent's parametersvoidupdateAgentType(BuildAgentEx agent, boolean isInitialUpdate)updates agent type parameters from the agent's parametersvoidupdateAgentTypeFromDB(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:AgentTypeManagerupdates agent type parameters from the agent's parameters- Specified by:
updateAgentTypein 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:AgentTypeManagerupdates agent type parameters from the agent's parameters- Specified by:
updateAgentTypein interfaceAgentTypeManager- Parameters:
agentTypeId- agent type idagentDescription- agent description
-
assignAgentType
public int assignAgentType(@NotNull BuildAgentEx agent)Description copied from interface:AgentTypeManagerCreates agent type for specified agent if agent does not have one and assigns it to the agent.- Specified by:
assignAgentTypein interfaceAgentTypeManager- Returns:
- id of new agent type
-
getOrCreateAgentTypeId
public int getOrCreateAgentTypeId(@NotNull AgentTypeKey key)Description copied from interface:AgentTypeManagersimilar toAgentTypeManager.getOrCreateAgentTypeId(jetbrains.buildServer.serverSide.agentTypes.AgentTypeKey, int), puts agentType to the "Default" pool, if it doesn't exist- Specified by:
getOrCreateAgentTypeIdin interfaceAgentTypeManager- Specified by:
getOrCreateAgentTypeIdin 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:
getOrCreateAgentTypeIdin interfaceAgentTypeManager- Specified by:
getOrCreateAgentTypeIdin 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:
findAgentTypeByIdin interfaceAgentTypeStorage- Parameters:
agentTypeId- agent type id.- Returns:
- loaded
AgentTypeor null if agent type not found. - Since:
- 7.0
-
findAgentTypesByIds
@NotNull public Map<Integer,AgentType> findAgentTypesByIds(@NotNull Collection<Integer> agentTypeIds)
Description copied from interface:AgentTypeStorageReturns map of agent types corresponding to the specified agent type ids- Specified by:
findAgentTypesByIdsin 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:
findAgentTypeByKeyin interfaceAgentTypeStorage- Parameters:
agentTypeKey- agent type key.- Returns:
- loaded
AgentTypeor 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:
getAgentTypeIdsin interfaceAgentTypeStorage- Returns:
- set of agent type identifiers.
-
getAgentTypePairs
public Map<Integer,AgentTypeKey> getAgentTypePairs()
- Specified by:
getAgentTypePairsin interfaceAgentTypeStorage
-
getAgentTypeIdsByPool
@NotNull public Collection<Integer> getAgentTypeIdsByPool(int agentPoolId)
- Specified by:
getAgentTypeIdsByPoolin interfaceAgentTypeStorage
-
getPolicy
@NotNull public AgentTypePolicy getPolicy(int agentTypeId)
Loads the policy from database (if not loaded yet) and returns it.- Specified by:
getPolicyin 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:
setPolicyKindin 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:
includeBuildTypesToAllowedin 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:
excludeBuildTypesFromAllowedin 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:
isAllowedToRunin 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:
removeBuildTypeFromAllListsin interfaceAgentTypeStorage- Parameters:
buildTypeId- build configuration identifier.- Since:
- 7.0
-
copyAgentTypeRestrictions
public void copyAgentTypeRestrictions(@NotNull String originalBuildTypeId, @NotNull String newBuildTypeId)- Specified by:
copyAgentTypeRestrictionsin interfaceAgentTypeStorage
-
invalidateCacheForAllAgentTypes
public void invalidateCacheForAllAgentTypes()
- Specified by:
invalidateCacheForAllAgentTypesin interfaceAgentTypeStorage
-
invalidateCacheForAgentTypesFromPools
public void invalidateCacheForAgentTypesFromPools(@NotNull Set<Integer> agentPoolIds, @NotNull CacheClearPolicy policy)- Specified by:
invalidateCacheForAgentTypesFromPoolsin interfaceAgentTypeStorage
-
invalidateCacheForOneAgentType
public void invalidateCacheForOneAgentType(int agentTypeId, @NotNull CacheClearPolicy policy)- Specified by:
invalidateCacheForOneAgentTypein interfaceAgentTypeStorage
-
updateAgentTypeFromDB
public void updateAgentTypeFromDB(int agentTypeId)
- Specified by:
updateAgentTypeFromDBin interfaceAgentTypeStorage
-
deleteAgentType
public void deleteAgentType(int agentTypeId)
- Specified by:
deleteAgentTypein interfaceAgentTypeStorage
-
setRunConfigurationPolicy
public void setRunConfigurationPolicy(int agentTypeId, @NotNull BuildAgentManager.RunConfigurationPolicy policy)- Specified by:
setRunConfigurationPolicyin interfaceAgentTypeManager
-
getRunConfigurationPolicy
@NotNull public BuildAgentManager.RunConfigurationPolicy getRunConfigurationPolicy(int agentTypeId)
- Specified by:
getRunConfigurationPolicyin interfaceAgentTypeManager
-
includeRunConfigurationsToAllowed
public void includeRunConfigurationsToAllowed(int agentTypeId, @NotNull String[] buildTypeIds)- Specified by:
includeRunConfigurationsToAllowedin interfaceAgentTypeManager
-
excludeRunConfigurationsFromAllowed
public void excludeRunConfigurationsFromAllowed(int agentTypeId, @NotNull String[] buildTypeIds)- Specified by:
excludeRunConfigurationsFromAllowedin interfaceAgentTypeManager
-
isCanRunConfiguration
public boolean isCanRunConfiguration(int agentTypeId, @NotNull BuildTypeDescriptor buildType)- Specified by:
isCanRunConfigurationin interfaceAgentTypeManager
-
getCanRunConfigurations
@NotNull public Set<String> getCanRunConfigurations(int agentTypeId)
- Specified by:
getCanRunConfigurationsin interfaceAgentTypeManager
-
getNumberOfCompatibleConfigurations
public int getNumberOfCompatibleConfigurations(@NotNull SAgentType agentType)- Specified by:
getNumberOfCompatibleConfigurationsin interfaceAgentTypeManager
-
getNumberOfIncompatibleConfigurations
public int getNumberOfIncompatibleConfigurations(@NotNull SAgentType agentType)- Specified by:
getNumberOfIncompatibleConfigurationsin interfaceAgentTypeManager
-
getAgentTypeCompatibilities
@NotNull public List<AgentCompatibility> getAgentTypeCompatibilities(@NotNull SAgentType agentType)
- Specified by:
getAgentTypeCompatibilitiesin interfaceAgentTypeManager
-
copyAgentTypeRestrictions
public void copyAgentTypeRestrictions(@NotNull BuildTypeDescriptor originalBuildType, @NotNull BuildTypeDescriptor newBuildType)- Specified by:
copyAgentTypeRestrictionsin interfaceAgentTypeManager
-
migrateAgentTypeKey
public void migrateAgentTypeKey(@NotNull AgentTypeKey currentKey, @NotNull AgentTypeKey newKey)- Specified by:
migrateAgentTypeKeyin interfaceAgentTypeManager
-
-