Skip to content

Commit 5632e31

Browse files
committed
Merge branch 'master' into ccr
* master: Painless: Add Bindings (#33042) Update version after client credentials backport Fix forbidden apis on FIPS (#33202) Remote 6.x transport BWC Layer for `_shrink` (#33236) Test fix - Graph HLRC tests needed another field adding to randomisation exception list HLRC: Add ML Get Records API (#33085) [ML] Fix character set finder bug with unencodable charsets (#33234) TESTS: Fix overly long lines (#33240) Test fix - Graph HLRC test was missing field name to be excluded from randomisation logic Remove unsupported group_shard_failures parameter (#33208) Update BucketUtils#suggestShardSideQueueSize signature (#33210) Parse PEM Key files leniantly (#33173) INGEST: Add Pipeline Processor (#32473) Core: Add java time xcontent serializers (#33120) Consider multi release jars when running third party audit (#33206) Update MSI documentation (#31950) HLRC: create base timed request class (#33216) [DOCS] Fixes command page titles HLRC: Move ML protocol classes into client ml package (#33203) Scroll queries asking for rescore are considered invalid (#32918) Painless: Fix Semicolon Regression (#33212) ingest: minor - update test to include dissect (#33211) Switch remaining LLREST usage to new style Requests (#33171) HLREST: add reindex API (#32679)
2 parents 41c7fc8 + b52818e commit 5632e31

File tree

222 files changed

+4880
-1432
lines changed

Some content is hidden

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

222 files changed

+4880
-1432
lines changed

buildSrc/src/main/groovy/org/elasticsearch/gradle/precommit/PrecommitTasks.groovy

+1
Original file line numberDiff line numberDiff line change
@@ -87,6 +87,7 @@ class PrecommitTasks {
8787
dependsOn(buildResources)
8888
signatureFile = buildResources.copy("forbidden/third-party-audit.txt")
8989
javaHome = project.runtimeJavaHome
90+
targetCompatibility = project.runtimeJavaVersion
9091
}
9192
return thirdPartyAuditTask
9293
}

buildSrc/src/main/java/org/elasticsearch/gradle/precommit/ThirdPartyAuditTask.java

+21
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@
2323
import org.elasticsearch.test.NamingConventionsCheck;
2424
import org.gradle.api.DefaultTask;
2525
import org.gradle.api.GradleException;
26+
import org.gradle.api.JavaVersion;
2627
import org.gradle.api.artifacts.Configuration;
2728
import org.gradle.api.file.FileCollection;
2829
import org.gradle.api.tasks.Input;
@@ -66,6 +67,17 @@ public class ThirdPartyAuditTask extends DefaultTask {
6667

6768
private String javaHome;
6869

70+
private JavaVersion targetCompatibility;
71+
72+
@Input
73+
public JavaVersion getTargetCompatibility() {
74+
return targetCompatibility;
75+
}
76+
77+
public void setTargetCompatibility(JavaVersion targetCompatibility) {
78+
this.targetCompatibility = targetCompatibility;
79+
}
80+
6981
@InputFiles
7082
public Configuration getForbiddenAPIsConfiguration() {
7183
return getProject().getConfigurations().getByName("forbiddenApisCliJar");
@@ -157,10 +169,19 @@ public void runThirdPartyAudit() throws IOException {
157169

158170
private void extractJars(FileCollection jars) {
159171
File jarExpandDir = getJarExpandDir();
172+
// We need to clean up to make sure old dependencies don't linger
173+
getProject().delete(jarExpandDir);
160174
jars.forEach(jar ->
161175
getProject().copy(spec -> {
162176
spec.from(getProject().zipTree(jar));
163177
spec.into(jarExpandDir);
178+
// Exclude classes for multi release jars above target
179+
for (int i = Integer.parseInt(targetCompatibility.getMajorVersion()) + 1;
180+
i <= Integer.parseInt(JavaVersion.VERSION_HIGHER.getMajorVersion());
181+
i++
182+
) {
183+
spec.exclude("META-INF/versions/" + i + "/**");
184+
}
164185
})
165186
);
166187
}

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

+21-6
Original file line numberDiff line numberDiff line change
@@ -24,13 +24,14 @@
2424
import org.apache.http.client.methods.HttpPost;
2525
import org.apache.http.client.methods.HttpPut;
2626
import org.elasticsearch.client.RequestConverters.EndpointBuilder;
27+
import org.elasticsearch.client.ml.CloseJobRequest;
28+
import org.elasticsearch.client.ml.DeleteJobRequest;
29+
import org.elasticsearch.client.ml.GetBucketsRequest;
30+
import org.elasticsearch.client.ml.GetJobRequest;
31+
import org.elasticsearch.client.ml.GetRecordsRequest;
32+
import org.elasticsearch.client.ml.OpenJobRequest;
33+
import org.elasticsearch.client.ml.PutJobRequest;
2734
import org.elasticsearch.common.Strings;
28-
import org.elasticsearch.protocol.xpack.ml.CloseJobRequest;
29-
import org.elasticsearch.protocol.xpack.ml.DeleteJobRequest;
30-
import org.elasticsearch.protocol.xpack.ml.GetJobRequest;
31-
import org.elasticsearch.protocol.xpack.ml.GetBucketsRequest;
32-
import org.elasticsearch.protocol.xpack.ml.OpenJobRequest;
33-
import org.elasticsearch.protocol.xpack.ml.PutJobRequest;
3435

3536
import java.io.IOException;
3637

@@ -124,4 +125,18 @@ static Request getBuckets(GetBucketsRequest getBucketsRequest) throws IOExceptio
124125
request.setEntity(createEntity(getBucketsRequest, REQUEST_BODY_CONTENT_TYPE));
125126
return request;
126127
}
128+
129+
static Request getRecords(GetRecordsRequest getRecordsRequest) throws IOException {
130+
String endpoint = new EndpointBuilder()
131+
.addPathPartAsIs("_xpack")
132+
.addPathPartAsIs("ml")
133+
.addPathPartAsIs("anomaly_detectors")
134+
.addPathPart(getRecordsRequest.getJobId())
135+
.addPathPartAsIs("results")
136+
.addPathPartAsIs("records")
137+
.build();
138+
Request request = new Request(HttpGet.METHOD_NAME, endpoint);
139+
request.setEntity(createEntity(getRecordsRequest, REQUEST_BODY_CONTENT_TYPE));
140+
return request;
141+
}
127142
}

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

+54-16
Original file line numberDiff line numberDiff line change
@@ -19,18 +19,20 @@
1919
package org.elasticsearch.client;
2020

2121
import org.elasticsearch.action.ActionListener;
22-
import org.elasticsearch.protocol.xpack.ml.CloseJobRequest;
23-
import org.elasticsearch.protocol.xpack.ml.CloseJobResponse;
24-
import org.elasticsearch.protocol.xpack.ml.DeleteJobRequest;
25-
import org.elasticsearch.protocol.xpack.ml.DeleteJobResponse;
26-
import org.elasticsearch.protocol.xpack.ml.GetBucketsRequest;
27-
import org.elasticsearch.protocol.xpack.ml.GetBucketsResponse;
28-
import org.elasticsearch.protocol.xpack.ml.GetJobRequest;
29-
import org.elasticsearch.protocol.xpack.ml.GetJobResponse;
30-
import org.elasticsearch.protocol.xpack.ml.OpenJobRequest;
31-
import org.elasticsearch.protocol.xpack.ml.OpenJobResponse;
32-
import org.elasticsearch.protocol.xpack.ml.PutJobRequest;
33-
import org.elasticsearch.protocol.xpack.ml.PutJobResponse;
22+
import org.elasticsearch.client.ml.CloseJobRequest;
23+
import org.elasticsearch.client.ml.CloseJobResponse;
24+
import org.elasticsearch.client.ml.DeleteJobRequest;
25+
import org.elasticsearch.client.ml.DeleteJobResponse;
26+
import org.elasticsearch.client.ml.GetBucketsRequest;
27+
import org.elasticsearch.client.ml.GetBucketsResponse;
28+
import org.elasticsearch.client.ml.GetJobRequest;
29+
import org.elasticsearch.client.ml.GetJobResponse;
30+
import org.elasticsearch.client.ml.GetRecordsRequest;
31+
import org.elasticsearch.client.ml.GetRecordsResponse;
32+
import org.elasticsearch.client.ml.OpenJobRequest;
33+
import org.elasticsearch.client.ml.OpenJobResponse;
34+
import org.elasticsearch.client.ml.PutJobRequest;
35+
import org.elasticsearch.client.ml.PutJobResponse;
3436

3537
import java.io.IOException;
3638
import java.util.Collections;
@@ -56,9 +58,9 @@ public final class MachineLearningClient {
5658
* For additional info
5759
* see <a href="https://www.elastic.co/guide/en/elasticsearch/reference/current/ml-put-job.html">ML PUT job documentation</a>
5860
*
59-
* @param request The PutJobRequest containing the {@link org.elasticsearch.protocol.xpack.ml.job.config.Job} settings
61+
* @param request The PutJobRequest containing the {@link org.elasticsearch.client.ml.job.config.Job} settings
6062
* @param options Additional request options (e.g. headers), use {@link RequestOptions#DEFAULT} if nothing needs to be customized
61-
* @return PutJobResponse with enclosed {@link org.elasticsearch.protocol.xpack.ml.job.config.Job} object
63+
* @return PutJobResponse with enclosed {@link org.elasticsearch.client.ml.job.config.Job} object
6264
* @throws IOException when there is a serialization issue sending the request or receiving the response
6365
*/
6466
public PutJobResponse putJob(PutJobRequest request, RequestOptions options) throws IOException {
@@ -75,7 +77,7 @@ public PutJobResponse putJob(PutJobRequest request, RequestOptions options) thro
7577
* For additional info
7678
* see <a href="https://www.elastic.co/guide/en/elasticsearch/reference/current/ml-put-job.html">ML PUT job documentation</a>
7779
*
78-
* @param request The request containing the {@link org.elasticsearch.protocol.xpack.ml.job.config.Job} settings
80+
* @param request The request containing the {@link org.elasticsearch.client.ml.job.config.Job} settings
7981
* @param options Additional request options (e.g. headers), use {@link RequestOptions#DEFAULT} if nothing needs to be customized
8082
* @param listener Listener to be notified upon request completion
8183
*/
@@ -98,7 +100,7 @@ public void putJobAsync(PutJobRequest request, RequestOptions options, ActionLis
98100
* @param request {@link GetJobRequest} Request containing a list of jobId(s) and additional options
99101
* @param options Additional request options (e.g. headers), use {@link RequestOptions#DEFAULT} if nothing needs to be customized
100102
* @return {@link GetJobResponse} response object containing
101-
* the {@link org.elasticsearch.protocol.xpack.ml.job.config.Job} objects and the number of jobs found
103+
* the {@link org.elasticsearch.client.ml.job.config.Job} objects and the number of jobs found
102104
* @throws IOException when there is a serialization issue sending the request or receiving the response
103105
*/
104106
public GetJobResponse getJob(GetJobRequest request, RequestOptions options) throws IOException {
@@ -285,4 +287,40 @@ public void getBucketsAsync(GetBucketsRequest request, RequestOptions options, A
285287
listener,
286288
Collections.emptySet());
287289
}
290+
291+
/**
292+
* Gets the records for a Machine Learning Job.
293+
* <p>
294+
* For additional info
295+
* see <a href="https://www.elastic.co/guide/en/elasticsearch/reference/current/ml-get-record.html">ML GET records documentation</a>
296+
*
297+
* @param request the request
298+
* @param options Additional request options (e.g. headers), use {@link RequestOptions#DEFAULT} if nothing needs to be customized
299+
*/
300+
public GetRecordsResponse getRecords(GetRecordsRequest request, RequestOptions options) throws IOException {
301+
return restHighLevelClient.performRequestAndParseEntity(request,
302+
MLRequestConverters::getRecords,
303+
options,
304+
GetRecordsResponse::fromXContent,
305+
Collections.emptySet());
306+
}
307+
308+
/**
309+
* Gets the records for a Machine Learning Job, notifies listener once the requested records are retrieved.
310+
* <p>
311+
* For additional info
312+
* see <a href="https://www.elastic.co/guide/en/elasticsearch/reference/current/ml-get-record.html">ML GET records documentation</a>
313+
*
314+
* @param request the request
315+
* @param options Additional request options (e.g. headers), use {@link RequestOptions#DEFAULT} if nothing needs to be customized
316+
* @param listener Listener to be notified upon request completion
317+
*/
318+
public void getRecordsAsync(GetRecordsRequest request, RequestOptions options, ActionListener<GetRecordsResponse> listener) {
319+
restHighLevelClient.performRequestAsyncAndParseEntity(request,
320+
MLRequestConverters::getRecords,
321+
options,
322+
GetRecordsResponse::fromXContent,
323+
listener,
324+
Collections.emptySet());
325+
}
288326
}

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

+16
Original file line numberDiff line numberDiff line change
@@ -106,6 +106,7 @@
106106
import org.elasticsearch.common.xcontent.XContentType;
107107
import org.elasticsearch.index.VersionType;
108108
import org.elasticsearch.index.rankeval.RankEvalRequest;
109+
import org.elasticsearch.index.reindex.ReindexRequest;
109110
import org.elasticsearch.protocol.xpack.XPackInfoRequest;
110111
import org.elasticsearch.protocol.xpack.XPackUsageRequest;
111112
import org.elasticsearch.protocol.xpack.license.DeleteLicenseRequest;
@@ -820,6 +821,21 @@ static Request clusterHealth(ClusterHealthRequest healthRequest) {
820821
return request;
821822
}
822823

824+
static Request reindex(ReindexRequest reindexRequest) throws IOException {
825+
String endpoint = new EndpointBuilder().addPathPart("_reindex").build();
826+
Request request = new Request(HttpPost.METHOD_NAME, endpoint);
827+
Params params = new Params(request)
828+
.withRefresh(reindexRequest.isRefresh())
829+
.withTimeout(reindexRequest.getTimeout())
830+
.withWaitForActiveShards(reindexRequest.getWaitForActiveShards());
831+
832+
if (reindexRequest.getScrollTime() != null) {
833+
params.putParam("scroll", reindexRequest.getScrollTime());
834+
}
835+
request.setEntity(createEntity(reindexRequest, REQUEST_BODY_CONTENT_TYPE));
836+
return request;
837+
}
838+
823839
static Request rollover(RolloverRequest rolloverRequest) throws IOException {
824840
String endpoint = new EndpointBuilder().addPathPart(rolloverRequest.getAlias()).addPathPartAsIs("_rollover")
825841
.addPathPart(rolloverRequest.getNewIndexName()).build();

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

+29
Original file line numberDiff line numberDiff line change
@@ -64,6 +64,8 @@
6464
import org.elasticsearch.common.xcontent.XContentType;
6565
import org.elasticsearch.index.rankeval.RankEvalRequest;
6666
import org.elasticsearch.index.rankeval.RankEvalResponse;
67+
import org.elasticsearch.index.reindex.BulkByScrollResponse;
68+
import org.elasticsearch.index.reindex.ReindexRequest;
6769
import org.elasticsearch.plugins.spi.NamedXContentProvider;
6870
import org.elasticsearch.rest.BytesRestResponse;
6971
import org.elasticsearch.rest.RestStatus;
@@ -395,6 +397,33 @@ public final void bulkAsync(BulkRequest bulkRequest, RequestOptions options, Act
395397
performRequestAsyncAndParseEntity(bulkRequest, RequestConverters::bulk, options, BulkResponse::fromXContent, listener, emptySet());
396398
}
397399

400+
/**
401+
* Executes a reindex request.
402+
* See <a href="https://www.elastic.co/guide/en/elasticsearch/reference/current/docs-reindex.html">Reindex API on elastic.co</a>
403+
* @param reindexRequest the request
404+
* @param options the request options (e.g. headers), use {@link RequestOptions#DEFAULT} if nothing needs to be customized
405+
* @return the response
406+
* @throws IOException in case there is a problem sending the request or parsing back the response
407+
*/
408+
public final BulkByScrollResponse reindex(ReindexRequest reindexRequest, RequestOptions options) throws IOException {
409+
return performRequestAndParseEntity(
410+
reindexRequest, RequestConverters::reindex, options, BulkByScrollResponse::fromXContent, emptySet()
411+
);
412+
}
413+
414+
/**
415+
* Asynchronously executes a reindex request.
416+
* See <a href="https://www.elastic.co/guide/en/elasticsearch/reference/current/docs-reindex.html">Reindex API on elastic.co</a>
417+
* @param reindexRequest the request
418+
* @param options the request options (e.g. headers), use {@link RequestOptions#DEFAULT} if nothing needs to be customized
419+
* @param listener the listener to be notified upon request completion
420+
*/
421+
public final void reindexAsync(ReindexRequest reindexRequest, RequestOptions options, ActionListener<BulkByScrollResponse> listener) {
422+
performRequestAsyncAndParseEntity(
423+
reindexRequest, RequestConverters::reindex, options, BulkByScrollResponse::fromXContent, listener, emptySet()
424+
);
425+
}
426+
398427
/**
399428
* Pings the remote Elasticsearch cluster and returns true if the ping succeeded, false otherwise
400429
* @param options the request options (e.g. headers), use {@link RequestOptions#DEFAULT} if nothing needs to be customized
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,56 @@
1+
/*
2+
* Licensed to Elasticsearch under one or more contributor
3+
* license agreements. See the NOTICE file distributed with
4+
* this work for additional information regarding copyright
5+
* ownership. Elasticsearch licenses this file to you under
6+
* the Apache License, Version 2.0 (the "License"); you may
7+
* not use this file except in compliance with the License.
8+
* You may obtain a copy of the License at
9+
*
10+
* http://www.apache.org/licenses/LICENSE-2.0
11+
*
12+
* Unless required by applicable law or agreed to in writing,
13+
* software distributed under the License is distributed on an
14+
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
15+
* KIND, either express or implied. See the License for the
16+
* specific language governing permissions and limitations
17+
* under the License.
18+
*/
19+
package org.elasticsearch.client;
20+
21+
import org.elasticsearch.common.unit.TimeValue;
22+
23+
/**
24+
* A base request for any requests that supply timeouts.
25+
*
26+
* Please note, any requests that use a ackTimeout should set timeout as they
27+
* represent the same backing field on the server.
28+
*/
29+
public class TimedRequest implements Validatable {
30+
31+
private TimeValue timeout;
32+
private TimeValue masterTimeout;
33+
34+
public void setTimeout(TimeValue timeout) {
35+
this.timeout = timeout;
36+
37+
}
38+
39+
public void setMasterTimeout(TimeValue masterTimeout) {
40+
this.masterTimeout = masterTimeout;
41+
}
42+
43+
/**
44+
* Returns the request timeout
45+
*/
46+
public TimeValue timeout() {
47+
return timeout;
48+
}
49+
50+
/**
51+
* Returns the timeout for the request to be completed on the master node
52+
*/
53+
public TimeValue masterNodeTimeout() {
54+
return masterTimeout;
55+
}
56+
}

x-pack/protocol/src/main/java/org/elasticsearch/protocol/xpack/ml/AbstractResultResponse.java renamed to client/rest-high-level/src/main/java/org/elasticsearch/client/ml/AbstractResultResponse.java

+1-1
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@
1616
* specific language governing permissions and limitations
1717
* under the License.
1818
*/
19-
package org.elasticsearch.protocol.xpack.ml;
19+
package org.elasticsearch.client.ml;
2020

2121
import org.elasticsearch.action.ActionResponse;
2222
import org.elasticsearch.common.ParseField;

x-pack/protocol/src/main/java/org/elasticsearch/protocol/xpack/ml/CloseJobRequest.java renamed to client/rest-high-level/src/main/java/org/elasticsearch/client/ml/CloseJobRequest.java

+1-1
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@
1616
* specific language governing permissions and limitations
1717
* under the License.
1818
*/
19-
package org.elasticsearch.protocol.xpack.ml;
19+
package org.elasticsearch.client.ml;
2020

2121
import org.elasticsearch.action.ActionRequest;
2222
import org.elasticsearch.action.ActionRequestValidationException;

x-pack/protocol/src/main/java/org/elasticsearch/protocol/xpack/ml/CloseJobResponse.java renamed to client/rest-high-level/src/main/java/org/elasticsearch/client/ml/CloseJobResponse.java

+1-1
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@
1616
* specific language governing permissions and limitations
1717
* under the License.
1818
*/
19-
package org.elasticsearch.protocol.xpack.ml;
19+
package org.elasticsearch.client.ml;
2020

2121
import org.elasticsearch.action.ActionResponse;
2222
import org.elasticsearch.common.ParseField;

x-pack/protocol/src/main/java/org/elasticsearch/protocol/xpack/ml/DeleteJobRequest.java renamed to client/rest-high-level/src/main/java/org/elasticsearch/client/ml/DeleteJobRequest.java

+1-1
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@
1616
* specific language governing permissions and limitations
1717
* under the License.
1818
*/
19-
package org.elasticsearch.protocol.xpack.ml;
19+
package org.elasticsearch.client.ml;
2020

2121
import org.elasticsearch.action.ActionRequest;
2222
import org.elasticsearch.action.ActionRequestValidationException;

x-pack/protocol/src/main/java/org/elasticsearch/protocol/xpack/ml/DeleteJobResponse.java renamed to client/rest-high-level/src/main/java/org/elasticsearch/client/ml/DeleteJobResponse.java

+1-1
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@
1616
* specific language governing permissions and limitations
1717
* under the License.
1818
*/
19-
package org.elasticsearch.protocol.xpack.ml;
19+
package org.elasticsearch.client.ml;
2020

2121
import org.elasticsearch.action.support.master.AcknowledgedResponse;
2222
import org.elasticsearch.common.xcontent.XContentParser;

x-pack/protocol/src/main/java/org/elasticsearch/protocol/xpack/ml/GetBucketsRequest.java renamed to client/rest-high-level/src/main/java/org/elasticsearch/client/ml/GetBucketsRequest.java

+4-4
Original file line numberDiff line numberDiff line change
@@ -16,17 +16,17 @@
1616
* specific language governing permissions and limitations
1717
* under the License.
1818
*/
19-
package org.elasticsearch.protocol.xpack.ml;
19+
package org.elasticsearch.client.ml;
2020

2121
import org.elasticsearch.action.ActionRequest;
2222
import org.elasticsearch.action.ActionRequestValidationException;
23+
import org.elasticsearch.client.ml.job.config.Job;
24+
import org.elasticsearch.client.ml.job.results.Result;
25+
import org.elasticsearch.client.ml.job.util.PageParams;
2326
import org.elasticsearch.common.ParseField;
2427
import org.elasticsearch.common.xcontent.ObjectParser;
2528
import org.elasticsearch.common.xcontent.ToXContentObject;
2629
import org.elasticsearch.common.xcontent.XContentBuilder;
27-
import org.elasticsearch.protocol.xpack.ml.job.config.Job;
28-
import org.elasticsearch.protocol.xpack.ml.job.results.Result;
29-
import org.elasticsearch.protocol.xpack.ml.job.util.PageParams;
3030

3131
import java.io.IOException;
3232
import java.util.Objects;

0 commit comments

Comments
 (0)