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

Improve preview and exception handling in AnomalyResultTransportAction #128

Merged
merged 8 commits into from
Jul 26, 2021

Conversation

kaituo
Copy link
Collaborator

@kaituo kaituo commented Jul 14, 2021

Signed-off-by: Kaituo Li kaituo@amazon.com

Description

This PR commits changes from the following PRs:
kaituo#11
kaituo#12

Issues Resolved

#129

Check List

  • 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 commits changes from the following PRs:
#11
#12
@codecov-commenter
Copy link

codecov-commenter commented Jul 15, 2021

Codecov Report

Merging #128 (9329bcf) into main (ea22d59) will increase coverage by 0.91%.
The diff coverage is 79.41%.

Impacted file tree graph

@@             Coverage Diff              @@
##               main     #128      +/-   ##
============================================
+ Coverage     75.97%   76.89%   +0.91%     
- Complexity     2886     2902      +16     
============================================
  Files           264      263       -1     
  Lines         12435    12494      +59     
  Branches       1222     1223       +1     
============================================
+ Hits           9448     9607     +159     
+ Misses         2478     2369     -109     
- Partials        509      518       +9     
Flag Coverage Δ
plugin 76.89% <79.41%> (+0.91%) ⬆️

Flags with carried forward coverage won't be shown. Click here to find out more.

Impacted Files Coverage Δ
.../java/org/opensearch/ad/AnomalyDetectorPlugin.java 95.91% <ø> (ø)
...rg/opensearch/ad/constant/CommonErrorMessages.java 90.90% <ø> (ø)
.../org/opensearch/ad/feature/CompositeRetriever.java 84.11% <ø> (+13.67%) ⬆️
...a/org/opensearch/ad/feature/AbstractRetriever.java 89.28% <66.66%> (-10.72%) ⬇️
...rch/ad/transport/AnomalyResultTransportAction.java 79.15% <73.33%> (+0.70%) ⬆️
...ansport/PreviewAnomalyDetectorTransportAction.java 79.34% <79.31%> (-3.32%) ⬇️
...va/org/opensearch/ad/feature/SearchFeatureDao.java 81.92% <83.13%> (+13.30%) ⬆️
...pensearch/ad/settings/AnomalyDetectorSettings.java 100.00% <100.00%> (ø)
...transport/IndexAnomalyDetectorTransportAction.java 72.46% <0.00%> (-1.83%) ⬇️
src/main/java/org/opensearch/ad/model/ADTask.java 96.56% <0.00%> (-1.57%) ⬇️
... and 8 more

@@ -103,7 +102,8 @@
private final Interpolator interpolator;
private final ClientUtil clientUtil;
private int maxEntitiesForPreview;
private final Gson gson;
private int pageSize;
Copy link
Collaborator

Choose a reason for hiding this comment

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

Add volatile ?

Copy link
Collaborator Author

@kaituo kaituo Jul 19, 2021

Choose a reason for hiding this comment

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

added. Just curious: did you see any bug/tickets related to not having volatile keyword?

Copy link
Collaborator

Choose a reason for hiding this comment

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

No, I always use volatile before fields which shared by multiple threads for system settings.

@@ -182,6 +185,11 @@ public void getLatestDataTime(AnomalyDetector detector, ActionListener<Optional<
* @param listener listener to return back the entities
*/
public void getHighestCountEntities(AnomalyDetector detector, long startTime, long endTime, ActionListener<List<Entity>> listener) {
if (detector.getCategoryField() == null || detector.getCategoryField().isEmpty()) {
Copy link
Collaborator

Choose a reason for hiding this comment

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

Use detector.isMultientityDetector() ?

Copy link
Collaborator Author

@kaituo kaituo Jul 19, 2021

Choose a reason for hiding this comment

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

changed

* in the natural order of composite keys. This is fine for Preview API. Preview API needs the
* top entities to make sure there is enough data for training and showing the results. We
* can paginate entities and filter out entities that do not have enough docs (e.g., 256 docs).
* As long as we have collected the desired number of entities (e.g., 5 entities), we can stop
Copy link
Collaborator

Choose a reason for hiding this comment

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

How about add max pagination limit to avoid scanning all entities if no entity has enough docs?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

how about adding 1 minute expiration time as preview is time-sensitive? If we can finish within time, scanning all entities are acceptable.

Copy link
Collaborator

Choose a reason for hiding this comment

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

I'm ok for that

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

please check the upcoming commit

topEntities.add(pageResults.get(i));
}
Map<String, Object> afterKey = compositeAgg.afterKey();
if (topEntities.size() >= maxEntitiesForPreview || afterKey == null || expirationEpochMs < clock.millis()) {
Copy link
Collaborator

Choose a reason for hiding this comment

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

If timeout, should we use onFailure to show timeout warning on frontend ?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

how about if timeout and if there are entities found, log the timeout and send whatever we have? And if timeout and if there are no entities found, send failure as you said?

Copy link
Collaborator

Choose a reason for hiding this comment

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

That makes sense. We should only send out timeout failure if no entities found.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

changed. Please check the commit.

jmazanec15
jmazanec15 previously approved these changes Jul 23, 2021
@kaituo kaituo merged commit 9731730 into opensearch-project:main Jul 26, 2021
ohltyler pushed a commit to ohltyler/anomaly-detection-2 that referenced this pull request Sep 1, 2021
opensearch-project#128)

* Improve preview and exception handling in AnomalyResultTransportAction

This PR commits changes from the following PRs:
kaituo#11
kaituo#12
ohltyler pushed a commit to ohltyler/anomaly-detection-2 that referenced this pull request Sep 1, 2021
opensearch-project#128)

* Improve preview and exception handling in AnomalyResultTransportAction

This PR commits changes from the following PRs:
kaituo#11
kaituo#12
ohltyler pushed a commit that referenced this pull request Sep 1, 2021
#128)

* Improve preview and exception handling in AnomalyResultTransportAction

This PR commits changes from the following PRs:
kaituo#11
kaituo#12
@ohltyler ohltyler added the enhancement New feature or request label Sep 2, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants