Skip to content

Commit fd4397e

Browse files
committed
Merge branch '6.x' into ccr-6.x
* 6.x: Fix forbidden apis on FIPS (#33202) HLRC: Add ML Get Records API (#33085) [ML] Fix character set finder bug with unencodable charsets (#33234) Tests fix - Graph HLRC client overly long line and syncing core’s copy of GraphExploreResponseTests taken from protocol. Related to #33231 Test fix - Graph HLRC test was missing field name to be excluded from randomisation logic Parse PEM Key files leniantly (#33173) Core: Add java time xcontent serializers (#33120) Consider multi release jars when running third party audit (#33206) Update MSI documentation (#31950) [DOCS] Fixes command page titles HLRC: Move ML protocol classes into client ml package (#33203) Painless: Fix Semicolon Regression (#33212)
2 parents 648c149 + b5345b0 commit fd4397e

File tree

144 files changed

+2031
-1059
lines changed

Some content is hidden

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

144 files changed

+2031
-1059
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
}

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;

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

+2-2
Original file line numberDiff line numberDiff line change
@@ -16,12 +16,12 @@
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

21+
import org.elasticsearch.client.ml.job.results.Bucket;
2122
import org.elasticsearch.common.ParseField;
2223
import org.elasticsearch.common.xcontent.ConstructingObjectParser;
2324
import org.elasticsearch.common.xcontent.XContentParser;
24-
import org.elasticsearch.protocol.xpack.ml.job.results.Bucket;
2525

2626
import java.io.IOException;
2727
import java.util.List;

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

+4-3
Original file line numberDiff line numberDiff line change
@@ -16,10 +16,11 @@
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;
2324
import org.elasticsearch.common.ParseField;
2425
import org.elasticsearch.common.xcontent.ConstructingObjectParser;
2526
import org.elasticsearch.common.xcontent.ToXContentObject;
@@ -32,7 +33,7 @@
3233
import java.util.Objects;
3334

3435
/**
35-
* Request object to get {@link org.elasticsearch.protocol.xpack.ml.job.config.Job} objects with the matching `jobId`s or
36+
* Request object to get {@link Job} objects with the matching `jobId`s or
3637
* `groupName`s.
3738
*
3839
* `_all` explicitly gets all the jobs in the cluster
@@ -66,7 +67,7 @@ public static GetJobRequest getAllJobsRequest() {
6667
}
6768

6869
/**
69-
* Get the specified {@link org.elasticsearch.protocol.xpack.ml.job.config.Job} configurations via their unique jobIds
70+
* Get the specified {@link Job} configurations via their unique jobIds
7071
* @param jobIds must not contain any null values
7172
*/
7273
public GetJobRequest(String... jobIds) {

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

+2-2
Original file line numberDiff line numberDiff line change
@@ -16,13 +16,13 @@
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

21+
import org.elasticsearch.client.ml.job.config.Job;
2122
import org.elasticsearch.common.ParseField;
2223
import org.elasticsearch.common.Strings;
2324
import org.elasticsearch.common.xcontent.ConstructingObjectParser;
2425
import org.elasticsearch.common.xcontent.XContentParser;
25-
import org.elasticsearch.protocol.xpack.ml.job.config.Job;
2626

2727
import java.io.IOException;
2828
import java.util.List;

0 commit comments

Comments
 (0)