-
Notifications
You must be signed in to change notification settings - Fork 25k
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
HLRC: Add activate watch action #33988
Conversation
Pinging @elastic/es-core-infra |
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.
A few small naming suggestions and one test suggestion, but I don't want to block merging on re-review.
} | ||
|
||
@Override | ||
public String toString() { |
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.
do we need to override toString
here? seems relatively harmless, but wasn't sure if it's necessary.
|
||
} | ||
|
||
// Activate watch that does not exist |
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.
I'd split this into a separate test case, testActivateWatchThatExists
and testActivateWatchThatDoesNotExist
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.
+1
@@ -75,4 +76,14 @@ public void testDeleteWatch() { | |||
assertEquals("/_xpack/watcher/watch/" + watchId, request.getEndpoint()); | |||
assertThat(request.getEntity(), nullValue()); | |||
} | |||
|
|||
public void testActivateWatch() { |
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.
I think testActivateWatchRequestConversion
is a clearer name.
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.
Wow im super sorry, i had done a review and forgot to click submit :/
Update to today, and we will very soon have a better way to test responses (you do not have a response test) and to generate docs, in the next day or two. We should hold off until then to merge. Feel free to fix up my nits tho.
.addPathPartAsIs("_xpack") | ||
.addPathPartAsIs("watcher") | ||
.addPathPartAsIs("watch") | ||
.addPathPartAsIs(activateWatchRequest.getWatchId()) |
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.
.addPathPart(activateWatchRequest...)
.addPathPartAsIs("_activate")
Looks like you swapped the two of them.
|
||
ValidationException exception = new ValidationException(); | ||
|
||
if (watchId == null) { |
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.
You should just put these in the constructor (the null check already is) and throw from there instead of here and just not override it
} | ||
|
||
@Override | ||
public XContentBuilder toXContent(XContentBuilder builder, Params params) throws IOException { |
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.
Node needed and it really doesnt even do anything, so we can remove it and ToXContent interface
return Objects.hash(status); | ||
} | ||
|
||
|
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.
extra space
|
||
} | ||
|
||
// Activate watch that does not exist |
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.
+1
@@ -132,4 +135,59 @@ public void onFailure(Exception e) { | |||
} | |||
} | |||
|
|||
public void testActivateWatch() throws Exception { |
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 will have a new ay to deal with the docs+test, we should wait to merge until it is merged.
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.
@hub-cap which is the issue that it is introducing this change?
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.
#34125 and it looks like its merged!
@hub-cap Added response test and changed the docs. I think it is getting closer. Is this change required in 6.x? |
Yea we backport all of the HLRC APIs to the current 6.x. Some of them landed in 6.4, most will land in 6.5 |
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.
minor nits, then
/** | ||
* A request to explicitly activate a watch. | ||
*/ | ||
public final class ActivateWatchRequest implements Validatable, Closeable { |
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 reason this is Closeable?
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.
You may also have a look at TimedRequest
, assuming this needs the timeouts (I dont know if it does or not, you would have to research the transport layer action)
|
||
public ActivateWatchRequest(String watchId) { | ||
if (watchId == null) { | ||
throw new IllegalArgumentException("Watch identifier is required"); |
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.
there is a Objects.requireNonNull
helper you can use here
return Objects.hash(status); | ||
} | ||
|
||
private static final ParseField STATUS_FIELD = new ParseField("status"); |
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 typically on teh top of these classes.
new ConstructingObjectParser<>("activate_watch_response", true, | ||
a -> new ActivateWatchResponse((WatchStatus) a[0])); | ||
|
||
static { |
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 too is on top
@elasticmachine test this please |
1 similar comment
@elasticmachine test this please |
@hub-cap The commit cannot be back ported as WatchStatus has not been back ported. If necessary I can coordinate with @jtibshirani to do so. |
Just backported it to 6.x in 83e30ee, sorry for the delay! |
* HLRC: Add activate watcher action Adds activate watch action to the high level rest client. Relates #29827
* master: (25 commits) HLRC: ML Adding get datafeed stats API (elastic#34271) Small fixes to the HLRC watcher documentation. (elastic#34306) Tasks: Document that status is not semvered (elastic#34270) HLRC: ML Add preview datafeed api (elastic#34284) [CI] Fix bogus ScheduleWithFixedDelayTests.testRunnableRunsAtMostOnceAfterCancellation Fix error in documentation for activete watch SCRIPTING: Terms set query expression (elastic#33856) Logging: Drop remaining Settings log ctor (elastic#34149) [ML] Remove unused last_data_time member from Job (elastic#34262) Docs: Allow skipping response assertions (elastic#34240) HLRC: Add activate watch action (elastic#33988) [Security] Multi Index Expression alias wildcard exclusion (elastic#34144) [ML] Label anomalies with multi_bucket_impact (elastic#34233) Document smtp.ssl.trust configuration option (elastic#34275) Support PKCS#11 tokens as keystores and truststores (elastic#34063) Fix sporadic failure in NestedObjectMapperTests [Authz] Allow update settings action for system user (elastic#34030) Replace version with reader cache key in IndicesRequestCache (elastic#34189) [TESTS] Set SO_LINGER and SO_REUSEADDR on the mock socket (elastic#34211) Security: upgrade unboundid ldapsdk to 4.0.8 (elastic#34247) ...
* rename-ccr-stats: (25 commits) HLRC: ML Adding get datafeed stats API (elastic#34271) Small fixes to the HLRC watcher documentation. (elastic#34306) Tasks: Document that status is not semvered (elastic#34270) HLRC: ML Add preview datafeed api (elastic#34284) [CI] Fix bogus ScheduleWithFixedDelayTests.testRunnableRunsAtMostOnceAfterCancellation Fix error in documentation for activete watch SCRIPTING: Terms set query expression (elastic#33856) Logging: Drop remaining Settings log ctor (elastic#34149) [ML] Remove unused last_data_time member from Job (elastic#34262) Docs: Allow skipping response assertions (elastic#34240) HLRC: Add activate watch action (elastic#33988) [Security] Multi Index Expression alias wildcard exclusion (elastic#34144) [ML] Label anomalies with multi_bucket_impact (elastic#34233) Document smtp.ssl.trust configuration option (elastic#34275) Support PKCS#11 tokens as keystores and truststores (elastic#34063) Fix sporadic failure in NestedObjectMapperTests [Authz] Allow update settings action for system user (elastic#34030) Replace version with reader cache key in IndicesRequestCache (elastic#34189) [TESTS] Set SO_LINGER and SO_REUSEADDR on the mock socket (elastic#34211) Security: upgrade unboundid ldapsdk to 4.0.8 (elastic#34247) ...
* HLRC: Add activate watcher action Adds activate watch action to the high level rest client. Relates #29827
Adds activate watch action to the high level rest client.
Relates #29827