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

REST high-level client: add get ingest pipeline API #30847

Merged
merged 7 commits into from
Jun 1, 2018

Conversation

sohaibiftikhar
Copy link
Contributor

@sohaibiftikhar sohaibiftikhar commented May 24, 2018

@elasticmachine
Copy link
Collaborator

Pinging @elastic/es-core-infra

@imotov
Copy link
Contributor

imotov commented May 24, 2018

@elasticmachine add to whitelist

* Get an existing pipeline
* <p>
* See
* <a href="https://www.elastic.co/guide/en/elasticsearch/reference/current/put-pipeline-api.html"> Get Pipeline API on elastic.co</a>
Copy link
Contributor Author

Choose a reason for hiding this comment

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

TODO: Fix javadoc link.

@@ -178,4 +156,27 @@ public void testPutPipeline() throws IOException {
execute(request, highLevelClient().cluster()::putPipeline, highLevelClient().cluster()::putPipelineAsync);
assertTrue(putPipelineResponse.isAcknowledged());
}

public void testGetPipeline() throws IOException {
String id = "get_pipeline_id";
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Change this to some_pipeline_id for uniformity.

Copy link
Member

@nik9000 nik9000 left a comment

Choose a reason for hiding this comment

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

I left just one question. Other than that it looks good!

import java.util.List;
import java.util.Map;

public class GetPipelineResponseTests extends ESTestCase {
Copy link
Member

Choose a reason for hiding this comment

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

What about making this an AbstractStreamableXContentTestCase like you did in #30793?

public void getPipelineAsync(GetPipelineRequest request, ActionListener<GetPipelineResponse> listener, Header... headers) {
restHighLevelClient.performRequestAsyncAndParseEntity( request, RequestConverters::getPipeline,
GetPipelineResponse::fromXContent, listener, emptySet(), headers);
}
Copy link
Member

Choose a reason for hiding this comment

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

Along the lines of the other comment I left on #30793 , this API should be added under the ingest namespace rather than the cluster one.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I would prefer to pick up moving to a new namespace after this and #30865 have been merged. Is this okay? Or do I need to bundle it with this change?

Copy link
Member

Choose a reason for hiding this comment

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

sure fine with me

Copy link
Member

@javanna javanna left a comment

Choose a reason for hiding this comment

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

LGTM besides the comment I left on the API namespace

Relates to elastic#27205

(cherry picked from commit 696b0ab2d09d4d25806b3fbfd4f82b6fc9f7218b)
@sohaibiftikhar sohaibiftikhar force-pushed the get_pipeline branch 2 times, most recently from ecb9bf9 to 8e2aeec Compare May 29, 2018 12:28
-- Also fixed strings
-- removed getPipelineConfigs method and switched to pipelines() method.
clonePipelines.add(createRandomPipeline("pipeline_" + clonePipelines.size() + 1));
return new GetPipelineResponse(clonePipelines);
} catch (IOException e) {
return null;
Copy link
Member

Choose a reason for hiding this comment

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

rather throw UncheckedIOException ?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Thanks for the tip. I didn't know these existed.

@Override
protected GetPipelineResponse mutateInstance(GetPipelineResponse response) {
try {
ArrayList<PipelineConfiguration> clonePipelines = new ArrayList<>(response.pipelines());
Copy link
Member

@javanna javanna May 29, 2018

Choose a reason for hiding this comment

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

nit: can you declare it as a list on the left side?

Copy link
Contributor Author

@sohaibiftikhar sohaibiftikhar May 29, 2018

Choose a reason for hiding this comment

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

You mean left side?

Copy link
Member

Choose a reason for hiding this comment

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

yes :) I have edited my comment right after posting it :)

} catch (IOException e) {
// If we fail to construct an instance we return `null` which would make the user of this method
// fail the test.
return null;
Copy link
Member

Choose a reason for hiding this comment

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

I would rather throw UncheckedIOException here

int result = 1;
for (PipelineConfiguration pipeline: pipelines) {
// We only take the sum here to ensure that the order does not matter.
result += (pipeline == null ? 0 : pipeline.getConfigAsMap().hashCode());
Copy link
Member

Choose a reason for hiding this comment

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

shall we add equals and hashcode to PipelineConfiguration ?

Copy link
Contributor Author

@sohaibiftikhar sohaibiftikhar May 29, 2018

Choose a reason for hiding this comment

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

It is already there. Unfortunately, it uses the BytesReference to do this. This depends on the XContentType and hence is not useful for comparison. Do you want me to change the implementation there?

Copy link
Member

Choose a reason for hiding this comment

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

I think we could, I am assuming that we need these only for tests and making equals/hashcode work with the map representation would not hurt. You can try and run IngestMetadaTests, PipelineConfigurationTests, PipelineExecutionServiceTests and PipelineStoreTests to check whether they remain green after the change.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Cool thanks! Will do the change.

@@ -48,8 +50,13 @@ public GetPipelineResponse(List<PipelineConfiguration> pipelines) {
this.pipelines = pipelines;
Copy link
Contributor Author

@sohaibiftikhar sohaibiftikhar May 29, 2018

Choose a reason for hiding this comment

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

@javanna Should I change this constructor to Set<PipelineConfiguration> instead of List<PipelineConfiguration> to keep it more in line with the actual JSON response? Then we don't need to do tricky stuff in the equals and hashcode. I did not do this before because PipelineConfiguration did not have the ideal equals and hashcode.

Copy link
Member

Choose a reason for hiding this comment

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

I would be ok with that, but let's first see whether tests are fine with this change, my assumptions may be wrong :)

-- also throw UncheckedIOException instead of returning null
@javanna
Copy link
Member

javanna commented May 30, 2018

@sohaibiftikhar when I build the docs I get

asciidoc: WARNING: get_pipeline.asciidoc: line 14: callout refers to non-existent list item 2

could you please look into that?

@sohaibiftikhar
Copy link
Contributor Author

@javanna I am confused. Line 14 is a blank line. Plus there is no list item <2> for that part. I could not replicate it as well. Could you give me the exact command to replicate this?

@sohaibiftikhar
Copy link
Contributor Author

sohaibiftikhar commented May 30, 2018

Okay, I found it. The end tag had a mistake. Still would be helpful to get the command though. Thanks!

@javanna
Copy link
Member

javanna commented May 30, 2018

here is the command that I run (you need to check out the docs repo first) from the root of my elasticsearch checkout:

/path/to/elastic/docs/build_docs.pl --doc docs/java-rest/index.asciidoc --chunk 1 --out ~/temp/asciidoc  --open

@javanna
Copy link
Member

javanna commented May 30, 2018

retest this please

@javanna
Copy link
Member

javanna commented May 30, 2018

@sohaibiftikhar would you mind pulling master in please?

@javanna
Copy link
Member

javanna commented May 30, 2018

nevermind, I took care of it, hopefully tests get green, failures were unrelated to your changes.

@javanna
Copy link
Member

javanna commented May 31, 2018

retest this please

@javanna
Copy link
Member

javanna commented May 31, 2018

retest this please

@sohaibiftikhar
Copy link
Contributor Author

works finally!

@javanna javanna merged commit 80d20a9 into elastic:master Jun 1, 2018
@javanna
Copy link
Member

javanna commented Jun 1, 2018

thanks @sohaibiftikhar !

javanna pushed a commit that referenced this pull request Jun 1, 2018
dnhatn added a commit that referenced this pull request Jun 2, 2018
* 6.x:
  Adjust BWC version on client features
  Introduce client feature tracking (#31020)
  [DOCS] Make geoshape docs less memory hungry (#31014)
  Fix handling of percent-encoded spaces in Windows batch files (#31034)
  [Docs] Fix a typo in Create Index naming limitation (#30891)
  REST high-level client: add delete ingest pipeline API (#30865)
  Ensure that index_prefixes settings cannot be changed (#30967)
  REST high-level client: add get ingest pipeline API (#30847)
  Cross Cluster Search: preserve remote status code (#30976)
  High-level client: list tasks failure to not lose nodeId (#31001)
  Refactor Sniffer and make it testable (#29638)
  [ML][TEST] Fix bucket count assertion in all tests in ModelPlotsIT (#31026)
  Add an option to split keyword field on whitespace at query time (#30691)
  Allow rollup job creation only if cluster is x-pack ready (#30963)
  Fix interoperability with < 6.3 transport clients (#30971)
  [Tests] Fix alias names in PutIndexTemplateRequestTests (#30960)
  [DOCS] Fixes links (#31011)
  Watcher: Give test a little more time
dnhatn added a commit that referenced this pull request Jun 2, 2018
* master:
  Avoid randomization bug in FeatureAwareTests
  Adjust BWC version on client features
  Add TRACE, CONNECT, and PATCH http methods (#31035)
  Adjust BWC version on client features
  [DOCS] Make geoshape docs less memory hungry (#31014)
  Fix handling of percent-encoded spaces in Windows batch files (#31034)
  [Docs] Fix a typo in Create Index naming limitation (#30891)
  Introduce client feature tracking (#31020)
  Ensure that index_prefixes settings cannot be changed (#30967)
  REST high-level client: add delete ingest pipeline API (#30865)
  [ML][TEST] Fix bucket count assertion in all tests in ModelPlotsIT (#31026)
  Allow rollup job creation only if cluster is x-pack ready (#30963)
  Fix interoperability with < 6.3 transport clients (#30971)
  Add an option to split keyword field on whitespace at query time (#30691)
  [Tests] Fix alias names in PutIndexTemplateRequestTests (#30960)
  REST high-level client: add get ingest pipeline API (#30847)
  Cross Cluster Search: preserve remote status code (#30976)
  High-level client: list tasks failure to not lose nodeId (#31001)
  [DOCS] Fixes links (#31011)
  Watcher: Give test a little more time
  Reuse expiration date of trial licenses (#30950)
  Remove unused query methods from MappedFieldType. (#30987)
  Transport client: Don't validate node in handshake (#30737)
  [DOCS] Clarify not all PKCS12 usable as truststores (#30750)
  HLRest: Allow caller to set per request options (#30490)
  Remove version read/write logic in Verify Response (#30879)
  [DOCS] Update readme for testing x-pack code snippets (#30696)
  Ensure intended key is selected in SamlAuthenticatorTests (#30993)
  Core: Remove RequestBuilder from Action (#30966)
@sohaibiftikhar sohaibiftikhar deleted the get_pipeline branch June 5, 2018 11:32
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