Skip to content

Commit 3f92d32

Browse files
Merge remote-tracking branch 'elastic/master' into repo-setting-fixes
2 parents 485f7bd + ed297b7 commit 3f92d32

File tree

774 files changed

+18745
-8405
lines changed

Some content is hidden

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

774 files changed

+18745
-8405
lines changed

buildSrc/src/main/resources/checkstyle_suppressions.xml

-8
Original file line numberDiff line numberDiff line change
@@ -46,14 +46,6 @@
4646
<suppress files="client[/\\]rest-high-level[/\\]src[/\\]test[/\\]java[/\\]org[/\\]elasticsearch[/\\]client[/\\]documentation[/\\]WatcherDocumentationIT.java" id="SnippetLength" />
4747
<suppress files="modules[/\\]reindex[/\\]src[/\\]test[/\\]java[/\\]org[/\\]elasticsearch[/\\]client[/\\]documentation[/\\]ReindexDocumentationIT.java" id="SnippetLength" />
4848

49-
<!-- Hopefully temporary suppression of LineLength on files that don't pass it. We should remove these when we the
50-
files start to pass. -->
51-
<suppress files="server[/\\]src[/\\]main[/\\]java[/\\]org[/\\]elasticsearch[/\\]monitor[/\\]jvm[/\\]GcNames.java" checks="LineLength" />
52-
<suppress files="server[/\\]src[/\\]main[/\\]java[/\\]org[/\\]elasticsearch[/\\]monitor[/\\]jvm[/\\]HotThreads.java" checks="LineLength" />
53-
<suppress files="server[/\\]src[/\\]main[/\\]java[/\\]org[/\\]elasticsearch[/\\]node[/\\]Node.java" checks="LineLength" />
54-
<suppress files="server[/\\]src[/\\]test[/\\]java[/\\]org[/\\]elasticsearch[/\\]aliases[/\\]IndexAliasesIT.java" checks="LineLength" />
55-
<suppress files="server[/\\]src[/\\]test[/\\]java[/\\]org[/\\]elasticsearch[/\\]monitor[/\\]jvm[/\\]JvmGcMonitorServiceSettingsTests.java" checks="LineLength" />
56-
5749
<!-- Gradle requires inputs to be seriablizable -->
5850
<suppress files="buildSrc[/\\]src[/\\]main[/\\]java[/\\]org[/\\]elasticsearch[/\\]gradle[/\\]precommit[/\\]TestingConventionRule.java" checks="RegexpSinglelineJava" />
5951
</suppressions>

buildSrc/src/main/resources/forbidden/es-all-signatures.txt

+13
Original file line numberDiff line numberDiff line change
@@ -50,3 +50,16 @@ java.nio.channels.SocketChannel#connect(java.net.SocketAddress)
5050
java.lang.Boolean#getBoolean(java.lang.String)
5151

5252
org.apache.lucene.util.IOUtils @ use @org.elasticsearch.core.internal.io instead
53+
54+
@defaultMessage use executors from org.elasticsearch.common.util.concurrent.EsExecutors instead which will properly bubble up Errors
55+
java.util.concurrent.AbstractExecutorService#<init>()
56+
java.util.concurrent.ThreadPoolExecutor#<init>(int, int, long, java.util.concurrent.TimeUnit, java.util.concurrent.BlockingQueue)
57+
java.util.concurrent.ThreadPoolExecutor#<init>(int, int, long, java.util.concurrent.TimeUnit, java.util.concurrent.BlockingQueue, java.util.concurrent.ThreadFactory)
58+
java.util.concurrent.ThreadPoolExecutor#<init>(int, int, long, java.util.concurrent.TimeUnit, java.util.concurrent.BlockingQueue, java.util.concurrent.RejectedExecutionHandler)
59+
java.util.concurrent.ThreadPoolExecutor#<init>(int, int, long, java.util.concurrent.TimeUnit, java.util.concurrent.BlockingQueue, java.util.concurrent.ThreadFactory, java.util.concurrent.RejectedExecutionHandler)
60+
61+
@defaultMessage extend org.elasticsearch.threadpool.Scheduler.SafeScheduledThreadPoolExecutor instead which will properly bubble up Errors
62+
java.util.concurrent.ScheduledThreadPoolExecutor#<init>(int)
63+
java.util.concurrent.ScheduledThreadPoolExecutor#<init>(int, java.util.concurrent.ThreadFactory)
64+
java.util.concurrent.ScheduledThreadPoolExecutor#<init>(int, java.util.concurrent.RejectedExecutionHandler)
65+
java.util.concurrent.ScheduledThreadPoolExecutor#<init>(int, java.util.concurrent.ThreadFactory, java.util.concurrent.RejectedExecutionHandler)
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
5.1
1+
5.1.1

client/rest-high-level/build.gradle

+1-1
Original file line numberDiff line numberDiff line change
@@ -105,7 +105,7 @@ integTestCluster {
105105
setting 'xpack.security.enabled', 'true'
106106
setting 'xpack.security.authc.token.enabled', 'true'
107107
// Truststore settings are not used since TLS is not enabled. Included for testing the get certificates API
108-
setting 'xpack.ssl.certificate_authorities', 'testnode.crt'
108+
setting 'xpack.security.http.ssl.certificate_authorities', 'testnode.crt'
109109
setting 'xpack.security.transport.ssl.truststore.path', 'testnode.jks'
110110
keystoreSetting 'xpack.security.transport.ssl.truststore.secure_password', 'testnode'
111111
setupCommand 'setupDummyUser',

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

+9
Original file line numberDiff line numberDiff line change
@@ -57,6 +57,8 @@
5757
import java.io.IOException;
5858
import java.util.Locale;
5959

60+
import static org.elasticsearch.rest.BaseRestHandler.INCLUDE_TYPE_NAME_PARAMETER;
61+
6062
final class IndicesRequestConverters {
6163

6264
private IndicesRequestConverters() {}
@@ -103,6 +105,7 @@ static Request createIndex(CreateIndexRequest createIndexRequest) throws IOExcep
103105
parameters.withTimeout(createIndexRequest.timeout());
104106
parameters.withMasterTimeout(createIndexRequest.masterNodeTimeout());
105107
parameters.withWaitForActiveShards(createIndexRequest.waitForActiveShards());
108+
parameters.putParam(INCLUDE_TYPE_NAME_PARAMETER, "true");
106109

107110
request.setEntity(RequestConverters.createEntity(createIndexRequest, RequestConverters.REQUEST_BODY_CONTENT_TYPE));
108111
return request;
@@ -131,6 +134,7 @@ static Request putMapping(PutMappingRequest putMappingRequest) throws IOExceptio
131134
RequestConverters.Params parameters = new RequestConverters.Params(request);
132135
parameters.withTimeout(putMappingRequest.timeout());
133136
parameters.withMasterTimeout(putMappingRequest.masterNodeTimeout());
137+
parameters.putParam(INCLUDE_TYPE_NAME_PARAMETER, "true");
134138

135139
request.setEntity(RequestConverters.createEntity(putMappingRequest, RequestConverters.REQUEST_BODY_CONTENT_TYPE));
136140
return request;
@@ -146,6 +150,7 @@ static Request getMappings(GetMappingsRequest getMappingsRequest) throws IOExcep
146150
parameters.withMasterTimeout(getMappingsRequest.masterNodeTimeout());
147151
parameters.withIndicesOptions(getMappingsRequest.indicesOptions());
148152
parameters.withLocal(getMappingsRequest.local());
153+
149154
return request;
150155
}
151156

@@ -165,6 +170,8 @@ static Request getFieldMapping(GetFieldMappingsRequest getFieldMappingsRequest)
165170
parameters.withIndicesOptions(getFieldMappingsRequest.indicesOptions());
166171
parameters.withIncludeDefaults(getFieldMappingsRequest.includeDefaults());
167172
parameters.withLocal(getFieldMappingsRequest.local());
173+
parameters.putParam(INCLUDE_TYPE_NAME_PARAMETER, "true");
174+
168175
return request;
169176
}
170177

@@ -357,6 +364,7 @@ static Request putTemplate(PutIndexTemplateRequest putIndexTemplateRequest) thro
357364
if (Strings.hasText(putIndexTemplateRequest.cause())) {
358365
params.putParam("cause", putIndexTemplateRequest.cause());
359366
}
367+
params.putParam(INCLUDE_TYPE_NAME_PARAMETER, "true");
360368
request.setEntity(RequestConverters.createEntity(putIndexTemplateRequest, RequestConverters.REQUEST_BODY_CONTENT_TYPE));
361369
return request;
362370
}
@@ -395,6 +403,7 @@ static Request getTemplates(GetIndexTemplatesRequest getIndexTemplatesRequest) {
395403
final RequestConverters.Params params = new RequestConverters.Params(request);
396404
params.withLocal(getIndexTemplatesRequest.isLocal());
397405
params.withMasterTimeout(getIndexTemplatesRequest.getMasterNodeTimeout());
406+
params.putParam(INCLUDE_TYPE_NAME_PARAMETER, "true");
398407
return request;
399408
}
400409

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

+4-1
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,10 @@ public List<NamedXContentRegistry.Entry> getNamedXContentParsers() {
5353
ShrinkAction::parse),
5454
new NamedXContentRegistry.Entry(LifecycleAction.class,
5555
new ParseField(FreezeAction.NAME),
56-
FreezeAction::parse)
56+
FreezeAction::parse),
57+
new NamedXContentRegistry.Entry(LifecycleAction.class,
58+
new ParseField(SetPriorityAction.NAME),
59+
SetPriorityAction::parse)
5760
);
5861
}
5962
}

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

+4-3
Original file line numberDiff line numberDiff line change
@@ -57,9 +57,10 @@ public class LifecyclePolicy implements ToXContentObject {
5757
throw new IllegalArgumentException("ordered " + PHASES_FIELD.getPreferredName() + " are not supported");
5858
}, PHASES_FIELD);
5959

60-
ALLOWED_ACTIONS.put("hot", Sets.newHashSet(RolloverAction.NAME));
61-
ALLOWED_ACTIONS.put("warm", Sets.newHashSet(AllocateAction.NAME, ForceMergeAction.NAME, ReadOnlyAction.NAME, ShrinkAction.NAME));
62-
ALLOWED_ACTIONS.put("cold", Sets.newHashSet(AllocateAction.NAME, FreezeAction.NAME));
60+
ALLOWED_ACTIONS.put("hot", Sets.newHashSet(SetPriorityAction.NAME, RolloverAction.NAME));
61+
ALLOWED_ACTIONS.put("warm", Sets.newHashSet(SetPriorityAction.NAME, AllocateAction.NAME, ForceMergeAction.NAME,
62+
ReadOnlyAction.NAME, ShrinkAction.NAME));
63+
ALLOWED_ACTIONS.put("cold", Sets.newHashSet(SetPriorityAction.NAME, AllocateAction.NAME, FreezeAction.NAME));
6364
ALLOWED_ACTIONS.put("delete", Sets.newHashSet(DeleteAction.NAME));
6465
}
6566

Original file line numberDiff line numberDiff line change
@@ -0,0 +1,96 @@
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.indexlifecycle;
20+
21+
import org.elasticsearch.common.Nullable;
22+
import org.elasticsearch.common.ParseField;
23+
import org.elasticsearch.common.Strings;
24+
import org.elasticsearch.common.xcontent.ConstructingObjectParser;
25+
import org.elasticsearch.common.xcontent.ObjectParser;
26+
import org.elasticsearch.common.xcontent.ToXContent;
27+
import org.elasticsearch.common.xcontent.ToXContentObject;
28+
import org.elasticsearch.common.xcontent.XContentBuilder;
29+
import org.elasticsearch.common.xcontent.XContentParser;
30+
31+
import java.io.IOException;
32+
33+
/**
34+
* A {@link LifecycleAction} which sets the index's priority. The higher the priority, the faster the recovery.
35+
*/
36+
public class SetPriorityAction implements LifecycleAction, ToXContentObject {
37+
public static final String NAME = "set_priority";
38+
private static final ParseField RECOVERY_PRIORITY_FIELD = new ParseField("priority");
39+
40+
@SuppressWarnings("unchecked")
41+
private static final ConstructingObjectParser<SetPriorityAction, Void> PARSER = new ConstructingObjectParser<>(NAME, true,
42+
a -> new SetPriorityAction((Integer) a[0]));
43+
44+
//package private for testing
45+
final Integer recoveryPriority;
46+
47+
static {
48+
PARSER.declareField(ConstructingObjectParser.constructorArg(),
49+
(p) -> p.currentToken() == XContentParser.Token.VALUE_NULL ? null : p.intValue()
50+
, RECOVERY_PRIORITY_FIELD, ObjectParser.ValueType.INT_OR_NULL);
51+
}
52+
53+
public static SetPriorityAction parse(XContentParser parser) {
54+
return PARSER.apply(parser, null);
55+
}
56+
57+
public SetPriorityAction(@Nullable Integer recoveryPriority) {
58+
if (recoveryPriority != null && recoveryPriority <= 0) {
59+
throw new IllegalArgumentException("[" + RECOVERY_PRIORITY_FIELD.getPreferredName() + "] must be 0 or greater");
60+
}
61+
this.recoveryPriority = recoveryPriority;
62+
}
63+
64+
@Override
65+
public XContentBuilder toXContent(XContentBuilder builder, ToXContent.Params params) throws IOException {
66+
builder.startObject();
67+
builder.field(RECOVERY_PRIORITY_FIELD.getPreferredName(), recoveryPriority);
68+
builder.endObject();
69+
return builder;
70+
}
71+
72+
@Override
73+
public boolean equals(Object o) {
74+
if (this == o) return true;
75+
if (o == null || getClass() != o.getClass()) return false;
76+
77+
SetPriorityAction that = (SetPriorityAction) o;
78+
79+
return recoveryPriority != null ? recoveryPriority.equals(that.recoveryPriority) : that.recoveryPriority == null;
80+
}
81+
82+
@Override
83+
public int hashCode() {
84+
return recoveryPriority != null ? recoveryPriority.hashCode() : 0;
85+
}
86+
87+
@Override
88+
public String toString() {
89+
return Strings.toString(this);
90+
}
91+
92+
@Override
93+
public String getName() {
94+
return NAME;
95+
}
96+
}

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

+2-13
Original file line numberDiff line numberDiff line change
@@ -20,17 +20,15 @@
2020

2121
import org.elasticsearch.common.ParseField;
2222
import org.elasticsearch.common.xcontent.ObjectParser;
23-
import org.elasticsearch.common.xcontent.ToXContentObject;
24-
import org.elasticsearch.common.xcontent.XContentBuilder;
2523
import org.elasticsearch.common.xcontent.XContentParser;
2624

2725
import java.io.IOException;
2826
import java.util.Objects;
2927

30-
public class DeleteWatchResponse implements ToXContentObject {
28+
public class DeleteWatchResponse {
3129

3230
private static final ObjectParser<DeleteWatchResponse, Void> PARSER
33-
= new ObjectParser<>("x_pack_delete_watch_response", DeleteWatchResponse::new);
31+
= new ObjectParser<>("x_pack_delete_watch_response", true, DeleteWatchResponse::new);
3432
static {
3533
PARSER.declareString(DeleteWatchResponse::setId, new ParseField("_id"));
3634
PARSER.declareLong(DeleteWatchResponse::setVersion, new ParseField("_version"));
@@ -89,15 +87,6 @@ public int hashCode() {
8987
return Objects.hash(id, version, found);
9088
}
9189

92-
@Override
93-
public XContentBuilder toXContent(XContentBuilder builder, Params params) throws IOException {
94-
return builder.startObject()
95-
.field("_id", id)
96-
.field("_version", version)
97-
.field("found", found)
98-
.endObject();
99-
}
100-
10190
public static DeleteWatchResponse fromXContent(XContentParser parser) throws IOException {
10291
return PARSER.parse(parser, null);
10392
}

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

+2-13
Original file line numberDiff line numberDiff line change
@@ -20,17 +20,15 @@
2020

2121
import org.elasticsearch.common.ParseField;
2222
import org.elasticsearch.common.xcontent.ObjectParser;
23-
import org.elasticsearch.common.xcontent.ToXContentObject;
24-
import org.elasticsearch.common.xcontent.XContentBuilder;
2523
import org.elasticsearch.common.xcontent.XContentParser;
2624

2725
import java.io.IOException;
2826
import java.util.Objects;
2927

30-
public class PutWatchResponse implements ToXContentObject {
28+
public class PutWatchResponse {
3129

3230
private static final ObjectParser<PutWatchResponse, Void> PARSER
33-
= new ObjectParser<>("x_pack_put_watch_response", PutWatchResponse::new);
31+
= new ObjectParser<>("x_pack_put_watch_response", true, PutWatchResponse::new);
3432

3533
static {
3634
PARSER.declareString(PutWatchResponse::setId, new ParseField("_id"));
@@ -90,15 +88,6 @@ public int hashCode() {
9088
return Objects.hash(id, version, created);
9189
}
9290

93-
@Override
94-
public XContentBuilder toXContent(XContentBuilder builder, Params params) throws IOException {
95-
return builder.startObject()
96-
.field("_id", id)
97-
.field("_version", version)
98-
.field("created", created)
99-
.endObject();
100-
}
101-
10291
public static PutWatchResponse fromXContent(XContentParser parser) throws IOException {
10392
return PARSER.parse(parser, null);
10493
}

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

+3-5
Original file line numberDiff line numberDiff line change
@@ -255,9 +255,7 @@ public void testSourceDoesNotExist() throws IOException {
255255
.put("number_of_shards", 1)
256256
.put("number_of_replicas", 0)
257257
.build();
258-
String mapping = "\"_doc\": { \"_source\": {\n" +
259-
" \"enabled\": false\n" +
260-
" } }";
258+
String mapping = "\"_source\": {\"enabled\": false}";
261259
createIndex(noSourceIndex, settings, mapping);
262260
assertEquals(
263261
RestStatus.OK,
@@ -1242,7 +1240,7 @@ public void testTermvectors() throws IOException {
12421240
.put("number_of_shards", 1)
12431241
.put("number_of_replicas", 0)
12441242
.build();
1245-
String mappings = "\"_doc\":{\"properties\":{\"field\":{\"type\":\"text\"}}}";
1243+
String mappings = "\"properties\":{\"field\":{\"type\":\"text\"}}";
12461244
createIndex(sourceIndex, settings, mappings);
12471245
assertEquals(
12481246
RestStatus.OK,
@@ -1318,7 +1316,7 @@ public void testMultiTermvectors() throws IOException {
13181316
.put("number_of_shards", 1)
13191317
.put("number_of_replicas", 0)
13201318
.build();
1321-
String mappings = "\"_doc\":{\"properties\":{\"field\":{\"type\":\"text\"}}}";
1319+
String mappings = "\"properties\":{\"field\":{\"type\":\"text\"}}";
13221320
createIndex(sourceIndex, settings, mappings);
13231321
assertEquals(
13241322
RestStatus.OK,

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

+5-7
Original file line numberDiff line numberDiff line change
@@ -341,7 +341,7 @@ public void testGetIndex() throws IOException {
341341
.put(SETTING_NUMBER_OF_SHARDS, 1)
342342
.put(SETTING_NUMBER_OF_REPLICAS, 0)
343343
.build();
344-
String mappings = "\"_doc\":{\"properties\":{\"field-1\":{\"type\":\"integer\"}}}";
344+
String mappings = "\"properties\":{\"field-1\":{\"type\":\"integer\"}}";
345345
createIndex(indexName, basicSettings, mappings);
346346

347347
GetIndexRequest getIndexRequest = new GetIndexRequest()
@@ -371,7 +371,7 @@ public void testGetIndexWithDefaults() throws IOException {
371371
.put(SETTING_NUMBER_OF_SHARDS, 1)
372372
.put(SETTING_NUMBER_OF_REPLICAS, 0)
373373
.build();
374-
String mappings = "\"_doc\":{\"properties\":{\"field-1\":{\"type\":\"integer\"}}}";
374+
String mappings = "\"properties\":{\"field-1\":{\"type\":\"integer\"}}";
375375
createIndex(indexName, basicSettings, mappings);
376376

377377
GetIndexRequest getIndexRequest = new GetIndexRequest()
@@ -443,9 +443,7 @@ public void testGetMapping() throws IOException {
443443
Map<String, Object> getIndexResponse = getAsMap(indexName);
444444
assertEquals("text", XContentMapValues.extractValue(indexName + ".mappings.properties.field.type", getIndexResponse));
445445

446-
GetMappingsRequest request = new GetMappingsRequest()
447-
.indices(indexName)
448-
.types("_doc");
446+
GetMappingsRequest request = new GetMappingsRequest().indices(indexName);
449447

450448
GetMappingsResponse getMappingsResponse =
451449
execute(request, highLevelClient().indices()::getMapping, highLevelClient().indices()::getMappingAsync);
@@ -1251,8 +1249,8 @@ public void testPutTemplate() throws Exception {
12511249
assertThat(extractRawValues("my-template.index_patterns", templates), contains("pattern-1", "name-*"));
12521250
assertThat(extractValue("my-template.settings.index.number_of_shards", templates), equalTo("3"));
12531251
assertThat(extractValue("my-template.settings.index.number_of_replicas", templates), equalTo("0"));
1254-
assertThat(extractValue("my-template.mappings.doc.properties.host_name.type", templates), equalTo("keyword"));
1255-
assertThat(extractValue("my-template.mappings.doc.properties.description.type", templates), equalTo("text"));
1252+
assertThat(extractValue("my-template.mappings.properties.host_name.type", templates), equalTo("keyword"));
1253+
assertThat(extractValue("my-template.mappings.properties.description.type", templates), equalTo("text"));
12561254
assertThat((Map<String, String>) extractValue("my-template.aliases.alias-1", templates), hasEntry("index_routing", "abc"));
12571255
assertThat((Map<String, String>) extractValue("my-template.aliases.{index}-write", templates), hasEntry("search_routing", "xyz"));
12581256
}

0 commit comments

Comments
 (0)