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

HLRC: Add activate watch action #33988

Merged
merged 13 commits into from
Oct 4, 2018
Merged

Conversation

iverase
Copy link
Contributor

@iverase iverase commented Sep 24, 2018

Adds activate watch action to the high level rest client.

Relates #29827

@iverase iverase requested a review from hub-cap September 24, 2018 10:23
@iverase iverase changed the title HLRC: Add activate watcher action HLRC: Add activate watch action Sep 24, 2018
@elasticmachine
Copy link
Collaborator

Pinging @elastic/es-core-infra

Copy link
Contributor

@pcsanwald pcsanwald left a 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() {
Copy link
Contributor

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
Copy link
Contributor

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

Copy link
Contributor

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() {
Copy link
Contributor

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.

Copy link
Contributor

@hub-cap hub-cap left a 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())
Copy link
Contributor

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) {
Copy link
Contributor

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 {
Copy link
Contributor

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);
}


Copy link
Contributor

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
Copy link
Contributor

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 {
Copy link
Contributor

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.

Copy link
Contributor Author

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?

Copy link
Contributor

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!

@iverase
Copy link
Contributor Author

iverase commented Oct 3, 2018

@hub-cap Added response test and changed the docs. I think it is getting closer.

Is this change required in 6.x?

@hub-cap
Copy link
Contributor

hub-cap commented Oct 3, 2018

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

Copy link
Contributor

@hub-cap hub-cap left a comment

Choose a reason for hiding this comment

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

minor nits, then :shipit:

/**
* A request to explicitly activate a watch.
*/
public final class ActivateWatchRequest implements Validatable, Closeable {
Copy link
Contributor

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?

Copy link
Contributor

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");
Copy link
Contributor

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");
Copy link
Contributor

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 {
Copy link
Contributor

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

@iverase
Copy link
Contributor Author

iverase commented Oct 4, 2018

@elasticmachine test this please

1 similar comment
@iverase
Copy link
Contributor Author

iverase commented Oct 4, 2018

@elasticmachine test this please

@iverase iverase merged commit 3ccb7af into elastic:master Oct 4, 2018
@iverase
Copy link
Contributor Author

iverase commented Oct 4, 2018

@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.

@jtibshirani
Copy link
Contributor

Just backported it to 6.x in 83e30ee, sorry for the delay!

iverase added a commit that referenced this pull request Oct 4, 2018
* HLRC: Add activate watcher action

Adds activate watch action to the high level rest client.

Relates #29827
@iverase iverase deleted the activateWatcher branch October 4, 2018 12:47
jasontedor added a commit to jasontedor/elasticsearch that referenced this pull request Oct 4, 2018
* 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)
  ...
jasontedor added a commit to jasontedor/elasticsearch that referenced this pull request Oct 4, 2018
* 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)
  ...
kcm pushed a commit that referenced this pull request Oct 30, 2018
* HLRC: Add activate watcher action

Adds activate watch action to the high level rest client.

Relates #29827
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants