Class ClusterAwareJob
- All Implemented Interfaces:
org.quartz.Job
- Direct Known Subclasses:
AgentsHeartBeatCheckerJob,BranchDetectionJob,BranchExpiryJob,BuildMonitorJobScheduler,BuildQueueMonitorJobScheduler,CrowdDeletedEntityCleanupJob,DeletionServiceJob,ElasticInstanceScheduleJob,EphemeralAgentCleanupJob,ExpirySchedulerImpl.ExpiryJob,ManagedAgentContainersMonitorJob,OfflineElasticAgentsRemovalJob,OfflineRemoteAgentsRemovalJob,OrphanedBuildMonitorJob,OrphanedBuildResultRemovalJob,PerformanceStatsDispatchJob,PlanVcsRevisionHistoryCleanupScheduler.PlanVcsHistoryCleanupJob,PullRequestDetectionJob,RememberMeTokenExpiryJob,RemoveOrphanedSpecsStateJob,RemoveOrphanedTestCaseJob,RemovePullRequestsJob,RepositoryStoredSpecsPollingJob,ScheduledBackupJob,StaleAvatarsRemovalJob,SystemInfoJob,TagDetectionJob,VariableContextUpgradeJob
Any job inheriting from this class should implement the executeBody and executionMode methods to define its specific logic and execution requirements. This class was created to centralize the handling of clustered job execution by leveraging cluster locks and node primary status. There are three modes: 1. LOCAL - schedules the job on every node in the cluster 2. PRIMARY - schedules the job on the primary node only, regardless of other nodes in the cluster 3. CLUSTERED - ensures that only one node executes the job at any given time and prevents concurrent execution across nodes, while also allowing seamless takeover when secondary nodes join the cluster.
-
Field Summary
Fields -
Constructor Summary
ConstructorsModifierConstructorDescriptionprotectedClusterAwareJob(BambooClusterNodeHeartbeatService bambooClusterNodeHeartbeatService, ClusterAwareLifecycleManager clusterAwareLifecycleManager, BambooClusterLockService bambooClusterLockService) -
Method Summary
Modifier and TypeMethodDescriptionfinal voidexecute(org.quartz.JobExecutionContext jobExecutionContext) protected abstract voidexecuteBody(org.quartz.JobExecutionContext jobExecutionContext) This is the job real work to be performed.protected abstract JobExecutionModeDetermines the execution mode for this job.extractDurationBetweenExecutionsSeconds(@NotNull String cronExpressionStr) protected longgetDurationBetweenExecutionsInSeconds(org.quartz.JobExecutionContext jobExecutionContext, String jobIdentifier)
-
Field Details
-
SCHEDULED_DURATION_BETWEEN_EXECUTIONS_SECONDS_CONST
- See Also:
-
SCHEDULED_DURATION_BETWEEN_EXECUTIONS_CRON_CONST
- See Also:
-
-
Constructor Details
-
ClusterAwareJob
public ClusterAwareJob() -
ClusterAwareJob
@VisibleForTesting protected ClusterAwareJob(BambooClusterNodeHeartbeatService bambooClusterNodeHeartbeatService, ClusterAwareLifecycleManager clusterAwareLifecycleManager, BambooClusterLockService bambooClusterLockService)
-
-
Method Details
-
execute
public final void execute(org.quartz.JobExecutionContext jobExecutionContext) throws org.quartz.JobExecutionException - Specified by:
executein interfaceorg.quartz.Job- Throws:
org.quartz.JobExecutionException
-
getDurationBetweenExecutionsInSeconds
@VisibleForTesting protected long getDurationBetweenExecutionsInSeconds(org.quartz.JobExecutionContext jobExecutionContext, String jobIdentifier) -
extractDurationBetweenExecutionsSeconds
-
executeBody
protected abstract void executeBody(org.quartz.JobExecutionContext jobExecutionContext) throws org.quartz.JobExecutionException This is the job real work to be performed. Every job that is based on this parent cluster aware job needs to implement this method and place here stuff that would be normally put in #execute(JobExecutionContext)- Throws:
org.quartz.JobExecutionException
-
executionMode
Determines the execution mode for this job.The execution mode defines how this job should execute in a clustered environment. Implementations should return the appropriate mode based on their execution requirements (e.g., LOCAL, PRIMARY, or CLUSTERED).
-