Class MockBuildAgentManager
- java.lang.Object
-
- jetbrains.buildServer.serverSide.agentPools.MockBuildAgentManager
-
- All Implemented Interfaces:
BuildAgentManager
public class MockBuildAgentManager extends Object implements BuildAgentManager
- Author:
- Maxim.Manuylov Date: 11/15/11
-
-
Nested Class Summary
-
Nested classes/interfaces inherited from interface jetbrains.buildServer.serverSide.BuildAgentManager
BuildAgentManager.RunConfigurationPolicy
-
-
Constructor Summary
Constructors Constructor Description MockBuildAgentManager()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description <T extends SBuildAgent>
TfindAgentById(int agentId, boolean searchUnregistered)
Searches for an agent with specified id among registered and unregistered agents.<T extends SBuildAgent>
TfindAgentByName(String agentName, boolean searchUnregistered)
Searches for an agent with specified name among registered and unregistered agents.<T extends SBuildAgent>
List<AgentCompatibility>getAgentCompatibilities(T agent)
Returns build configuration compatibility information for the specified agent<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 agentint
getNumberOfRegisteredAgents()
Returns number of registered and authorized agents<T extends SBuildAgent>
List<T>getRegisteredAgents()
Returns all registered authorized agents.<T extends SBuildAgent>
List<T>getRegisteredAgents(boolean includeUnauthorized)
Returns all registered agents.<T extends SBuildAgent>
BuildAgentManager.RunConfigurationPolicygetRunConfigurationPolicy(T agent)
Returns run configuration policy for an agent.<T extends SBuildAgent>
List<T>getUnregisteredAgents()
Returns list of all currently unregistered and authorized agents, i.e.<T extends SBuildAgent>
List<T>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.void
removeAgent(SBuildAgent agent, SUser user)
Removes specified agent and cleans up this agent state from the database.<T extends SBuildAgent>
voidsetCanRunConfiguration(T agent, String buildTypeId, boolean canRun)
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.<T extends SBuildAgent>
voidsetRunConfigurationPolicy(T agent, BuildAgentManager.RunConfigurationPolicy policy)
Sets build configuration run policy for an agent.
-
-
-
Method Detail
-
getRegisteredAgents
public <T extends SBuildAgent> List<T> getRegisteredAgents()
Description copied from interface:BuildAgentManager
Returns all registered authorized agents. Registered means connected at the moment of call.- Specified by:
getRegisteredAgents
in interfaceBuildAgentManager
- Returns:
- see above
-
getRegisteredAgents
public <T extends SBuildAgent> List<T> 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
- Parameters:
includeUnauthorized
- if true, unauthorized agents, i.e. agents which cannot run builds until authorized by admin- Returns:
- see above
-
getUnregisteredAgents
public <T extends SBuildAgent> List<T> 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
- Returns:
- list of all currently unregistered agents
-
getUnregisteredAgents
public <T extends SBuildAgent> List<T> 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
- Parameters:
includeUnauthorized
- whether to include or exclude unauthorized agents- Returns:
- list of all currently unregistered agents
-
findAgentById
public <T extends SBuildAgent> T 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
- Parameters:
agentId
- id of the agent to searchsearchUnregistered
- true if unregistered agents should be searched too- Returns:
- found agent or null
-
findAgentByName
public <T extends SBuildAgent> T findAgentByName(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
- Parameters:
agentName
- name of the agent to searchsearchUnregistered
- true if unregistered agents should be searched too- Returns:
- found agent or null
-
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
-
setRunConfigurationPolicy
public <T extends SBuildAgent> void setRunConfigurationPolicy(T agent, 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
-
-
getRunConfigurationPolicy
public <T extends SBuildAgent> BuildAgentManager.RunConfigurationPolicy getRunConfigurationPolicy(T 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
public <T extends SBuildAgent> void setCanRunConfiguration(T agent, String buildTypeId, boolean canRun)
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 <T extends SBuildAgent> boolean isCanRunConfiguration(T 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 <T extends SBuildAgent> Set<String> getCanRunConfigurations(T 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
-
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
-
-