Skip to content

Commit dc7b384

Browse files
committed
Merge remote-tracking branch 'origin/6.x' into index-lifecycle-6.x
2 parents 819dbb5 + 7b18c5c commit dc7b384

File tree

88 files changed

+3097
-833
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

88 files changed

+3097
-833
lines changed

buildSrc/src/main/resources/checkstyle.xml

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,11 +12,25 @@
1212

1313
<!-- Checks Java files and forbids empty Javadoc comments -->
1414
<module name="RegexpMultiline">
15+
<property name="id" value="EmptyJavadoc"/>
1516
<property name="format" value="\/\*[\s\*]*\*\/"/>
1617
<property name="fileExtensions" value="java"/>
1718
<property name="message" value="Empty javadoc comments are forbidden"/>
1819
</module>
1920

21+
<!--
22+
We include snippets that are wrapped in `// tag` and `// end` into the
23+
docs, stripping the leading spaces. If the context is wider than 76
24+
characters then it'll need to scroll. This fails the build if it sees
25+
such snippets.
26+
-->
27+
<module name="RegexpMultiline">
28+
<property name="id" value="SnippetLength"/>
29+
<property name="format" value="^( *)\/\/\s*tag(.+)\s*\n(.*\n)*\1.{77,}\n(.*\n)*\1\/\/\s*end\2\s*$"/>
30+
<property name="fileExtensions" value="java"/>
31+
<property name="message" value="Code snippets longer than 76 characters get cut off when rendered in the docs"/>
32+
</module>
33+
2034
<module name="TreeWalker">
2135
<!-- Its our official line length! See checkstyle_suppressions.xml for the files that don't pass this. For now we
2236
suppress the check there but enforce it everywhere else. This prevents the list from getting longer even if it is

buildSrc/src/main/resources/checkstyle_suppressions.xml

Lines changed: 28 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,34 @@
2121
configuration of classes that aren't in packages. -->
2222
<suppress files="test[/\\]framework[/\\]src[/\\]test[/\\]java[/\\]Dummy.java" checks="PackageDeclaration" />
2323

24+
<!--
25+
Truly temporary suppressions suppression of snippets included in
26+
documentation that are so wide that they scroll.
27+
-->
28+
<suppress files="client[/\\]rest-high-level[/\\]src[/\\]test[/\\]java[/\\]org[/\\]elasticsearch[/\\]client[/\\]documentation[/\\]CRUDDocumentationIT.java" id="SnippetLength" />
29+
<suppress files="client[/\\]rest-high-level[/\\]src[/\\]test[/\\]java[/\\]org[/\\]elasticsearch[/\\]client[/\\]documentation[/\\]ClusterClientDocumentationIT.java" id="SnippetLength" />
30+
<suppress files="client[/\\]rest-high-level[/\\]src[/\\]test[/\\]java[/\\]org[/\\]elasticsearch[/\\]client[/\\]documentation[/\\]GraphDocumentationIT.java" id="SnippetLength" />
31+
<suppress files="client[/\\]rest-high-level[/\\]src[/\\]test[/\\]java[/\\]org[/\\]elasticsearch[/\\]client[/\\]documentation[/\\]IndicesClientDocumentationIT.java" id="SnippetLength" />
32+
<suppress files="client[/\\]rest-high-level[/\\]src[/\\]test[/\\]java[/\\]org[/\\]elasticsearch[/\\]client[/\\]documentation[/\\]IngestClientDocumentationIT.java" id="SnippetLength" />
33+
<suppress files="client[/\\]rest-high-level[/\\]src[/\\]test[/\\]java[/\\]org[/\\]elasticsearch[/\\]client[/\\]documentation[/\\]LicensingDocumentationIT.java" id="SnippetLength" />
34+
<suppress files="client[/\\]rest-high-level[/\\]src[/\\]test[/\\]java[/\\]org[/\\]elasticsearch[/\\]client[/\\]documentation[/\\]MigrationDocumentationIT.java" id="SnippetLength" />
35+
<suppress files="client[/\\]rest-high-level[/\\]src[/\\]test[/\\]java[/\\]org[/\\]elasticsearch[/\\]client[/\\]documentation[/\\]MigrationClientDocumentationIT.java" id="SnippetLength" />
36+
<suppress files="client[/\\]rest-high-level[/\\]src[/\\]test[/\\]java[/\\]org[/\\]elasticsearch[/\\]client[/\\]documentation[/\\]MiscellaneousDocumentationIT.java" id="SnippetLength" />
37+
<suppress files="client[/\\]rest-high-level[/\\]src[/\\]test[/\\]java[/\\]org[/\\]elasticsearch[/\\]client[/\\]documentation[/\\]MlClientDocumentationIT.java" id="SnippetLength" />
38+
<suppress files="client[/\\]rest-high-level[/\\]src[/\\]test[/\\]java[/\\]org[/\\]elasticsearch[/\\]client[/\\]documentation[/\\]RollupDocumentationIT.java" id="SnippetLength" />
39+
<suppress files="client[/\\]rest-high-level[/\\]src[/\\]test[/\\]java[/\\]org[/\\]elasticsearch[/\\]client[/\\]documentation[/\\]SearchDocumentationIT.java" id="SnippetLength" />
40+
<suppress files="client[/\\]rest-high-level[/\\]src[/\\]test[/\\]java[/\\]org[/\\]elasticsearch[/\\]client[/\\]documentation[/\\]SecurityDocumentationIT.java" id="SnippetLength" />
41+
<suppress files="client[/\\]rest-high-level[/\\]src[/\\]test[/\\]java[/\\]org[/\\]elasticsearch[/\\]client[/\\]documentation[/\\]SnapshotClientDocumentationIT.java" id="SnippetLength" />
42+
<suppress files="client[/\\]rest-high-level[/\\]src[/\\]test[/\\]java[/\\]org[/\\]elasticsearch[/\\]client[/\\]documentation[/\\]StoredScriptsDocumentationIT.java" id="SnippetLength" />
43+
<suppress files="client[/\\]rest-high-level[/\\]src[/\\]test[/\\]java[/\\]org[/\\]elasticsearch[/\\]client[/\\]documentation[/\\]TasksClientDocumentationIT.java" id="SnippetLength" />
44+
<suppress files="client[/\\]rest-high-level[/\\]src[/\\]test[/\\]java[/\\]org[/\\]elasticsearch[/\\]client[/\\]documentation[/\\]WatcherDocumentationIT.java" id="SnippetLength" />
45+
<!--
46+
This one is in plugins/examples/script-expert-scoring but we need to
47+
suppress it like this because we build that project twice, once in for
48+
real and once as a test for our build system. -->
49+
<suppress files="src[/\\]main[/\\]java[/\\]org[/\\]elasticsearch[/\\]example[/\\]expertscript[/\\]ExpertScriptPlugin.java" id="SnippetLength" />
50+
<suppress files="modules[/\\]reindex[/\\]src[/\\]test[/\\]java[/\\]org[/\\]elasticsearch[/\\]client[/\\]documentation[/\\]ReindexDocumentationIT.jav" id="SnippetLength" />
51+
2452
<!-- Hopefully temporary suppression of LineLength on files that don't pass it. We should remove these when we the
2553
files start to pass. -->
2654
<suppress files="client[/\\]rest[/\\]src[/\\]test[/\\]java[/\\]org[/\\]elasticsearch[/\\]client[/\\]HeapBufferedAsyncResponseConsumerTests.java" checks="LineLength" />
@@ -159,7 +187,6 @@
159187
<suppress files="server[/\\]src[/\\]main[/\\]java[/\\]org[/\\]elasticsearch[/\\]action[/\\]support[/\\]master[/\\]AcknowledgedRequestBuilder.java" checks="LineLength" />
160188
<suppress files="server[/\\]src[/\\]main[/\\]java[/\\]org[/\\]elasticsearch[/\\]action[/\\]support[/\\]master[/\\]MasterNodeOperationRequestBuilder.java" checks="LineLength" />
161189
<suppress files="server[/\\]src[/\\]main[/\\]java[/\\]org[/\\]elasticsearch[/\\]action[/\\]support[/\\]master[/\\]MasterNodeReadOperationRequestBuilder.java" checks="LineLength" />
162-
<suppress files="server[/\\]src[/\\]main[/\\]java[/\\]org[/\\]elasticsearch[/\\]action[/\\]support[/\\]master[/\\]TransportMasterNodeAction.java" checks="LineLength" />
163190
<suppress files="server[/\\]src[/\\]main[/\\]java[/\\]org[/\\]elasticsearch[/\\]action[/\\]support[/\\]master[/\\]info[/\\]ClusterInfoRequest.java" checks="LineLength" />
164191
<suppress files="server[/\\]src[/\\]main[/\\]java[/\\]org[/\\]elasticsearch[/\\]action[/\\]support[/\\]master[/\\]info[/\\]ClusterInfoRequestBuilder.java" checks="LineLength" />
165192
<suppress files="server[/\\]src[/\\]main[/\\]java[/\\]org[/\\]elasticsearch[/\\]action[/\\]support[/\\]master[/\\]info[/\\]TransportClusterInfoAction.java" checks="LineLength" />

client/rest-high-level/src/main/java/org/elasticsearch/client/RequestConverters.java

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -552,8 +552,20 @@ static Request deleteByQuery(DeleteByQueryRequest deleteByQueryRequest) throws I
552552
return request;
553553
}
554554

555-
static Request rethrottle(RethrottleRequest rethrottleRequest) throws IOException {
556-
String endpoint = new EndpointBuilder().addPathPart("_reindex").addPathPart(rethrottleRequest.getTaskId().toString())
555+
static Request rethrottleReindex(RethrottleRequest rethrottleRequest) {
556+
return rethrottle(rethrottleRequest, "_reindex");
557+
}
558+
559+
static Request rethrottleUpdateByQuery(RethrottleRequest rethrottleRequest) {
560+
return rethrottle(rethrottleRequest, "_update_by_query");
561+
}
562+
563+
static Request rethrottleDeleteByQuery(RethrottleRequest rethrottleRequest) {
564+
return rethrottle(rethrottleRequest, "_delete_by_query");
565+
}
566+
567+
private static Request rethrottle(RethrottleRequest rethrottleRequest, String firstPathPart) {
568+
String endpoint = new EndpointBuilder().addPathPart(firstPathPart).addPathPart(rethrottleRequest.getTaskId().toString())
557569
.addPathPart("_rethrottle").build();
558570
Request request = new Request(HttpPost.METHOD_NAME, endpoint);
559571
Params params = new Params(request)

client/rest-high-level/src/main/java/org/elasticsearch/client/RestHighLevelClient.java

Lines changed: 69 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -511,9 +511,9 @@ public final BulkByScrollResponse updateByQuery(UpdateByQueryRequest updateByQue
511511
* @param listener the listener to be notified upon request completion
512512
*/
513513
public final void updateByQueryAsync(UpdateByQueryRequest updateByQueryRequest, RequestOptions options,
514-
ActionListener<BulkByScrollResponse> listener) {
514+
ActionListener<BulkByScrollResponse> listener) {
515515
performRequestAsyncAndParseEntity(
516-
updateByQueryRequest, RequestConverters::updateByQuery, options, BulkByScrollResponse::fromXContent, listener, emptySet()
516+
updateByQueryRequest, RequestConverters::updateByQuery, options, BulkByScrollResponse::fromXContent, listener, emptySet()
517517
);
518518
}
519519

@@ -543,35 +543,93 @@ public final BulkByScrollResponse deleteByQuery(DeleteByQueryRequest deleteByQue
543543
public final void deleteByQueryAsync(DeleteByQueryRequest deleteByQueryRequest, RequestOptions options,
544544
ActionListener<BulkByScrollResponse> listener) {
545545
performRequestAsyncAndParseEntity(
546-
deleteByQueryRequest, RequestConverters::deleteByQuery, options, BulkByScrollResponse::fromXContent, listener, emptySet()
546+
deleteByQueryRequest, RequestConverters::deleteByQuery, options, BulkByScrollResponse::fromXContent, listener, emptySet()
547547
);
548548
}
549549

550+
/**
551+
* Executes a delete by query rethrottle request.
552+
* See <a href="https://www.elastic.co/guide/en/elasticsearch/reference/current/docs-delete-by-query.html">
553+
* Delete By Query API on elastic.co</a>
554+
* @param rethrottleRequest the request
555+
* @param options the request options (e.g. headers), use {@link RequestOptions#DEFAULT} if nothing needs to be customized
556+
* @return the response
557+
* @throws IOException in case there is a problem sending the request or parsing back the response
558+
*/
559+
public final ListTasksResponse deleteByQueryRethrottle(RethrottleRequest rethrottleRequest, RequestOptions options) throws IOException {
560+
return performRequestAndParseEntity(rethrottleRequest, RequestConverters::rethrottleDeleteByQuery, options,
561+
ListTasksResponse::fromXContent, emptySet());
562+
}
563+
564+
/**
565+
* Asynchronously execute an delete by query rethrottle request.
566+
* See <a href="https://www.elastic.co/guide/en/elasticsearch/reference/current/docs-delete-by-query.html">
567+
* Delete By Query API on elastic.co</a>
568+
* @param rethrottleRequest the request
569+
* @param options the request options (e.g. headers), use {@link RequestOptions#DEFAULT} if nothing needs to be customized
570+
* @param listener the listener to be notified upon request completion
571+
*/
572+
public final void deleteByQueryRethrottleAsync(RethrottleRequest rethrottleRequest, RequestOptions options,
573+
ActionListener<ListTasksResponse> listener) {
574+
performRequestAsyncAndParseEntity(rethrottleRequest, RequestConverters::rethrottleDeleteByQuery, options,
575+
ListTasksResponse::fromXContent, listener, emptySet());
576+
}
577+
578+
/**
579+
* Executes a update by query rethrottle request.
580+
* See <a href="https://www.elastic.co/guide/en/elasticsearch/reference/current/docs-update-by-query.html">
581+
* Update By Query API on elastic.co</a>
582+
* @param rethrottleRequest the request
583+
* @param options the request options (e.g. headers), use {@link RequestOptions#DEFAULT} if nothing needs to be customized
584+
* @return the response
585+
* @throws IOException in case there is a problem sending the request or parsing back the response
586+
*/
587+
public final ListTasksResponse updateByQueryRethrottle(RethrottleRequest rethrottleRequest, RequestOptions options) throws IOException {
588+
return performRequestAndParseEntity(rethrottleRequest, RequestConverters::rethrottleUpdateByQuery, options,
589+
ListTasksResponse::fromXContent, emptySet());
590+
}
591+
592+
/**
593+
* Asynchronously execute an update by query rethrottle request.
594+
* See <a href="https://www.elastic.co/guide/en/elasticsearch/reference/current/docs-update-by-query.html">
595+
* Update By Query API on elastic.co</a>
596+
* @param rethrottleRequest the request
597+
* @param options the request options (e.g. headers), use {@link RequestOptions#DEFAULT} if nothing needs to be customized
598+
* @param listener the listener to be notified upon request completion
599+
*/
600+
public final void updateByQueryRethrottleAsync(RethrottleRequest rethrottleRequest, RequestOptions options,
601+
ActionListener<ListTasksResponse> listener) {
602+
performRequestAsyncAndParseEntity(rethrottleRequest, RequestConverters::rethrottleUpdateByQuery, options,
603+
ListTasksResponse::fromXContent, listener, emptySet());
604+
}
605+
550606
/**
551607
* Executes a reindex rethrottling request.
552608
* See the <a href="https://www.elastic.co/guide/en/elasticsearch/reference/current/docs-reindex.html#docs-reindex-rethrottle">
553-
* Reindex rethrottling API on elastic.co</a>
609+
* Reindex rethrottling API on elastic.co</a>
610+
*
554611
* @param rethrottleRequest the request
555-
* @param options the request options (e.g. headers), use {@link RequestOptions#DEFAULT} if nothing needs to be customized
612+
* @param options the request options (e.g. headers), use {@link RequestOptions#DEFAULT} if nothing needs to be customized
556613
* @return the response
557614
* @throws IOException in case there is a problem sending the request or parsing back the response
558615
*/
559616
public final ListTasksResponse reindexRethrottle(RethrottleRequest rethrottleRequest, RequestOptions options) throws IOException {
560-
return performRequestAndParseEntity(rethrottleRequest, RequestConverters::rethrottle, options, ListTasksResponse::fromXContent,
561-
emptySet());
617+
return performRequestAndParseEntity(rethrottleRequest, RequestConverters::rethrottleReindex, options,
618+
ListTasksResponse::fromXContent, emptySet());
562619
}
563620

564621
/**
565622
* Executes a reindex rethrottling request.
566623
* See the <a href="https://www.elastic.co/guide/en/elasticsearch/reference/current/docs-reindex.html#docs-reindex-rethrottle">
567-
* Reindex rethrottling API on elastic.co</a>
624+
* Reindex rethrottling API on elastic.co</a>
625+
*
568626
* @param rethrottleRequest the request
569-
* @param options the request options (e.g. headers), use {@link RequestOptions#DEFAULT} if nothing needs to be customized
570-
* @param listener the listener to be notified upon request completion
627+
* @param options the request options (e.g. headers), use {@link RequestOptions#DEFAULT} if nothing needs to be customized
628+
* @param listener the listener to be notified upon request completion
571629
*/
572630
public final void reindexRethrottleAsync(RethrottleRequest rethrottleRequest, RequestOptions options,
573631
ActionListener<ListTasksResponse> listener) {
574-
performRequestAsyncAndParseEntity(rethrottleRequest, RequestConverters::rethrottle, options, ListTasksResponse::fromXContent,
632+
performRequestAsyncAndParseEntity(rethrottleRequest, RequestConverters::rethrottleReindex, options, ListTasksResponse::fromXContent,
575633
listener, emptySet());
576634
}
577635

client/rest-high-level/src/main/java/org/elasticsearch/client/RollupClient.java

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,8 @@
2020
package org.elasticsearch.client;
2121

2222
import org.elasticsearch.action.ActionListener;
23+
import org.elasticsearch.client.rollup.GetRollupJobRequest;
24+
import org.elasticsearch.client.rollup.GetRollupJobResponse;
2325
import org.elasticsearch.client.rollup.PutRollupJobRequest;
2426
import org.elasticsearch.client.rollup.PutRollupJobResponse;
2527

@@ -73,4 +75,37 @@ public void putRollupJobAsync(PutRollupJobRequest request, RequestOptions option
7375
PutRollupJobResponse::fromXContent,
7476
listener, Collections.emptySet());
7577
}
78+
79+
/**
80+
* Get a rollup job from the cluster.
81+
* See <a href="https://www.elastic.co/guide/en/elasticsearch/reference/current/rollup-put-job.html">
82+
* the docs</a> for more.
83+
* @param request the request
84+
* @param options the request options (e.g. headers), use {@link RequestOptions#DEFAULT} if nothing needs to be customized
85+
* @return the response
86+
* @throws IOException in case there is a problem sending the request or parsing back the response
87+
*/
88+
public GetRollupJobResponse getRollupJob(GetRollupJobRequest request, RequestOptions options) throws IOException {
89+
return restHighLevelClient.performRequestAndParseEntity(request,
90+
RollupRequestConverters::getJob,
91+
options,
92+
GetRollupJobResponse::fromXContent,
93+
Collections.emptySet());
94+
}
95+
96+
/**
97+
* Asynchronously get a rollup job from the cluster.
98+
* See <a href="https://www.elastic.co/guide/en/elasticsearch/reference/current/rollup-put-job.html">
99+
* the docs</a> for more.
100+
* @param request the request
101+
* @param options the request options (e.g. headers), use {@link RequestOptions#DEFAULT} if nothing needs to be customized
102+
* @param listener the listener to be notified upon request completion
103+
*/
104+
public void getRollupJobAsync(GetRollupJobRequest request, RequestOptions options, ActionListener<GetRollupJobResponse> listener) {
105+
restHighLevelClient.performRequestAsyncAndParseEntity(request,
106+
RollupRequestConverters::getJob,
107+
options,
108+
GetRollupJobResponse::fromXContent,
109+
listener, Collections.emptySet());
110+
}
76111
}

client/rest-high-level/src/main/java/org/elasticsearch/client/RollupRequestConverters.java

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,9 @@
1818
*/
1919
package org.elasticsearch.client;
2020

21+
import org.apache.http.client.methods.HttpGet;
2122
import org.apache.http.client.methods.HttpPut;
23+
import org.elasticsearch.client.rollup.GetRollupJobRequest;
2224
import org.elasticsearch.client.rollup.PutRollupJobRequest;
2325

2426
import java.io.IOException;
@@ -42,4 +44,14 @@ static Request putJob(final PutRollupJobRequest putRollupJobRequest) throws IOEx
4244
request.setEntity(createEntity(putRollupJobRequest, REQUEST_BODY_CONTENT_TYPE));
4345
return request;
4446
}
47+
48+
static Request getJob(final GetRollupJobRequest getRollupJobRequest) {
49+
String endpoint = new RequestConverters.EndpointBuilder()
50+
.addPathPartAsIs("_xpack")
51+
.addPathPartAsIs("rollup")
52+
.addPathPartAsIs("job")
53+
.addPathPart(getRollupJobRequest.getJobId())
54+
.build();
55+
return new Request(HttpGet.METHOD_NAME, endpoint);
56+
}
4557
}

0 commit comments

Comments
 (0)