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

refactor(backend): Refactor of ReindexThread (#30109) #30110

Draft
wants to merge 6 commits into
base: main
Choose a base branch
from

Conversation

spbolton
Copy link
Contributor

@spbolton spbolton commented Sep 23, 2024

This pull request includes significant updates to the BulkProcessorListener class in the dotCMS project to improve concurrency handling and error logging. The most important changes involve replacing existing data structures with thread-safe alternatives, adding new atomic counters, and refactoring methods for better readability and functionality.

Improvements to concurrency handling:

  • Replaced HashMap with ConcurrentHashMap for workingRecords to ensure thread-safe operations. (dotCMS/src/main/java/com/dotmarketing/common/reindex/BulkProcessorListener.java)
  • Introduced AtomicInteger counters for tracking total responses, success, and failure counts. (dotCMS/src/main/java/com/dotmarketing/common/reindex/BulkProcessorListener.java)
  • Added a BlockingQueue<ReindexResult> to manage reindexing results in a thread-safe manner. (dotCMS/src/main/java/com/dotmarketing/common/reindex/BulkProcessorListener.java)

Refactoring for readability and functionality:

  • Extracted logic for obtaining IDs from BulkItemResponse into a new method getIdFromResponse. (dotCMS/src/main/java/com/dotmarketing/common/reindex/BulkProcessorListener.java)
  • Refactored error handling and success logging into separate methods addErrorToQueue and addSuccessToQueue. (dotCMS/src/main/java/com/dotmarketing/common/reindex/BulkProcessorListener.java)
  • Replaced handleFailure and handleSuccess methods with new logic to add results to the queue and increment counters. (dotCMS/src/main/java/com/dotmarketing/common/reindex/BulkProcessorListener.java)

Follows on from basic change in #30084

This PR resolves #30109 (Refactor of ReindexThread).

@spbolton spbolton linked an issue Sep 23, 2024 that may be closed by this pull request
@spbolton spbolton marked this pull request as draft September 23, 2024 12:11
@nollymar nollymar changed the base branch from master to main September 30, 2024 20:13
@spbolton spbolton force-pushed the issue-30109-refactor-of-reindexthread branch from 80bd6c3 to df3383a Compare October 1, 2024 10:29
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Refactor of ReindexThread
1 participant