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 CheckpointWriteWorker #4

Closed
wants to merge 2 commits into from
Closed

Conversation

kaituo
Copy link
Owner

@kaituo kaituo commented Jun 22, 2021

Description

This PR refactors CheckpointWriteWorker

  1. Extract the method shoulSave for code reuse.
  2. Remove unnecessary exception handling in the write method as ConcurrentModificationException won’t happen when fetching a detector.

Testing done:

  1. Added unit tests for the changed code.

Issues Resolved

opensearch-project#85

Check List

  • [ X ] Commits are signed per the DCO using --signoff

By submitting this pull request, I confirm that my contribution is made under the terms of the Apache 2.0 license.
For more information on following Developer Certificate of Origin and signing off your commits, please check here.

This PR refactors CheckpointWriteWorker
1. Extract the method shoulSave for code reuse.
2. Remove unnecessary exception handling in the write method as ConcurrentModificationException won’t happen when fetching a detector.

Testing done:
1. Added unit tests for the changed code.
@@ -152,22 +151,18 @@ protected BulkRequest toBatchRequest(List<CheckpointWriteRequest> toProcess) {
*/
public void write(ModelState<EntityModel> modelState, boolean forceWrite, RequestPriority priority) {
Instant instant = modelState.getLastCheckpointTime();
if ((instant == Instant.MIN || instant.plus(checkpointInterval).isAfter(clock.instant())) && !forceWrite) {
if (!shoulSave(instant, forceWrite)) {
Copy link
Collaborator

Choose a reason for hiding this comment

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

nit: shouldSave instead of shoulSave?

Copy link
Owner Author

Choose a reason for hiding this comment

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

yeah, fixed

Copy link
Collaborator

@ohltyler ohltyler left a comment

Choose a reason for hiding this comment

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

LGTM overall. +1 on @jmazanec15's comment.

@kaituo kaituo closed this Jun 23, 2021
kaituo added a commit to opensearch-project/anomaly-detection that referenced this pull request Jul 12, 2021
This PR is a conglomerate of the following PRs.

#60
#64
#65
#67
#68
#69
#70
#71
#74
#75
#76
#77
#78
#79
#82
#83
#84
#92
#94
#93
#95
kaituo#1
kaituo#2
kaituo#3
kaituo#4
kaituo#5
kaituo#6
kaituo#7
kaituo#8
kaituo#9
kaituo#10

This spreadsheet contains the mappings from files to PR number (bug fix in my AD fork and tests are not included):
https://gist.github.com/kaituo/9e1592c4ac4f2f449356cb93d0591167
ohltyler pushed a commit to opensearch-project/anomaly-detection that referenced this pull request Sep 1, 2021
This PR is a conglomerate of the following PRs.

#60
#64
#65
#67
#68
#69
#70
#71
#74
#75
#76
#77
#78
#79
#82
#83
#84
#92
#94
#93
#95
kaituo#1
kaituo#2
kaituo#3
kaituo#4
kaituo#5
kaituo#6
kaituo#7
kaituo#8
kaituo#9
kaituo#10

This spreadsheet contains the mappings from files to PR number (bug fix in my AD fork and tests are not included):
https://gist.github.com/kaituo/9e1592c4ac4f2f449356cb93d0591167
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.

3 participants