Package com.atlassian.bamboo.plan
Class ExecutableAgentsHelperImpl
- java.lang.Object
-
- com.atlassian.bamboo.plan.ExecutableAgentsHelperImpl
-
- All Implemented Interfaces:
ExecutableAgentsHelper
public class ExecutableAgentsHelperImpl extends Object implements ExecutableAgentsHelper
-
-
Nested Class Summary
-
Nested classes/interfaces inherited from interface com.atlassian.bamboo.plan.ExecutableAgentsHelper
ExecutableAgentsHelper.ExecutableQuery, ExecutableAgentsHelper.ExecutorQuery
-
-
Constructor Summary
Constructors Constructor Description ExecutableAgentsHelperImpl(CachedPlanManager cachedPlanManager, ExecutionStatusProvider executionStatusProvider, com.atlassian.plugin.PluginAccessor pluginAccessor, AgentAssignmentService agentAssignmentService, CapabilityRequirementsMatcher capabilityRequirementsMatcher, CapabilitySetManager capabilitySetManager, ElasticInstanceManager elasticInstanceManager, ElasticImageConfigurationAccessor elasticImageConfigurationAccessor, EphemeralAgentsService ephemeralAgentsService, EnvironmentCustomConfigService environmentCustomConfigService)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description boolean
canExecute(@NotNull ExecutableAgentsHelper.ExecutorQuery executorQuery, @NotNull EphemeralAgentTemplate ephemeralAgentTemplate)
Checks if the given template is applicable for the given query - whether the template meets the query requirements.boolean
canExecute(@NotNull BuildAgent buildAgent, @NotNull CommonContext context, @NotNull ImmutableRequirementSet requirements)
Returns true or false depending on whether the agent can execute the given context, taking into account requirement set and other global settings such as agent assignments.@NotNull Collection<BuildAgent>
getExecutableAgents(@NotNull ExecutableAgentsHelper.ExecutorQuery executorQuery)
ExecutableAgentsMatrix
getExecutableAgentsMatrix(@NotNull ExecutableAgentsHelper.ExecutorQuery executorQuery)
@NotNull Collection<ImmutableBuildable>
getExecutableBuildables(@NotNull ExecutableAgentsHelper.ExecutableQuery executableQuery)
Collection of buildables for which this agent can execute.@NotNull Collection<ImmutableBuildable>
getExecutableBuildables(ExecutableAgentsHelper.ExecutableQuery executableQuery, Predicate<? super ImmutableBuildable> filter)
Collection of buildables for which this agent can execute.@NotNull Collection<Environment>
getExecutableEnvironments(@NotNull ExecutableAgentsHelper.ExecutableQuery executableQuery)
@NotNull Collection<EphemeralAgentTemplate>
getExecutableEphemeralAgentTemplates(@NotNull ExecutableAgentsHelper.ExecutorQuery executorQuery)
Calculates the list of ephemeral agents templates that are capable of running an agent that can build a Buildable plan.Collection<ElasticImageConfiguration>
getExecutableImages(@NotNull ExecutableAgentsHelper.ExecutorQuery executorQuery)
Calculates the list of elastic images that are capable of running an agent that can build a Buildable plan.boolean
isAgentEligibleForReceivingJobs(long agentId)
This method checks if agent is eligible to receive new jobs.boolean
planHasExecutableAgents(@NotNull PlanKey planKey, boolean includeDisabled)
Checks if a Buildable can be built on any active agent.boolean
planHasExecutableAgents(@NotNull PlanResultKey planResultKey)
Checks if a Job can be built on any active agent.void
resendStopAgentMessageIfRequired(long agentId)
If agent is online andBuildAgent.isRequestedToBeStopped()
is true, the system will re-request the agent stop.
-
-
-
Constructor Detail
-
ExecutableAgentsHelperImpl
public ExecutableAgentsHelperImpl(CachedPlanManager cachedPlanManager, ExecutionStatusProvider executionStatusProvider, com.atlassian.plugin.PluginAccessor pluginAccessor, AgentAssignmentService agentAssignmentService, CapabilityRequirementsMatcher capabilityRequirementsMatcher, CapabilitySetManager capabilitySetManager, ElasticInstanceManager elasticInstanceManager, ElasticImageConfigurationAccessor elasticImageConfigurationAccessor, EphemeralAgentsService ephemeralAgentsService, EnvironmentCustomConfigService environmentCustomConfigService)
-
-
Method Detail
-
getExecutableAgents
@NotNull @Transactional public @NotNull Collection<BuildAgent> getExecutableAgents(@NotNull @NotNull ExecutableAgentsHelper.ExecutorQuery executorQuery)
- Specified by:
getExecutableAgents
in interfaceExecutableAgentsHelper
-
canExecute
public boolean canExecute(@NotNull @NotNull BuildAgent buildAgent, @NotNull @NotNull CommonContext context, @NotNull @NotNull ImmutableRequirementSet requirements)
Description copied from interface:ExecutableAgentsHelper
Returns true or false depending on whether the agent can execute the given context, taking into account requirement set and other global settings such as agent assignments.- Specified by:
canExecute
in interfaceExecutableAgentsHelper
-
getExecutableAgentsMatrix
public ExecutableAgentsMatrix getExecutableAgentsMatrix(@NotNull @NotNull ExecutableAgentsHelper.ExecutorQuery executorQuery)
- Specified by:
getExecutableAgentsMatrix
in interfaceExecutableAgentsHelper
-
isAgentEligibleForReceivingJobs
public boolean isAgentEligibleForReceivingJobs(long agentId)
Description copied from interface:ExecutableAgentsHelper
This method checks if agent is eligible to receive new jobs.- Specified by:
isAgentEligibleForReceivingJobs
in interfaceExecutableAgentsHelper
- Returns:
- true iff agent it's ok to receive jobs (i.e. we haven't requested it's shutdown)
-
resendStopAgentMessageIfRequired
public void resendStopAgentMessageIfRequired(long agentId)
Description copied from interface:ExecutableAgentsHelper
If agent is online andBuildAgent.isRequestedToBeStopped()
is true, the system will re-request the agent stop.- Specified by:
resendStopAgentMessageIfRequired
in interfaceExecutableAgentsHelper
-
getExecutableImages
public Collection<ElasticImageConfiguration> getExecutableImages(@NotNull @NotNull ExecutableAgentsHelper.ExecutorQuery executorQuery)
Description copied from interface:ExecutableAgentsHelper
Calculates the list of elastic images that are capable of running an agent that can build a Buildable plan.- Specified by:
getExecutableImages
in interfaceExecutableAgentsHelper
-
getExecutableEphemeralAgentTemplates
@NotNull public @NotNull Collection<EphemeralAgentTemplate> getExecutableEphemeralAgentTemplates(@NotNull @NotNull ExecutableAgentsHelper.ExecutorQuery executorQuery)
Description copied from interface:ExecutableAgentsHelper
Calculates the list of ephemeral agents templates that are capable of running an agent that can build a Buildable plan.- Specified by:
getExecutableEphemeralAgentTemplates
in interfaceExecutableAgentsHelper
- Returns:
- collection of ephemeral agent templates that match the query
-
canExecute
public boolean canExecute(@NotNull @NotNull ExecutableAgentsHelper.ExecutorQuery executorQuery, @NotNull @NotNull EphemeralAgentTemplate ephemeralAgentTemplate)
Description copied from interface:ExecutableAgentsHelper
Checks if the given template is applicable for the given query - whether the template meets the query requirements.- Specified by:
canExecute
in interfaceExecutableAgentsHelper
- Parameters:
executorQuery
- query to checkephemeralAgentTemplate
- template to check- Returns:
- true if the template is applicable for the query, false otherwise
-
planHasExecutableAgents
@Transactional public boolean planHasExecutableAgents(@NotNull @NotNull PlanKey planKey, boolean includeDisabled)
Checks if a Buildable can be built on any active agent. This implementation utilises information already available in ExecutionStatus if it exists.- Specified by:
planHasExecutableAgents
in interfaceExecutableAgentsHelper
- Parameters:
planKey
-includeDisabled
- indicate whether disabled agents should be included in checking- Returns:
-
planHasExecutableAgents
@Transactional public boolean planHasExecutableAgents(@NotNull @NotNull PlanResultKey planResultKey)
Checks if a Job can be built on any active agent. This implementation utilises information already available in ExecutionStatus if it exists.- Specified by:
planHasExecutableAgents
in interfaceExecutableAgentsHelper
- Parameters:
planResultKey
-- Returns:
-
getExecutableBuildables
@NotNull public @NotNull Collection<ImmutableBuildable> getExecutableBuildables(@NotNull @NotNull ExecutableAgentsHelper.ExecutableQuery executableQuery)
Description copied from interface:ExecutableAgentsHelper
Collection of buildables for which this agent can execute. Checks capabilities and agent assignments- Specified by:
getExecutableBuildables
in interfaceExecutableAgentsHelper
-
getExecutableBuildables
@NotNull public @NotNull Collection<ImmutableBuildable> getExecutableBuildables(ExecutableAgentsHelper.ExecutableQuery executableQuery, Predicate<? super ImmutableBuildable> filter)
Description copied from interface:ExecutableAgentsHelper
Collection of buildables for which this agent can execute. Checks capabilities and agent assignments- Specified by:
getExecutableBuildables
in interfaceExecutableAgentsHelper
-
getExecutableEnvironments
@NotNull public @NotNull Collection<Environment> getExecutableEnvironments(@NotNull @NotNull ExecutableAgentsHelper.ExecutableQuery executableQuery)
- Specified by:
getExecutableEnvironments
in interfaceExecutableAgentsHelper
- Returns:
- collection of environments that can be executed using given set of capabilities/assignments
-
-