Class AbstractUpgradeTaskWithConcurrentExecution

java.lang.Object
com.atlassian.bamboo.upgrade.AbstractUpgradeTask
com.atlassian.bamboo.upgrade.AbstractUpgradeTaskWithConcurrentExecution
All Implemented Interfaces:
UpgradeTask
Direct Known Subclasses:
AbstractGrantNewPermissionsUpgradeTask, UpgradeTask100205AddCreateReleaseToProjectBasedOnEnvironments

public abstract class AbstractUpgradeTaskWithConcurrentExecution extends AbstractUpgradeTask
AbstractUpgradeTaskWithConcurrentExecution is an abstract class that extends AbstractUpgradeTask and provides functionality for executing upgrade tasks concurrently.

This class manages concurrency using a ForkJoinPool and allows tasks to be scheduled and executed in parallel. It also provides mechanisms to track the progress of the tasks and log the progress at regular intervals.

Key features: - Manages concurrency level based on system properties and available processors. - Uses ForkJoinPool to execute tasks concurrently. - Tracks the progress of tasks using an AtomicInteger counter. There can be different task types tracked separately. - Logs progress information when a certain number of tasks have been completed.

Usage: - Extend this class and implement the specific upgrade logic in the subclass. - Use the doUpgradeWithExecutorContext method to execute the upgrade tasks within a concurrent context. - Use the schedule method to schedule individual tasks for execution. - Use the notifyCounter method to update the progress counter and log progress information.

  • Field Details

    • pageSize

      protected final int pageSize
  • Constructor Details

    • AbstractUpgradeTaskWithConcurrentExecution

      public AbstractUpgradeTaskWithConcurrentExecution(@NotNull @NotNull String buildNumber, @NotNull @NotNull String shortDescription, int pageSize)
    • AbstractUpgradeTaskWithConcurrentExecution

      public AbstractUpgradeTaskWithConcurrentExecution(@NotNull @NotNull String shortDescription, int pageSize)
  • Method Details

    • doUpgradeWithExecutorContext

      public void doUpgradeWithExecutorContext(@NotNull @NotNull Runnable upgrade) throws Exception
      Throws:
      Exception
    • startTrackingProgress

      protected void startTrackingProgress(String collectionName, long collectionSize)
    • schedule

      protected void schedule(@NotNull @NotNull Runnable task)
      All #schedule calls need to be called within the doUpgradeWithExecutorContext#upgrade context! Most of the tasks have to fetch the data from the database on their own to avoid hibernate session-related issues, so please avoid using entity objects fetched before calling the #schedule method.
    • notifyProgress

      protected void notifyProgress(String collectionName)