Skip to content

Commit fd708ed

Browse files
author
Hendrik Muhs
committed
Merge branch 'master' of github.com:elastic/elasticsearch into feature/fib
2 parents d78d131 + 798fb54 commit fd708ed

File tree

472 files changed

+19813
-5173
lines changed

Some content is hidden

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

472 files changed

+19813
-5173
lines changed

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

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -782,9 +782,12 @@ class BuildPlugin implements Plugin<Project> {
782782
}
783783
}
784784

785-
// TODO: remove this once joda time is removed from scriptin in 7.0
785+
// TODO: remove this once joda time is removed from scripting in 7.0
786786
systemProperty 'es.scripting.use_java_time', 'true'
787787

788+
// TODO: remove this once ctx isn't added to update script params in 7.0
789+
systemProperty 'es.scripting.update.ctx_in_params', 'false'
790+
788791
// Set the system keystore/truststore password if we're running tests in a FIPS-140 JVM
789792
if (project.inFipsJvm) {
790793
systemProperty 'javax.net.ssl.trustStorePassword', 'password'

buildSrc/src/main/groovy/org/elasticsearch/gradle/doc/SnippetsTask.groovy

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -284,6 +284,10 @@ public class SnippetsTask extends DefaultTask {
284284
contents.append(line).append('\n')
285285
return
286286
}
287+
// Allow line continuations for console snippets within lists
288+
if (snippet != null && line.trim() == '+') {
289+
return
290+
}
287291
// Just finished
288292
emit()
289293
}

buildSrc/src/main/resources/checkstyle_suppressions.xml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -686,6 +686,7 @@
686686
<suppress files="modules[/\\]lang-expression[/\\]src[/\\]main[/\\]java[/\\]org[/\\]elasticsearch[/\\]script[/\\]expression[/\\]ExpressionScriptEngine.java" checks="LineLength" />
687687
<suppress files="modules[/\\]lang-expression[/\\]src[/\\]test[/\\]java[/\\]org[/\\]elasticsearch[/\\]script[/\\]expression[/\\]MoreExpressionTests.java" checks="LineLength" />
688688
<suppress files="modules[/\\]lang-expression[/\\]src[/\\]test[/\\]java[/\\]org[/\\]elasticsearch[/\\]script[/\\]expression[/\\]StoredExpressionTests.java" checks="LineLength" />
689+
<suppress files="modules[/\\]lang-painless[/\\]src[/\\]test[/\\]java[/\\]org[/\\]elasticsearch[/\\]painless[/\\]ContextExampleTests.java" checks="LineLength" />
689690
<suppress files="modules[/\\]reindex[/\\]src[/\\]main[/\\]java[/\\]org[/\\]elasticsearch[/\\]index[/\\]reindex[/\\]TransportUpdateByQueryAction.java" checks="LineLength" />
690691
<suppress files="plugins[/\\]analysis-icu[/\\]src[/\\]main[/\\]java[/\\]org[/\\]elasticsearch[/\\]index[/\\]analysis[/\\]IcuCollationTokenFilterFactory.java" checks="LineLength" />
691692
<suppress files="plugins[/\\]analysis-icu[/\\]src[/\\]main[/\\]java[/\\]org[/\\]elasticsearch[/\\]index[/\\]analysis[/\\]IcuFoldingTokenFilterFactory.java" checks="LineLength" />

buildSrc/version.properties

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,13 @@
11
elasticsearch = 7.0.0-alpha1
2-
lucene = 7.5.0-snapshot-608f0277b0
2+
lucene = 7.5.0-snapshot-13b9e28f9d
33

44
# optional dependencies
55
spatial4j = 0.7
66
jts = 1.15.0
7-
jackson = 2.8.10
7+
jackson = 2.8.11
88
snakeyaml = 1.17
99
# when updating log4j, please update also docs/java-api/index.asciidoc
10-
log4j = 2.9.1
10+
log4j = 2.11.1
1111
slf4j = 1.6.2
1212

1313
# when updating the JNA version, also update the version in buildSrc/build.gradle

client/rest-high-level/build.gradle

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,14 @@ apply plugin: 'com.github.johnrengelman.shadow'
3030
group = 'org.elasticsearch.client'
3131
archivesBaseName = 'elasticsearch-rest-high-level-client'
3232

33+
publishing {
34+
publications {
35+
nebula {
36+
artifactId = archivesBaseName
37+
}
38+
}
39+
}
40+
3341
//we need to copy the yaml spec so we can check naming (see RestHighlevelClientTests#testApiNamingConventions)
3442
Task copyRestSpec = RestIntegTestTask.createCopyRestSpecTask(project, Providers.FALSE)
3543
test.dependsOn(copyRestSpec)

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

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@
2626
import org.elasticsearch.action.ingest.PutPipelineRequest;
2727
import org.elasticsearch.action.ingest.SimulatePipelineRequest;
2828
import org.elasticsearch.action.ingest.SimulatePipelineResponse;
29-
import org.elasticsearch.action.ingest.WritePipelineResponse;
29+
import org.elasticsearch.action.support.master.AcknowledgedResponse;
3030

3131
import java.io.IOException;
3232

@@ -54,9 +54,9 @@ public final class IngestClient {
5454
* @return the response
5555
* @throws IOException in case there is a problem sending the request or parsing back the response
5656
*/
57-
public WritePipelineResponse putPipeline(PutPipelineRequest request, RequestOptions options) throws IOException {
57+
public AcknowledgedResponse putPipeline(PutPipelineRequest request, RequestOptions options) throws IOException {
5858
return restHighLevelClient.performRequestAndParseEntity( request, RequestConverters::putPipeline, options,
59-
WritePipelineResponse::fromXContent, emptySet());
59+
AcknowledgedResponse::fromXContent, emptySet());
6060
}
6161

6262
/**
@@ -67,9 +67,9 @@ public WritePipelineResponse putPipeline(PutPipelineRequest request, RequestOpti
6767
* @param options the request options (e.g. headers), use {@link RequestOptions#DEFAULT} if nothing needs to be customized
6868
* @param listener the listener to be notified upon request completion
6969
*/
70-
public void putPipelineAsync(PutPipelineRequest request, RequestOptions options, ActionListener<WritePipelineResponse> listener) {
70+
public void putPipelineAsync(PutPipelineRequest request, RequestOptions options, ActionListener<AcknowledgedResponse> listener) {
7171
restHighLevelClient.performRequestAsyncAndParseEntity( request, RequestConverters::putPipeline, options,
72-
WritePipelineResponse::fromXContent, listener, emptySet());
72+
AcknowledgedResponse::fromXContent, listener, emptySet());
7373
}
7474

7575
/**
@@ -109,9 +109,9 @@ public void getPipelineAsync(GetPipelineRequest request, RequestOptions options,
109109
* @return the response
110110
* @throws IOException in case there is a problem sending the request or parsing back the response
111111
*/
112-
public WritePipelineResponse deletePipeline(DeletePipelineRequest request, RequestOptions options) throws IOException {
112+
public AcknowledgedResponse deletePipeline(DeletePipelineRequest request, RequestOptions options) throws IOException {
113113
return restHighLevelClient.performRequestAndParseEntity( request, RequestConverters::deletePipeline, options,
114-
WritePipelineResponse::fromXContent, emptySet());
114+
AcknowledgedResponse::fromXContent, emptySet());
115115
}
116116

117117
/**
@@ -123,9 +123,9 @@ public WritePipelineResponse deletePipeline(DeletePipelineRequest request, Reque
123123
* @param options the request options (e.g. headers), use {@link RequestOptions#DEFAULT} if nothing needs to be customized
124124
* @param listener the listener to be notified upon request completion
125125
*/
126-
public void deletePipelineAsync(DeletePipelineRequest request, RequestOptions options, ActionListener<WritePipelineResponse> listener) {
126+
public void deletePipelineAsync(DeletePipelineRequest request, RequestOptions options, ActionListener<AcknowledgedResponse> listener) {
127127
restHighLevelClient.performRequestAsyncAndParseEntity( request, RequestConverters::deletePipeline, options,
128-
WritePipelineResponse::fromXContent, listener, emptySet());
128+
AcknowledgedResponse::fromXContent, listener, emptySet());
129129
}
130130

131131
/**

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

Lines changed: 70 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,11 +19,25 @@
1919

2020
package org.elasticsearch.client;
2121

22+
import org.apache.http.HttpEntity;
2223
import org.elasticsearch.action.ActionListener;
24+
import org.elasticsearch.common.Strings;
25+
import org.elasticsearch.common.io.Streams;
26+
import org.elasticsearch.common.xcontent.DeprecationHandler;
27+
import org.elasticsearch.common.xcontent.NamedXContentRegistry;
28+
import org.elasticsearch.common.xcontent.XContentBuilder;
29+
import org.elasticsearch.common.xcontent.XContentFactory;
30+
import org.elasticsearch.common.xcontent.XContentParser;
31+
import org.elasticsearch.common.xcontent.XContentType;
32+
import org.elasticsearch.protocol.xpack.license.GetLicenseRequest;
33+
import org.elasticsearch.protocol.xpack.license.GetLicenseResponse;
2334
import org.elasticsearch.protocol.xpack.license.PutLicenseRequest;
2435
import org.elasticsearch.protocol.xpack.license.PutLicenseResponse;
2536

2637
import java.io.IOException;
38+
import java.io.InputStream;
39+
import java.io.InputStreamReader;
40+
import java.nio.charset.StandardCharsets;
2741

2842
import static java.util.Collections.emptySet;
2943

@@ -54,7 +68,7 @@ public PutLicenseResponse putLicense(PutLicenseRequest request, RequestOptions o
5468
}
5569

5670
/**
57-
* Asynchronously updates license for the cluster cluster.
71+
* Asynchronously updates license for the cluster.
5872
* @param options the request options (e.g. headers), use {@link RequestOptions#DEFAULT} if nothing needs to be customized
5973
* @param listener the listener to be notified upon request completion
6074
*/
@@ -63,4 +77,59 @@ public void putLicenseAsync(PutLicenseRequest request, RequestOptions options, A
6377
PutLicenseResponse::fromXContent, listener, emptySet());
6478
}
6579

80+
/**
81+
* Returns the current license for the cluster.
82+
* @param options the request options (e.g. headers), use {@link RequestOptions#DEFAULT} if nothing needs to be customized
83+
* @return the response
84+
* @throws IOException in case there is a problem sending the request or parsing back the response
85+
*/
86+
public GetLicenseResponse getLicense(GetLicenseRequest request, RequestOptions options) throws IOException {
87+
return restHighLevelClient.performRequest(request, RequestConverters::getLicense, options,
88+
response -> new GetLicenseResponse(convertResponseToJson(response)), emptySet());
89+
}
90+
91+
/**
92+
* Asynchronously returns the current license for the cluster cluster.
93+
* @param options the request options (e.g. headers), use {@link RequestOptions#DEFAULT} if nothing needs to be customized
94+
* @param listener the listener to be notified upon request completion
95+
*/
96+
public void getLicenseAsync(GetLicenseRequest request, RequestOptions options, ActionListener<GetLicenseResponse> listener) {
97+
restHighLevelClient.performRequestAsync(request, RequestConverters::getLicense, options,
98+
response -> new GetLicenseResponse(convertResponseToJson(response)), listener, emptySet());
99+
}
100+
101+
102+
/**
103+
* Converts an entire response into a json sting
104+
*
105+
* This is useful for responses that we don't parse on the client side, but instead work as string
106+
* such as in case of the license JSON
107+
*/
108+
static String convertResponseToJson(Response response) throws IOException {
109+
HttpEntity entity = response.getEntity();
110+
if (entity == null) {
111+
throw new IllegalStateException("Response body expected but not returned");
112+
}
113+
if (entity.getContentType() == null) {
114+
throw new IllegalStateException("Elasticsearch didn't return the [Content-Type] header, unable to parse response body");
115+
}
116+
XContentType xContentType = XContentType.fromMediaTypeOrFormat(entity.getContentType().getValue());
117+
if (xContentType == null) {
118+
throw new IllegalStateException("Unsupported Content-Type: " + entity.getContentType().getValue());
119+
}
120+
if (xContentType == XContentType.JSON) {
121+
// No changes is required
122+
return Streams.copyToString(new InputStreamReader(response.getEntity().getContent(), StandardCharsets.UTF_8));
123+
} else {
124+
// Need to convert into JSON
125+
try (InputStream stream = response.getEntity().getContent();
126+
XContentParser parser = XContentFactory.xContent(xContentType).createParser(NamedXContentRegistry.EMPTY,
127+
DeprecationHandler.THROW_UNSUPPORTED_OPERATION, stream)) {
128+
parser.nextToken();
129+
XContentBuilder builder = XContentFactory.jsonBuilder();
130+
builder.copyCurrentStructure(parser);
131+
return Strings.toString(builder);
132+
}
133+
}
134+
}
66135
}

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

Lines changed: 19 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -107,10 +107,11 @@
107107
import org.elasticsearch.index.VersionType;
108108
import org.elasticsearch.index.rankeval.RankEvalRequest;
109109
import org.elasticsearch.protocol.xpack.XPackInfoRequest;
110+
import org.elasticsearch.protocol.xpack.license.GetLicenseRequest;
111+
import org.elasticsearch.protocol.xpack.license.PutLicenseRequest;
110112
import org.elasticsearch.protocol.xpack.watcher.DeleteWatchRequest;
111113
import org.elasticsearch.protocol.xpack.watcher.PutWatchRequest;
112114
import org.elasticsearch.protocol.xpack.XPackUsageRequest;
113-
import org.elasticsearch.protocol.xpack.license.PutLicenseRequest;
114115
import org.elasticsearch.rest.action.search.RestSearchAction;
115116
import org.elasticsearch.script.mustache.MultiSearchTemplateRequest;
116117
import org.elasticsearch.script.mustache.SearchTemplateRequest;
@@ -1154,7 +1155,11 @@ static Request xpackUsage(XPackUsageRequest usageRequest) {
11541155
}
11551156

11561157
static Request putLicense(PutLicenseRequest putLicenseRequest) {
1157-
Request request = new Request(HttpPut.METHOD_NAME, "/_xpack/license");
1158+
String endpoint = new EndpointBuilder()
1159+
.addPathPartAsIs("_xpack")
1160+
.addPathPartAsIs("license")
1161+
.build();
1162+
Request request = new Request(HttpPut.METHOD_NAME, endpoint);
11581163
Params parameters = new Params(request);
11591164
parameters.withTimeout(putLicenseRequest.timeout());
11601165
parameters.withMasterTimeout(putLicenseRequest.masterNodeTimeout());
@@ -1165,6 +1170,18 @@ static Request putLicense(PutLicenseRequest putLicenseRequest) {
11651170
return request;
11661171
}
11671172

1173+
1174+
static Request getLicense(GetLicenseRequest getLicenseRequest) {
1175+
String endpoint = new EndpointBuilder()
1176+
.addPathPartAsIs("_xpack")
1177+
.addPathPartAsIs("license")
1178+
.build();
1179+
Request request = new Request(HttpGet.METHOD_NAME, endpoint);
1180+
Params parameters = new Params(request);
1181+
parameters.withLocal(getLicenseRequest.local());
1182+
return request;
1183+
}
1184+
11681185
private static HttpEntity createEntity(ToXContent toXContent, XContentType xContentType) throws IOException {
11691186
BytesRef source = XContentHelper.toXContent(toXContent, xContentType, false).toBytesRef();
11701187
return new ByteArrayEntity(source.bytes, source.offset, source.length, createContentType(xContentType));

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

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -163,8 +163,11 @@
163163
import org.elasticsearch.search.aggregations.pipeline.derivative.ParsedDerivative;
164164
import org.elasticsearch.search.suggest.Suggest;
165165
import org.elasticsearch.search.suggest.completion.CompletionSuggestion;
166+
import org.elasticsearch.search.suggest.completion.CompletionSuggestionBuilder;
166167
import org.elasticsearch.search.suggest.phrase.PhraseSuggestion;
168+
import org.elasticsearch.search.suggest.phrase.PhraseSuggestionBuilder;
167169
import org.elasticsearch.search.suggest.term.TermSuggestion;
170+
import org.elasticsearch.search.suggest.term.TermSuggestionBuilder;
168171

169172
import java.io.Closeable;
170173
import java.io.IOException;
@@ -1141,11 +1144,11 @@ static List<NamedXContentRegistry.Entry> getDefaultNamedXContents() {
11411144
List<NamedXContentRegistry.Entry> entries = map.entrySet().stream()
11421145
.map(entry -> new NamedXContentRegistry.Entry(Aggregation.class, new ParseField(entry.getKey()), entry.getValue()))
11431146
.collect(Collectors.toList());
1144-
entries.add(new NamedXContentRegistry.Entry(Suggest.Suggestion.class, new ParseField(TermSuggestion.NAME),
1147+
entries.add(new NamedXContentRegistry.Entry(Suggest.Suggestion.class, new ParseField(TermSuggestionBuilder.SUGGESTION_NAME),
11451148
(parser, context) -> TermSuggestion.fromXContent(parser, (String)context)));
1146-
entries.add(new NamedXContentRegistry.Entry(Suggest.Suggestion.class, new ParseField(PhraseSuggestion.NAME),
1149+
entries.add(new NamedXContentRegistry.Entry(Suggest.Suggestion.class, new ParseField(PhraseSuggestionBuilder.SUGGESTION_NAME),
11471150
(parser, context) -> PhraseSuggestion.fromXContent(parser, (String)context)));
1148-
entries.add(new NamedXContentRegistry.Entry(Suggest.Suggestion.class, new ParseField(CompletionSuggestion.NAME),
1151+
entries.add(new NamedXContentRegistry.Entry(Suggest.Suggestion.class, new ParseField(CompletionSuggestionBuilder.SUGGESTION_NAME),
11491152
(parser, context) -> CompletionSuggestion.fromXContent(parser, (String)context)));
11501153
return entries;
11511154
}

client/rest-high-level/src/test/java/org/elasticsearch/client/IngestClientIT.java

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@
2828
import org.elasticsearch.action.ingest.SimulateDocumentVerboseResult;
2929
import org.elasticsearch.action.ingest.SimulatePipelineRequest;
3030
import org.elasticsearch.action.ingest.SimulatePipelineResponse;
31-
import org.elasticsearch.action.ingest.WritePipelineResponse;
31+
import org.elasticsearch.action.support.master.AcknowledgedResponse;
3232
import org.elasticsearch.common.bytes.BytesReference;
3333
import org.elasticsearch.common.xcontent.XContentBuilder;
3434
import org.elasticsearch.common.xcontent.XContentType;
@@ -50,7 +50,7 @@ public void testPutPipeline() throws IOException {
5050
BytesReference.bytes(pipelineBuilder),
5151
pipelineBuilder.contentType());
5252

53-
WritePipelineResponse putPipelineResponse =
53+
AcknowledgedResponse putPipelineResponse =
5454
execute(request, highLevelClient().ingest()::putPipeline, highLevelClient().ingest()::putPipelineAsync);
5555
assertTrue(putPipelineResponse.isAcknowledged());
5656
}
@@ -86,7 +86,7 @@ public void testDeletePipeline() throws IOException {
8686

8787
DeletePipelineRequest request = new DeletePipelineRequest(id);
8888

89-
WritePipelineResponse response =
89+
AcknowledgedResponse response =
9090
execute(request, highLevelClient().ingest()::deletePipeline, highLevelClient().ingest()::deletePipelineAsync);
9191
assertTrue(response.isAcknowledged());
9292
}

client/rest-high-level/src/test/java/org/elasticsearch/client/documentation/IngestClientDocumentationIT.java

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@
3131
import org.elasticsearch.action.ingest.SimulatePipelineRequest;
3232
import org.elasticsearch.action.ingest.SimulatePipelineResponse;
3333
import org.elasticsearch.action.ingest.SimulateProcessorResult;
34-
import org.elasticsearch.action.ingest.WritePipelineResponse;
34+
import org.elasticsearch.action.support.master.AcknowledgedResponse;
3535
import org.elasticsearch.client.ESRestHighLevelClientTestCase;
3636
import org.elasticsearch.client.RequestOptions;
3737
import org.elasticsearch.client.RestHighLevelClient;
@@ -93,7 +93,7 @@ public void testPutPipeline() throws IOException {
9393
// end::put-pipeline-request-masterTimeout
9494

9595
// tag::put-pipeline-execute
96-
WritePipelineResponse response = client.ingest().putPipeline(request, RequestOptions.DEFAULT); // <1>
96+
AcknowledgedResponse response = client.ingest().putPipeline(request, RequestOptions.DEFAULT); // <1>
9797
// end::put-pipeline-execute
9898

9999
// tag::put-pipeline-response
@@ -117,10 +117,10 @@ public void testPutPipelineAsync() throws Exception {
117117
);
118118

119119
// tag::put-pipeline-execute-listener
120-
ActionListener<WritePipelineResponse> listener =
121-
new ActionListener<WritePipelineResponse>() {
120+
ActionListener<AcknowledgedResponse> listener =
121+
new ActionListener<AcknowledgedResponse>() {
122122
@Override
123-
public void onResponse(WritePipelineResponse response) {
123+
public void onResponse(AcknowledgedResponse response) {
124124
// <1>
125125
}
126126

@@ -236,7 +236,7 @@ public void testDeletePipeline() throws IOException {
236236
// end::delete-pipeline-request-masterTimeout
237237

238238
// tag::delete-pipeline-execute
239-
WritePipelineResponse response = client.ingest().deletePipeline(request, RequestOptions.DEFAULT); // <1>
239+
AcknowledgedResponse response = client.ingest().deletePipeline(request, RequestOptions.DEFAULT); // <1>
240240
// end::delete-pipeline-execute
241241

242242
// tag::delete-pipeline-response
@@ -257,10 +257,10 @@ public void testDeletePipelineAsync() throws Exception {
257257
DeletePipelineRequest request = new DeletePipelineRequest("my-pipeline-id");
258258

259259
// tag::delete-pipeline-execute-listener
260-
ActionListener<WritePipelineResponse> listener =
261-
new ActionListener<WritePipelineResponse>() {
260+
ActionListener<AcknowledgedResponse> listener =
261+
new ActionListener<AcknowledgedResponse>() {
262262
@Override
263-
public void onResponse(WritePipelineResponse response) {
263+
public void onResponse(AcknowledgedResponse response) {
264264
// <1>
265265
}
266266

0 commit comments

Comments
 (0)