Skip to content

Commit

Permalink
Feat (Core): Migrate import contentlets action to job processor - Fee…
Browse files Browse the repository at this point in the history
…dback improvements (#30617)

This pull request includes several changes to the job queue management
system, focusing on improving the handling of job cancellation requests
and updating exception handling. The key changes include the
introduction of a new event for job cancellation requests, modifications
to exception types for consistency, and enhancements to job state
management.

### Improvements to job cancellation handling:
* Added a new `JobCancelRequestEvent` class to represent job
cancellation requests and handle them appropriately
(`dotCMS/src/main/java/com/dotcms/jobs/business/api/events/JobCancelRequestEvent.java`).
* Introduced a method `onCancelRequestJob` to handle job cancellation
requests and updated the `cancelJob` method to use this new method
(`dotCMS/src/main/java/com/dotcms/jobs/business/api/JobQueueManagerAPIImpl.java`).
[[1]](diffhunk://#diff-c092f8af2f800c0ca84f2c2f4aed0af60d0ed488e20fa32992967e154064f561R180-R184)
[[2]](diffhunk://#diff-c092f8af2f800c0ca84f2c2f4aed0af60d0ed488e20fa32992967e154064f561R862-R909)

### Exception handling improvements:
* Replaced `JobQueueDataException` with `DotDataException` in various
methods to standardize exception handling
(`dotCMS/src/main/java/com/dotcms/jobs/business/api/JobQueueManagerAPI.java`).
[[1]](diffhunk://#diff-97639376a50922f533c812eb8848f70e1913df8f14f0fb5bb582243f5660e465L10)
[[2]](diffhunk://#diff-97639376a50922f533c812eb8848f70e1913df8f14f0fb5bb582243f5660e465L97-R99)
[[3]](diffhunk://#diff-97639376a50922f533c812eb8848f70e1913df8f14f0fb5bb582243f5660e465L118-R149)
* Updated exception handling in `getActiveJobs`, `getCompletedJobs`,
`getCanceledJobs`, and `getFailedJobs` methods to throw
`DotDataException` instead of `JobQueueDataException`
(`dotCMS/src/main/java/com/dotcms/jobs/business/api/JobQueueManagerAPIImpl.java`).
[[1]](diffhunk://#diff-c092f8af2f800c0ca84f2c2f4aed0af60d0ed488e20fa32992967e154064f561L307-R323)
[[2]](diffhunk://#diff-c092f8af2f800c0ca84f2c2f4aed0af60d0ed488e20fa32992967e154064f561L327-R434)

### Job state management:
* Added a method `getJobState` to fetch the state of a job and ensure
the latest state is used during job progress updates
(`dotCMS/src/main/java/com/dotcms/jobs/business/api/JobQueueManagerAPIImpl.java`).
* Enhanced the `handleJobCompletion` method to check if a job has been
in a canceling state and update its status accordingly
(`dotCMS/src/main/java/com/dotcms/jobs/business/api/JobQueueManagerAPIImpl.java`).

### Code cleanup and imports:
* Removed unused import `JobQueueDataException` and added necessary
imports for new event handling
(`dotCMS/src/main/java/com/dotcms/jobs/business/api/JobQueueManagerAPI.java`).
* Added imports for new event handling and exception classes
(`dotCMS/src/main/java/com/dotcms/jobs/business/api/JobQueueManagerAPIImpl.java`).
[[1]](diffhunk://#diff-c092f8af2f800c0ca84f2c2f4aed0af60d0ed488e20fa32992967e154064f561R3-R8)
[[2]](diffhunk://#diff-c092f8af2f800c0ca84f2c2f4aed0af60d0ed488e20fa32992967e154064f561R20)
[[3]](diffhunk://#diff-c092f8af2f800c0ca84f2c2f4aed0af60d0ed488e20fa32992967e154064f561R37-R44)
  • Loading branch information
jgambarios authored Nov 13, 2024
1 parent ac4a771 commit a9329c4
Show file tree
Hide file tree
Showing 22 changed files with 1,800 additions and 766 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ public class JobQueueConfigProducer {

// The interval in milliseconds to poll for job updates.
static final int DEFAULT_POLL_JOB_UPDATES_INTERVAL_MILLISECONDS = Config.getIntProperty(
"JOB_QUEUE_POLL_JOB_UPDATES_INTERVAL_MILLISECONDS", 1000
"JOB_QUEUE_POLL_JOB_UPDATES_INTERVAL_MILLISECONDS", 3000
);

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@
import com.dotcms.jobs.business.job.JobPaginatedResult;
import com.dotcms.jobs.business.processor.JobProcessor;
import com.dotcms.jobs.business.queue.JobQueue;
import com.dotcms.jobs.business.queue.error.JobQueueDataException;
import com.dotmarketing.exception.DotDataException;
import java.util.Map;
import java.util.Optional;
Expand Down Expand Up @@ -94,10 +93,10 @@ String createJob(String queueName, Map<String, Object> parameters)
* @param page The page number
* @param pageSize The number of jobs per page
* @return A result object containing the list of active jobs and pagination information.
* @throws JobQueueDataException if there's an error fetching the jobs
* @throws DotDataException if there's an error fetching the jobs
*/
JobPaginatedResult getActiveJobs(String queueName, int page, int pageSize)
throws JobQueueDataException;
throws DotDataException;

/**
* Retrieves a list of jobs.
Expand All @@ -115,39 +114,39 @@ JobPaginatedResult getActiveJobs(String queueName, int page, int pageSize)
* @param page The page number
* @param pageSize The number of jobs per page
* @return A result object containing the list of active jobs and pagination information.
* @throws JobQueueDataException if there's an error fetching the jobs
* @throws DotDataException if there's an error fetching the jobs
*/
JobPaginatedResult getActiveJobs(int page, int pageSize) throws JobQueueDataException;
JobPaginatedResult getActiveJobs(int page, int pageSize) throws DotDataException;

/**
* Retrieves a list of completed jobs
*
* @param page The page number
* @param pageSize The number of jobs per page
* @return A result object containing the list of completed jobs and pagination information.
* @throws JobQueueDataException if there's an error fetching the jobs
* @throws DotDataException if there's an error fetching the jobs
*/
JobPaginatedResult getCompletedJobs(int page, int pageSize) throws JobQueueDataException;
JobPaginatedResult getCompletedJobs(int page, int pageSize) throws DotDataException;

/**
* Retrieves a list of canceled jobs
*
* @param page The page number
* @param pageSize The number of jobs per page
* @return A result object containing the list of canceled jobs and pagination information.
* @throws JobQueueDataException if there's an error fetching the jobs
* @throws DotDataException if there's an error fetching the jobs
*/
JobPaginatedResult getCanceledJobs(int page, int pageSize) throws JobQueueDataException;
JobPaginatedResult getCanceledJobs(int page, int pageSize) throws DotDataException;

/**
* Retrieves a list of failed jobs
*
* @param page The page number
* @param pageSize The number of jobs per page
* @return A result object containing the list of failed jobs and pagination information.
* @throws JobQueueDataException if there's an error fetching the jobs
* @throws DotDataException if there's an error fetching the jobs
*/
JobPaginatedResult getFailedJobs(int page, int pageSize) throws JobQueueDataException;
JobPaginatedResult getFailedJobs(int page, int pageSize) throws DotDataException;

/**
* Cancels a job.
Expand Down
Loading

0 comments on commit a9329c4

Please sign in to comment.