Class AbstractUpgradeTaskWithConcurrentExecution
- All Implemented Interfaces:
UpgradeTask
- Direct Known Subclasses:
AbstractGrantNewPermissionsUpgradeTask
,UpgradeTask100205AddCreateReleaseToProjectBasedOnEnvironments
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 Summary
Fields inherited from class com.atlassian.bamboo.upgrade.AbstractUpgradeTask
errors, hibernateConfig, shortDescription
-
Constructor Summary
ConstructorDescriptionAbstractUpgradeTaskWithConcurrentExecution
(@NotNull String shortDescription, int pageSize) AbstractUpgradeTaskWithConcurrentExecution
(@NotNull String buildNumber, @NotNull String shortDescription, int pageSize) -
Method Summary
Modifier and TypeMethodDescriptionvoid
doUpgradeWithExecutorContext
(@NotNull Runnable upgrade) protected void
notifyProgress
(String collectionName) protected void
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.protected void
startTrackingProgress
(String collectionName, long collectionSize) Methods inherited from class com.atlassian.bamboo.upgrade.AbstractUpgradeTask
getBuildNumber, getErrors, getShortDescription
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
Methods inherited from interface com.atlassian.bamboo.upgrade.UpgradeTask
doUpgrade
-
Field Details
-
pageSize
protected final int pageSize
-
-
Constructor Details
-
AbstractUpgradeTaskWithConcurrentExecution
-
AbstractUpgradeTaskWithConcurrentExecution
public AbstractUpgradeTaskWithConcurrentExecution(@NotNull @NotNull String shortDescription, int pageSize)
-
-
Method Details
-
doUpgradeWithExecutorContext
- Throws:
Exception
-
startTrackingProgress
-
schedule
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
-