-
Notifications
You must be signed in to change notification settings - Fork 467
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Feat (Core): Implement abandoned job detection and recovery (#30710)
This pull request includes some refactoring and improvements to the job queue management system. The changes primarily focus on removing the job polling mechanism, enhancing job validation, and adding an abandoned job detector. Below are the most important changes: ### Removal of Job Polling Mechanism: * [`dotCMS/src/main/java/com/dotcms/jobs/business/api/JobQueueConfig.java`](diffhunk://#diff-4c8b70e959cc00105adc8298bf8a977a3c18a6ceb5d55110bda6d023159a5e5aL13-L24): Removed the `pollJobUpdatesIntervalMilliseconds` parameter and its associated methods. [[1]](diffhunk://#diff-4c8b70e959cc00105adc8298bf8a977a3c18a6ceb5d55110bda6d023159a5e5aL13-L24) [[2]](diffhunk://#diff-4c8b70e959cc00105adc8298bf8a977a3c18a6ceb5d55110bda6d023159a5e5aL36-L44) * [`dotCMS/src/main/java/com/dotcms/jobs/business/api/JobQueueConfigProducer.java`](diffhunk://#diff-1367d122323650421a37296f7a223becc19bb3d6c1d2a965dd52ae6bbd2f5e74L19-L23): Removed the default polling interval configuration and its usage. [[1]](diffhunk://#diff-1367d122323650421a37296f7a223becc19bb3d6c1d2a965dd52ae6bbd2f5e74L19-L23) [[2]](diffhunk://#diff-1367d122323650421a37296f7a223becc19bb3d6c1d2a965dd52ae6bbd2f5e74L33-R28) * [`dotCMS/src/main/java/com/dotcms/jobs/business/api/JobQueueManagerAPIImpl.java`](diffhunk://#diff-c092f8af2f800c0ca84f2c2f4aed0af60d0ed488e20fa32992967e154064f561L121-R122): Removed the polling scheduler and related methods. [[1]](diffhunk://#diff-c092f8af2f800c0ca84f2c2f4aed0af60d0ed488e20fa32992967e154064f561L121-R122) [[2]](diffhunk://#diff-c092f8af2f800c0ca84f2c2f4aed0af60d0ed488e20fa32992967e154064f561L477-L498) ### Addition of Abandoned Job Detector: * [`dotCMS/src/main/java/com/dotcms/jobs/business/api/JobQueueManagerAPIImpl.java`](diffhunk://#diff-c092f8af2f800c0ca84f2c2f4aed0af60d0ed488e20fa32992967e154064f561R112): Added `AbandonedJobDetector` as a dependency and integrated it into the job queue lifecycle methods. [[1]](diffhunk://#diff-c092f8af2f800c0ca84f2c2f4aed0af60d0ed488e20fa32992967e154064f561R112) [[2]](diffhunk://#diff-c092f8af2f800c0ca84f2c2f4aed0af60d0ed488e20fa32992967e154064f561L142-R151) [[3]](diffhunk://#diff-c092f8af2f800c0ca84f2c2f4aed0af60d0ed488e20fa32992967e154064f561L170-L179) [[4]](diffhunk://#diff-c092f8af2f800c0ca84f2c2f4aed0af60d0ed488e20fa32992967e154064f561L221-R209) [[5]](diffhunk://#diff-c092f8af2f800c0ca84f2c2f4aed0af60d0ed488e20fa32992967e154064f561R230-L243) ### Enhancements to Job Validation: * [`dotCMS/src/main/java/com/dotcms/jobs/business/api/JobQueueManagerAPIImpl.java`](diffhunk://#diff-c092f8af2f800c0ca84f2c2f4aed0af60d0ed488e20fa32992967e154064f561R283-R303): Added validation for job parameters if the processor implements `Validator` and handled validation exceptions. ### Event Handling Improvements: * [`dotCMS/src/main/java/com/dotcms/jobs/business/api/JobQueueManagerAPIImpl.java`](diffhunk://#diff-c092f8af2f800c0ca84f2c2f4aed0af60d0ed488e20fa32992967e154064f561R283-R303): Replaced direct event firing with `JobUtil.sendEvents` for better event management. [[1]](diffhunk://#diff-c092f8af2f800c0ca84f2c2f4aed0af60d0ed488e20fa32992967e154064f561R283-R303) [[2]](diffhunk://#diff-c092f8af2f800c0ca84f2c2f4aed0af60d0ed488e20fa32992967e154064f561L543-R526) [[3]](diffhunk://#diff-c092f8af2f800c0ca84f2c2f4aed0af60d0ed488e20fa32992967e154064f561L668-R649) [[4]](diffhunk://#diff-c092f8af2f800c0ca84f2c2f4aed0af60d0ed488e20fa32992967e154064f561L721-R703) [[5]](diffhunk://#diff-c092f8af2f800c0ca84f2c2f4aed0af60d0ed488e20fa32992967e154064f561L743-R724) ### Miscellaneous Changes: * [`dotCMS/src/main/java/com/dotcms/jobs/business/api/JobQueueManagerAPIImpl.java`](diffhunk://#diff-c092f8af2f800c0ca84f2c2f4aed0af60d0ed488e20fa32992967e154064f561L764-R743): Adjusted the job progress update interval from 2 to 3 seconds.
- Loading branch information
1 parent
5082547
commit ab2ddd4
Showing
34 changed files
with
1,144 additions
and
530 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
163 changes: 60 additions & 103 deletions
163
dotCMS/src/main/java/com/dotcms/jobs/business/api/JobQueueManagerAPIImpl.java
Large diffs are not rendered by default.
Oops, something went wrong.
57 changes: 0 additions & 57 deletions
57
dotCMS/src/main/java/com/dotcms/jobs/business/api/events/EventProducer.java
This file was deleted.
Oops, something went wrong.
39 changes: 39 additions & 0 deletions
39
dotCMS/src/main/java/com/dotcms/jobs/business/api/events/JobAbandonedEvent.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
package com.dotcms.jobs.business.api.events; | ||
|
||
import com.dotcms.jobs.business.job.Job; | ||
import java.time.LocalDateTime; | ||
|
||
/** | ||
* Event fired when an abandoned job is detected. | ||
*/ | ||
public class JobAbandonedEvent implements JobEvent { | ||
|
||
private final Job job; | ||
private final LocalDateTime detectedAt; | ||
|
||
/** | ||
* Constructs a new JobAbandonedEvent. | ||
* | ||
* @param job The job. | ||
* @param detectedAt The timestamp when the abandoned job was detected. | ||
*/ | ||
public JobAbandonedEvent(Job job, LocalDateTime detectedAt) { | ||
this.job = job; | ||
this.detectedAt = detectedAt; | ||
} | ||
|
||
/** | ||
* @return The abandoned job. | ||
*/ | ||
public Job getJob() { | ||
return job; | ||
} | ||
|
||
/** | ||
* @return The timestamp when the abandoned job was detected. | ||
*/ | ||
public LocalDateTime getDetectedAt() { | ||
return detectedAt; | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
9 changes: 9 additions & 0 deletions
9
dotCMS/src/main/java/com/dotcms/jobs/business/api/events/JobEvent.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
package com.dotcms.jobs.business.api.events; | ||
|
||
/** | ||
* Base marker interface for all job-related events in the job queue system. All specific job event | ||
* types (e.g., JobStartedEvent, JobCompletedEvent, etc.) should implement this interface. | ||
*/ | ||
public interface JobEvent { | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.