-
Notifications
You must be signed in to change notification settings - Fork 36
support return AD job when get detector #50
support return AD job when get detector #50
Conversation
src/main/java/com/amazon/opendistroforelasticsearch/ad/model/AnomalyDetectorJob.java
Show resolved
Hide resolved
.../amazon/opendistroforelasticsearch/ad/rest/handler/IndexAnomalyDetectorJobActionHandler.java
Outdated
Show resolved
Hide resolved
.../amazon/opendistroforelasticsearch/ad/rest/handler/IndexAnomalyDetectorJobActionHandler.java
Show resolved
Hide resolved
channel.sendResponse(new BytesRestResponse(response.status(), response.toXContent(channel.newErrorBuilder(), EMPTY_PARAMS))); | ||
} | ||
if (function != null) { | ||
function.execute(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
so function does not send back response using channel?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Function will send back response.
Check line 287 of file IndexAnomalyDetectorJobActionHandler
stopAdDetectorListener(channel, detectorId)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Any way to enforce sending back response? It is easy for function implementor to forget to add a channel.sendResponse.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is a private function and it doesn't implicitly require to send response to channel here. Depends on how developer implements the logic.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
AnomalyDetectorFunction is too general and can be anything. We want to make an interface specific for a specific thing. I would suggest:
- rename AnomalyDetectorFunction to ListenerWithChannel or sth that is more specific
- make execute take channel as a parameter
- add a comment before channel indicating user should send channel response.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We can do that. How about we split such refactoring work into another issue. So we can make this PR more focusing. Thanks for the suggestion.
?job=true
1). If job not exists, create new job.
2). If job exists: a). if job state is enabled, return warning message; b). if job state is disabled, enable job.
1). If job not exists, return error message
2). If job exists: a).if job state is disabled, return warning message; b).if job state is enabled, disable job and stop AD model.
1). If no AD job index or AD job not found or AD job is disabled, delete detector directly
2). If AD job state is enabled, return warning message, not delete detector