Skip to content

Commit 01b3be9

Browse files
committed
Merge remote-tracking branch 'elastic/master' into zen2
2 parents 31e8781 + e77835c commit 01b3be9

File tree

169 files changed

+8173
-2305
lines changed

Some content is hidden

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

169 files changed

+8173
-2305
lines changed

.ci/packer_cache.sh

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
#!/bin/bash
2+
3+
SCRIPT="$0"
4+
5+
# SCRIPT might be an arbitrarily deep series of symbolic links; loop until we
6+
# have the concrete path
7+
while [ -h "$SCRIPT" ] ; do
8+
ls=$(ls -ld "$SCRIPT")
9+
# Drop everything prior to ->
10+
link=$(expr "$ls" : '.*-> \(.*\)$')
11+
if expr "$link" : '/.*' > /dev/null; then
12+
SCRIPT="$link"
13+
else
14+
SCRIPT=$(dirname "$SCRIPT")/"$link"
15+
fi
16+
done
17+
18+
source $(dirname "${SCRIPT}")/java-versions.properties
19+
JAVA_HOME="${HOME}"/.java/${ES_BUILD_JAVA} ./gradlew resolveAllDependencies --parallel

build.gradle

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -628,3 +628,11 @@ if (System.properties.get("build.compare") != null) {
628628
}
629629
}
630630
}
631+
632+
allprojects {
633+
task resolveAllDependencies {
634+
doLast {
635+
configurations.findAll { it.isCanBeResolved() }.each { it.resolve() }
636+
}
637+
}
638+
}

buildSrc/src/main/groovy/org/elasticsearch/gradle/BuildPlugin.groovy

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -825,9 +825,6 @@ class BuildPlugin implements Plugin<Project> {
825825
}
826826
}
827827

828-
// TODO: remove this once joda time is removed from scripting in 7.0
829-
systemProperty 'es.scripting.use_java_time', 'true'
830-
831828
// TODO: remove this once ctx isn't added to update script params in 7.0
832829
systemProperty 'es.scripting.update.ctx_in_params', 'false'
833830

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

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,13 +35,15 @@
3535
import org.elasticsearch.client.ml.ForecastJobRequest;
3636
import org.elasticsearch.client.ml.GetBucketsRequest;
3737
import org.elasticsearch.client.ml.GetCategoriesRequest;
38+
import org.elasticsearch.client.ml.GetDatafeedRequest;
3839
import org.elasticsearch.client.ml.GetInfluencersRequest;
3940
import org.elasticsearch.client.ml.GetJobRequest;
4041
import org.elasticsearch.client.ml.GetJobStatsRequest;
4142
import org.elasticsearch.client.ml.GetOverallBucketsRequest;
4243
import org.elasticsearch.client.ml.GetRecordsRequest;
4344
import org.elasticsearch.client.ml.OpenJobRequest;
4445
import org.elasticsearch.client.ml.PostDataRequest;
46+
import org.elasticsearch.client.ml.PutCalendarRequest;
4547
import org.elasticsearch.client.ml.PutDatafeedRequest;
4648
import org.elasticsearch.client.ml.PutJobRequest;
4749
import org.elasticsearch.client.ml.UpdateJobRequest;
@@ -196,6 +198,24 @@ static Request putDatafeed(PutDatafeedRequest putDatafeedRequest) throws IOExcep
196198
return request;
197199
}
198200

201+
static Request getDatafeed(GetDatafeedRequest getDatafeedRequest) {
202+
String endpoint = new EndpointBuilder()
203+
.addPathPartAsIs("_xpack")
204+
.addPathPartAsIs("ml")
205+
.addPathPartAsIs("datafeeds")
206+
.addPathPart(Strings.collectionToCommaDelimitedString(getDatafeedRequest.getDatafeedIds()))
207+
.build();
208+
Request request = new Request(HttpGet.METHOD_NAME, endpoint);
209+
210+
RequestConverters.Params params = new RequestConverters.Params(request);
211+
if (getDatafeedRequest.isAllowNoDatafeeds() != null) {
212+
params.putParam(GetDatafeedRequest.ALLOW_NO_DATAFEEDS.getPreferredName(),
213+
Boolean.toString(getDatafeedRequest.isAllowNoDatafeeds()));
214+
}
215+
216+
return request;
217+
}
218+
199219
static Request deleteDatafeed(DeleteDatafeedRequest deleteDatafeedRequest) {
200220
String endpoint = new EndpointBuilder()
201221
.addPathPartAsIs("_xpack")
@@ -327,4 +347,16 @@ static Request getInfluencers(GetInfluencersRequest getInfluencersRequest) throw
327347
request.setEntity(createEntity(getInfluencersRequest, REQUEST_BODY_CONTENT_TYPE));
328348
return request;
329349
}
350+
351+
static Request putCalendar(PutCalendarRequest putCalendarRequest) throws IOException {
352+
String endpoint = new EndpointBuilder()
353+
.addPathPartAsIs("_xpack")
354+
.addPathPartAsIs("ml")
355+
.addPathPartAsIs("calendars")
356+
.addPathPart(putCalendarRequest.getCalendar().getId())
357+
.build();
358+
Request request = new Request(HttpPut.METHOD_NAME, endpoint);
359+
request.setEntity(createEntity(putCalendarRequest, REQUEST_BODY_CONTENT_TYPE));
360+
return request;
361+
}
330362
}

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

Lines changed: 285 additions & 223 deletions
Large diffs are not rendered by default.

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

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -219,6 +219,7 @@ public class RestHighLevelClient implements Closeable {
219219
private final MigrationClient migrationClient = new MigrationClient(this);
220220
private final MachineLearningClient machineLearningClient = new MachineLearningClient(this);
221221
private final SecurityClient securityClient = new SecurityClient(this);
222+
private final RollupClient rollupClient = new RollupClient(this);
222223

223224
/**
224225
* Creates a {@link RestHighLevelClient} given the low level {@link RestClientBuilder} that allows to build the
@@ -300,6 +301,18 @@ public final SnapshotClient snapshot() {
300301
return snapshotClient;
301302
}
302303

304+
/**
305+
* Provides methods for accessing the Elastic Licensed Rollup APIs that
306+
* are shipped with the default distribution of Elasticsearch. All of
307+
* these APIs will 404 if run against the OSS distribution of Elasticsearch.
308+
* <p>
309+
* See the <a href="https://www.elastic.co/guide/en/elasticsearch/reference/current/rollup-apis.html">
310+
* Watcher APIs on elastic.co</a> for more information.
311+
*/
312+
public RollupClient rollup() {
313+
return rollupClient;
314+
}
315+
303316
/**
304317
* Provides a {@link TasksClient} which can be used to access the Tasks API.
305318
*
Lines changed: 76 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,76 @@
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+
20+
package org.elasticsearch.client;
21+
22+
import org.elasticsearch.action.ActionListener;
23+
import org.elasticsearch.client.rollup.PutRollupJobRequest;
24+
import org.elasticsearch.client.rollup.PutRollupJobResponse;
25+
26+
import java.io.IOException;
27+
import java.util.Collections;
28+
29+
/**
30+
* A wrapper for the {@link RestHighLevelClient} that provides methods for
31+
* accessing the Elastic Rollup-related methods
32+
* <p>
33+
* See the <a href="https://www.elastic.co/guide/en/elasticsearch/reference/current/rollup-apis.html">
34+
* X-Pack Rollup APIs on elastic.co</a> for more information.
35+
*/
36+
public class RollupClient {
37+
38+
private final RestHighLevelClient restHighLevelClient;
39+
40+
RollupClient(final RestHighLevelClient restHighLevelClient) {
41+
this.restHighLevelClient = restHighLevelClient;
42+
}
43+
44+
/**
45+
* Put a rollup job into the cluster
46+
* See <a href="https://www.elastic.co/guide/en/elasticsearch/reference/current/rollup-put-job.html">
47+
* the docs</a> for more.
48+
* @param request the request
49+
* @param options the request options (e.g. headers), use {@link RequestOptions#DEFAULT} if nothing needs to be customized
50+
* @return the response
51+
* @throws IOException in case there is a problem sending the request or parsing back the response
52+
*/
53+
public PutRollupJobResponse putRollupJob(PutRollupJobRequest request, RequestOptions options) throws IOException {
54+
return restHighLevelClient.performRequestAndParseEntity(request,
55+
RollupRequestConverters::putJob,
56+
options,
57+
PutRollupJobResponse::fromXContent,
58+
Collections.emptySet());
59+
}
60+
61+
/**
62+
* Asynchronously put a rollup job into the cluster
63+
* See <a href="https://www.elastic.co/guide/en/elasticsearch/reference/current/rollup-put-job.html">
64+
* the docs</a> for more.
65+
* @param request the request
66+
* @param options the request options (e.g. headers), use {@link RequestOptions#DEFAULT} if nothing needs to be customized
67+
* @param listener the listener to be notified upon request completion
68+
*/
69+
public void putRollupJobAsync(PutRollupJobRequest request, RequestOptions options, ActionListener<PutRollupJobResponse> listener) {
70+
restHighLevelClient.performRequestAsyncAndParseEntity(request,
71+
RollupRequestConverters::putJob,
72+
options,
73+
PutRollupJobResponse::fromXContent,
74+
listener, Collections.emptySet());
75+
}
76+
}
Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
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.apache.http.client.methods.HttpPut;
22+
import org.elasticsearch.client.rollup.PutRollupJobRequest;
23+
24+
import java.io.IOException;
25+
26+
import static org.elasticsearch.client.RequestConverters.REQUEST_BODY_CONTENT_TYPE;
27+
import static org.elasticsearch.client.RequestConverters.createEntity;
28+
29+
final class RollupRequestConverters {
30+
31+
private RollupRequestConverters() {
32+
}
33+
34+
static Request putJob(final PutRollupJobRequest putRollupJobRequest) throws IOException {
35+
String endpoint = new RequestConverters.EndpointBuilder()
36+
.addPathPartAsIs("_xpack")
37+
.addPathPartAsIs("rollup")
38+
.addPathPartAsIs("job")
39+
.addPathPart(putRollupJobRequest.getConfig().getId())
40+
.build();
41+
Request request = new Request(HttpPut.METHOD_NAME, endpoint);
42+
request.setEntity(createEntity(putRollupJobRequest, REQUEST_BODY_CONTENT_TYPE));
43+
return request;
44+
}
45+
}

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

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,8 @@
1818
*/
1919
package org.elasticsearch.client;
2020

21+
import org.elasticsearch.common.Nullable;
22+
2123
import java.util.ArrayList;
2224
import java.util.List;
2325

@@ -31,10 +33,23 @@ public class ValidationException extends IllegalArgumentException {
3133
* Add a new validation error to the accumulating validation errors
3234
* @param error the error to add
3335
*/
34-
public void addValidationError(String error) {
36+
public void addValidationError(final String error) {
3537
validationErrors.add(error);
3638
}
3739

40+
/**
41+
* Adds validation errors from an existing {@link ValidationException} to
42+
* the accumulating validation errors
43+
* @param exception the {@link ValidationException} to add errors from
44+
*/
45+
public final void addValidationErrors(final @Nullable ValidationException exception) {
46+
if (exception != null) {
47+
for (String error : exception.validationErrors()) {
48+
addValidationError(error);
49+
}
50+
}
51+
}
52+
3853
/**
3954
* Returns the validation errors accumulated
4055
*/

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -136,9 +136,9 @@ public Boolean isAllowNoJobs() {
136136
/**
137137
* Whether to ignore if a wildcard expression matches no jobs.
138138
*
139-
* This includes `_all` string or when no jobs have been specified
139+
* This includes {@code _all} string or when no jobs have been specified
140140
*
141-
* @param allowNoJobs When {@code true} ignore if wildcard or `_all` matches no jobs. Defaults to {@code true}
141+
* @param allowNoJobs When {@code true} ignore if wildcard or {@code _all} matches no jobs. Defaults to {@code true}
142142
*/
143143
public void setAllowNoJobs(boolean allowNoJobs) {
144144
this.allowNoJobs = allowNoJobs;

0 commit comments

Comments
 (0)