Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feat (Core): Migrate import contentlets action to job processor - Feedback improvements #30617

Conversation

jgambarios
Copy link
Contributor

@jgambarios jgambarios commented Nov 9, 2024

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] [2]

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] [2] [3]
  • 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] [2]

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] [2] [3]

This PR fixes: #29498

Replaced the use of `synchronizedList` with `CopyOnWriteArrayList` for thread safety in `RealTimeJobMonitor`. Simplified content import method by consolidating preview and publish handling into a single method and improved header processing logic for multilingual imports in `ImportContentletsProcessor`.
Introduced JobCancelRequestEvent to handle job cancel requests, and updated JobState to include CANCEL_REQUESTED state. Enhanced logic to support cancellation in JobQueueManagerAPIImpl, including job cancellation exception handling and event notifications.
Implemented caching for job states to improve performance by avoiding redundant database calls. Added new `JobCache` interface and `JobCacheImpl` for job state caching, and integrated it with methods fetching and updating job state and status. Enhanced job progress updates to utilize the new caching logic, and removed redundant job cancellation logic for clarity and efficiency.
Refactor to introduce `findContentType` for content type retrieval and validation. This involves handling cases where content type is not found, adding detailed error messages, and ensuring security checks.
…mportContentletsAction-to-job-processor-fixes
Copy link
Contributor

@fabrizzio-dotCMS fabrizzio-dotCMS left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

left a couple of comments but all in all looks good

@nollymar nollymar added this pull request to the merge queue Nov 13, 2024
@github-merge-queue github-merge-queue bot removed this pull request from the merge queue due to failed status checks Nov 13, 2024
@jgambarios jgambarios added this pull request to the merge queue Nov 13, 2024
Merged via the queue into main with commit a9329c4 Nov 13, 2024
36 checks passed
@jgambarios jgambarios deleted the issue-29498-migrate-ImportContentletsAction-to-job-processor-fixes branch November 13, 2024 15:38
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
3 participants