Class AbstractQueueOfExecutables
java.lang.Object
com.atlassian.bamboo.v2.build.queue.queues.AbstractQueueOfExecutables
- All Implemented Interfaces:
QueueOfExecutables
- Direct Known Subclasses:
OffloadingQueueOfExecutables,SimpleQueueOfExecutables
-
Nested Class Summary
Nested classes/interfaces inherited from interface com.atlassian.bamboo.v2.build.queue.QueueOfExecutables
QueueOfExecutables.EnqueueResult, QueueOfExecutables.ExecutableData -
Constructor Summary
ConstructorsModifierConstructorDescriptionprotectedAbstractQueueOfExecutables(ExecutorCalculator executorCalculator, CommonContextMap map, com.atlassian.event.api.EventPublisher eventPublisher, EphemeralAgentsService ephemeralAgentsService) -
Method Summary
Modifier and TypeMethodDescription@NotNull QueueOfExecutables.EnqueueResultenqueueAndRequestDedicatedAgentIfApplicable(@NotNull CommonContext context, @Nullable MinimalRequirementSet requirements) Adds a new executable to store.@NotNull com.google.common.collect.ImmutableList<QueueOfExecutables.ExecutableData>executablesForAgent(long agentId) Returns executables available for an agent.@NotNull com.google.common.collect.ImmutableList<QueueOfExecutables.ExecutableData>executablesForAgent(long agentId, Function<Long, Collection<ResultKey>> source) @Nullable CommonContextRetrieves an executable with given key from storage.getExecutorsForExecutable(@NotNull ResultKey resultKey) Returns the executors currently considered to be eligible for building resultKey.@Nullable Collection<ElasticImageConfiguration>getImagesForExecutable(@NotNull ResultKey resultKey) Returns the images currently considered to be eligible for building resultKey.@Nullable Collection<ElasticImageConfiguration>getNonDedicatedImagesForExecutable(@NotNull ResultKey resultKey) Returns the images that can execute the given executable.@Nullable Collection<EphemeralAgentTemplate>getTemplatesForExecutable(@NotNull ResultKey resultKey) Returns the ephemeral agents templates currently considered to be eligible for building resultKey.@Nullable CommonContextCalled when a given executable is en route to agent.voidlaunchDedicatedAgentsForTemplate(@NotNull EphemeralAgentTemplate template) Launches dedicated agents for the given template and executables present in the queue at the moment of this method call.@NotNull com.google.common.collect.ImmutableList<QueueOfExecutables.ExecutableData>nonDedicatedExecutablesForAgent(long agentId) Returns immutable list of the non-dedicated executables available for an agent.voidrecalculateExecutables(BuildAgent agent) Updates all agent-executable mappings for a given agent.voidRecalculates executors for all executables - until then, any information about executor-executable mapping should be considered to be invalid.voidrecalculateExecutors(@NotNull Set<Key> keys) Recalculates executors for a given plan - until then, any information about executor-executable mapping for this plan should be considered to be invalid.@Nullable CommonContextCalled when an executable should be removed from the queue.voidremoveDedicationTimestamp(@NotNull ResultKey resultKey) Remove the dedication timestamp for the given result key if the one exists.intsize()Returns the amount of executables in queue (not counting executables in flight)
-
Constructor Details
-
AbstractQueueOfExecutables
protected AbstractQueueOfExecutables(ExecutorCalculator executorCalculator, CommonContextMap map, com.atlassian.event.api.EventPublisher eventPublisher, EphemeralAgentsService ephemeralAgentsService)
-
-
Method Details
-
inflight
Description copied from interface:QueueOfExecutablesCalled when a given executable is en route to agent. May be implemented as a simple remove(). Executables in flight should be treated as removed, but may be put back into a queue if an agent fails to acknowledge that it received the executable.- Specified by:
inflightin interfaceQueueOfExecutables- Returns:
- the removed context
-
remove
Description copied from interface:QueueOfExecutablesCalled when an executable should be removed from the queue. will not be called concurrently- Specified by:
removein interfaceQueueOfExecutables- Returns:
- the removed context
-
enqueueAndRequestDedicatedAgentIfApplicable
@NotNull public @NotNull QueueOfExecutables.EnqueueResult enqueueAndRequestDedicatedAgentIfApplicable(@NotNull @NotNull CommonContext context, @Nullable @Nullable MinimalRequirementSet requirements) Description copied from interface:QueueOfExecutablesAdds a new executable to store. Will not be called concurrently.- Specified by:
enqueueAndRequestDedicatedAgentIfApplicablein interfaceQueueOfExecutables- Parameters:
context- context to enqueuerequirements- requirements needed to execute the context, may be null- Returns:
- FAILED if requirements could not be retrieved for a build and were not provided in the call (assumption: the reason is that the build got deleted) ENQUEUED_COMMON if successfully enqueued ENQUEUED_DEDICATED if successfully enqueued and requested a dedicated agent for the execution
-
executablesForAgent
@NotNull public @NotNull com.google.common.collect.ImmutableList<QueueOfExecutables.ExecutableData> executablesForAgent(long agentId) Description copied from interface:QueueOfExecutablesReturns executables available for an agent.- Specified by:
executablesForAgentin interfaceQueueOfExecutables
-
nonDedicatedExecutablesForAgent
@NotNull public @NotNull com.google.common.collect.ImmutableList<QueueOfExecutables.ExecutableData> nonDedicatedExecutablesForAgent(long agentId) Description copied from interface:QueueOfExecutablesReturns immutable list of the non-dedicated executables available for an agent.- Specified by:
nonDedicatedExecutablesForAgentin interfaceQueueOfExecutables- Parameters:
agentId- id of the agent- Returns:
- list of executable data
-
executablesForAgent
@NotNull public @NotNull com.google.common.collect.ImmutableList<QueueOfExecutables.ExecutableData> executablesForAgent(long agentId, Function<Long, Collection<ResultKey>> source) -
recalculateExecutables
Description copied from interface:QueueOfExecutablesUpdates all agent-executable mappings for a given agent.- Specified by:
recalculateExecutablesin interfaceQueueOfExecutables
-
recalculateExecutors
public void recalculateExecutors()Description copied from interface:QueueOfExecutablesRecalculates executors for all executables - until then, any information about executor-executable mapping should be considered to be invalid. The dedicated agents won't be launched as a part of this process.- Specified by:
recalculateExecutorsin interfaceQueueOfExecutables
-
size
public int size()Description copied from interface:QueueOfExecutablesReturns the amount of executables in queue (not counting executables in flight)- Specified by:
sizein interfaceQueueOfExecutables
-
getImagesForExecutable
@Nullable public @Nullable Collection<ElasticImageConfiguration> getImagesForExecutable(@NotNull @NotNull ResultKey resultKey) Description copied from interface:QueueOfExecutablesReturns the images currently considered to be eligible for building resultKey.- Specified by:
getImagesForExecutablein interfaceQueueOfExecutables
-
getNonDedicatedImagesForExecutable
@Nullable public @Nullable Collection<ElasticImageConfiguration> getNonDedicatedImagesForExecutable(@NotNull @NotNull ResultKey resultKey) Description copied from interface:QueueOfExecutablesReturns the images that can execute the given executable. If the executable is not found, null is returned. If the executable is dedicated at the moment of check, the empty list will be returned.- Specified by:
getNonDedicatedImagesForExecutablein interfaceQueueOfExecutables- Parameters:
resultKey- executable- Returns:
- list of elastic image configurations
-
getTemplatesForExecutable
@Nullable public @Nullable Collection<EphemeralAgentTemplate> getTemplatesForExecutable(@NotNull @NotNull ResultKey resultKey) Description copied from interface:QueueOfExecutablesReturns the ephemeral agents templates currently considered to be eligible for building resultKey. If the resultKey is not found the null is returned.- Specified by:
getTemplatesForExecutablein interfaceQueueOfExecutables- Parameters:
resultKey- result key to look for- Returns:
- ephemeral agents templates.
-
getExecutorsForExecutable
@Nullable public @Nullable Set<Long> getExecutorsForExecutable(@NotNull @NotNull ResultKey resultKey) Description copied from interface:QueueOfExecutablesReturns the executors currently considered to be eligible for building resultKey.- Specified by:
getExecutorsForExecutablein interfaceQueueOfExecutables
-
removeDedicationTimestamp
Description copied from interface:QueueOfExecutablesRemove the dedication timestamp for the given result key if the one exists. The dedication timestamp works as a due-to-date, to which the build queue holds the related executable for a dedicated agent. After the date pass, every executor can grab the executable. Removing the dedication timestamp means that the executable is no longer dedicated.- Specified by:
removeDedicationTimestampin interfaceQueueOfExecutables- Parameters:
resultKey- of the related executable
-
recalculateExecutors
Description copied from interface:QueueOfExecutablesRecalculates executors for a given plan - until then, any information about executor-executable mapping for this plan should be considered to be invalid.- Specified by:
recalculateExecutorsin interfaceQueueOfExecutables- Parameters:
keys- the keys to invalidate
-
get
Description copied from interface:QueueOfExecutablesRetrieves an executable with given key from storage.- Specified by:
getin interfaceQueueOfExecutables
-
launchDedicatedAgentsForTemplate
Description copied from interface:QueueOfExecutablesLaunches dedicated agents for the given template and executables present in the queue at the moment of this method call. The dedicated agent will be launched if the corresponding executable is not already waiting for any dedicated agent.- Specified by:
launchDedicatedAgentsForTemplatein interfaceQueueOfExecutables- Parameters:
template- the template to launch dedicated agents for
-