Skip to content

Commit e5bb88c

Browse files
committed
Merge remote-tracking branch 'elastic/master' into sync-retention-leases
* elastic/master: (104 commits) Permission for restricted indices (elastic#37577) Remove Watcher Account "unsecure" settings (elastic#36736) Add cache cleaning task for ML snapshot (elastic#37505) Update jdk used by the docker builds (elastic#37621) Remove an unused constant in PutMappingRequest. Update get users to allow unknown fields (elastic#37593) Do not add index event listener if CCR disabled (elastic#37432) Add local session timeouts to leader node (elastic#37438) Add some deprecation optimizations (elastic#37597) refactor inner geogrid classes to own class files (elastic#37596) Remove obsolete deprecation checks (elastic#37510) ML: Add support for single bucket aggs in Datafeeds (elastic#37544) ML: creating ML State write alias and pointing writes there (elastic#37483) Deprecate types in the put mapping API. (elastic#37280) [ILM] Add unfollow action (elastic#36970) Packaging: Update marker used to allow ELASTIC_PASSWORD (elastic#37243) Fix setting openldap realm ssl config Document the need for JAVA11_HOME (elastic#37589) SQL: fix object extraction from sources (elastic#37502) Nit in settings.gradle for Eclipse ...
2 parents eb90d54 + ff0f540 commit e5bb88c

File tree

701 files changed

+20512
-6888
lines changed

Some content is hidden

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

701 files changed

+20512
-6888
lines changed

CONTRIBUTING.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -100,8 +100,8 @@ JDK 11 and testing on a JDK 8 runtime; to do this, set `RUNTIME_JAVA_HOME`
100100
pointing to the Java home of a JDK 8 installation. Note that this mechanism can
101101
be used to test against other JDKs as well, this is not only limited to JDK 8.
102102

103-
> Note: It is also required to have `JAVA8_HOME`, `JAVA9_HOME`, and
104-
`JAVA10_HOME` are available so that the tests can pass.
103+
> Note: It is also required to have `JAVA8_HOME`, `JAVA9_HOME`, `JAVA10_HOME`
104+
and `JAVA11_HOME` available so that the tests can pass.
105105

106106
> Warning: do not use `sdkman` for Java installations which do not have proper
107107
`jrunscript` for jdk distributions.

buildSrc/src/main/resources/checkstyle_suppressions.xml

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -46,11 +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[/\\]node[/\\]Node.java" checks="LineLength" />
52-
<suppress files="server[/\\]src[/\\]test[/\\]java[/\\]org[/\\]elasticsearch[/\\]aliases[/\\]IndexAliasesIT.java" checks="LineLength" />
53-
5449
<!-- Gradle requires inputs to be seriablizable -->
5550
<suppress files="buildSrc[/\\]src[/\\]main[/\\]java[/\\]org[/\\]elasticsearch[/\\]gradle[/\\]precommit[/\\]TestingConventionRule.java" checks="RegexpSinglelineJava" />
5651
</suppressions>

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

Lines changed: 13 additions & 0 deletions
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)
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
5.1
1+
5.1.1

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

Lines changed: 40 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,6 @@
4141
import org.elasticsearch.action.admin.indices.mapping.get.GetFieldMappingsResponse;
4242
import org.elasticsearch.action.admin.indices.mapping.get.GetMappingsRequest;
4343
import org.elasticsearch.action.admin.indices.mapping.get.GetMappingsResponse;
44-
import org.elasticsearch.action.admin.indices.mapping.put.PutMappingRequest;
4544
import org.elasticsearch.action.admin.indices.open.OpenIndexRequest;
4645
import org.elasticsearch.action.admin.indices.open.OpenIndexResponse;
4746
import org.elasticsearch.action.admin.indices.refresh.RefreshRequest;
@@ -63,6 +62,7 @@
6362
import org.elasticsearch.client.indices.FreezeIndexRequest;
6463
import org.elasticsearch.client.indices.GetIndexTemplatesRequest;
6564
import org.elasticsearch.client.indices.IndexTemplatesExistRequest;
65+
import org.elasticsearch.client.indices.PutMappingRequest;
6666
import org.elasticsearch.client.indices.UnfreezeIndexRequest;
6767
import org.elasticsearch.rest.RestStatus;
6868

@@ -166,6 +166,45 @@ public void putMappingAsync(PutMappingRequest putMappingRequest, RequestOptions
166166
AcknowledgedResponse::fromXContent, listener, emptySet());
167167
}
168168

169+
/**
170+
* Updates the mappings on an index using the Put Mapping API.
171+
* See <a href="https://www.elastic.co/guide/en/elasticsearch/reference/current/indices-put-mapping.html">
172+
* Put Mapping API on elastic.co</a>
173+
* @param putMappingRequest the request
174+
* @param options the request options (e.g. headers), use {@link RequestOptions#DEFAULT} if nothing needs to be customized
175+
* @return the response
176+
* @throws IOException in case there is a problem sending the request or parsing back the response
177+
*
178+
* @deprecated This method uses an old request object which still refers to types, a deprecated feature. The method
179+
* {@link #putMapping(PutMappingRequest, RequestOptions)} should be used instead, which accepts a new request object.
180+
*/
181+
@Deprecated
182+
public AcknowledgedResponse putMapping(org.elasticsearch.action.admin.indices.mapping.put.PutMappingRequest putMappingRequest,
183+
RequestOptions options) throws IOException {
184+
return restHighLevelClient.performRequestAndParseEntity(putMappingRequest, IndicesRequestConverters::putMapping, options,
185+
AcknowledgedResponse::fromXContent, emptySet());
186+
}
187+
188+
/**
189+
* Asynchronously updates the mappings on an index using the Put Mapping API.
190+
* See <a href="https://www.elastic.co/guide/en/elasticsearch/reference/current/indices-put-mapping.html">
191+
* Put Mapping API on elastic.co</a>
192+
* @param putMappingRequest the request
193+
* @param options the request options (e.g. headers), use {@link RequestOptions#DEFAULT} if nothing needs to be customized
194+
* @param listener the listener to be notified upon request completion
195+
*
196+
* @deprecated This method uses an old request object which still refers to types, a deprecated feature. The
197+
* method {@link #putMappingAsync(PutMappingRequest, RequestOptions, ActionListener)} should be used instead,
198+
* which accepts a new request object.
199+
*/
200+
@Deprecated
201+
public void putMappingAsync(org.elasticsearch.action.admin.indices.mapping.put.PutMappingRequest putMappingRequest,
202+
RequestOptions options,
203+
ActionListener<AcknowledgedResponse> listener) {
204+
restHighLevelClient.performRequestAsyncAndParseEntity(putMappingRequest, IndicesRequestConverters::putMapping, options,
205+
AcknowledgedResponse::fromXContent, listener, emptySet());
206+
}
207+
169208
/**
170209
* Retrieves the mappings on an index or indices using the Get Mapping API.
171210
* See <a href="https://www.elastic.co/guide/en/elasticsearch/reference/current/indices-get-mapping.html">

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

Lines changed: 14 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,6 @@
3737
import org.elasticsearch.action.admin.indices.get.GetIndexRequest;
3838
import org.elasticsearch.action.admin.indices.mapping.get.GetFieldMappingsRequest;
3939
import org.elasticsearch.action.admin.indices.mapping.get.GetMappingsRequest;
40-
import org.elasticsearch.action.admin.indices.mapping.put.PutMappingRequest;
4140
import org.elasticsearch.action.admin.indices.open.OpenIndexRequest;
4241
import org.elasticsearch.action.admin.indices.refresh.RefreshRequest;
4342
import org.elasticsearch.action.admin.indices.rollover.RolloverRequest;
@@ -51,6 +50,7 @@
5150
import org.elasticsearch.client.indices.FreezeIndexRequest;
5251
import org.elasticsearch.client.indices.GetIndexTemplatesRequest;
5352
import org.elasticsearch.client.indices.IndexTemplatesExistRequest;
53+
import org.elasticsearch.client.indices.PutMappingRequest;
5454
import org.elasticsearch.client.indices.UnfreezeIndexRequest;
5555
import org.elasticsearch.common.Strings;
5656

@@ -122,14 +122,25 @@ static Request updateAliases(IndicesAliasesRequest indicesAliasesRequest) throws
122122
return request;
123123
}
124124

125+
125126
static Request putMapping(PutMappingRequest putMappingRequest) throws IOException {
127+
Request request = new Request(HttpPut.METHOD_NAME, RequestConverters.endpoint(putMappingRequest.indices(), "_mapping"));
128+
129+
RequestConverters.Params parameters = new RequestConverters.Params(request);
130+
parameters.withTimeout(putMappingRequest.timeout());
131+
parameters.withMasterTimeout(putMappingRequest.masterNodeTimeout());
132+
request.setEntity(RequestConverters.createEntity(putMappingRequest, RequestConverters.REQUEST_BODY_CONTENT_TYPE));
133+
return request;
134+
}
135+
136+
static Request putMapping(org.elasticsearch.action.admin.indices.mapping.put.PutMappingRequest putMappingRequest) throws IOException {
126137
// The concreteIndex is an internal concept, not applicable to requests made over the REST API.
127138
if (putMappingRequest.getConcreteIndex() != null) {
128139
throw new IllegalArgumentException("concreteIndex cannot be set on PutMapping requests made over the REST API");
129140
}
130141

131-
Request request = new Request(HttpPut.METHOD_NAME, RequestConverters.endpoint(putMappingRequest.indices(), "_mapping",
132-
putMappingRequest.type()));
142+
Request request = new Request(HttpPut.METHOD_NAME, RequestConverters.endpoint(putMappingRequest.indices(),
143+
"_mapping", putMappingRequest.type()));
133144

134145
RequestConverters.Params parameters = new RequestConverters.Params(request);
135146
parameters.withTimeout(putMappingRequest.timeout());
@@ -150,7 +161,6 @@ static Request getMappings(GetMappingsRequest getMappingsRequest) throws IOExcep
150161
parameters.withMasterTimeout(getMappingsRequest.masterNodeTimeout());
151162
parameters.withIndicesOptions(getMappingsRequest.indicesOptions());
152163
parameters.withLocal(getMappingsRequest.local());
153-
parameters.putParam(INCLUDE_TYPE_NAME_PARAMETER, "true");
154164

155165
return request;
156166
}

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

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,13 @@ 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),
60+
new NamedXContentRegistry.Entry(LifecycleAction.class,
61+
new ParseField(UnfollowAction.NAME),
62+
UnfollowAction::parse)
5763
);
5864
}
5965
}

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

Lines changed: 4 additions & 3 deletions
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(UnfollowAction.NAME, SetPriorityAction.NAME, RolloverAction.NAME));
61+
ALLOWED_ACTIONS.put("warm", Sets.newHashSet(UnfollowAction.NAME, SetPriorityAction.NAME, AllocateAction.NAME, ForceMergeAction.NAME,
62+
ReadOnlyAction.NAME, ShrinkAction.NAME));
63+
ALLOWED_ACTIONS.put("cold", Sets.newHashSet(UnfollowAction.NAME, SetPriorityAction.NAME, AllocateAction.NAME, FreezeAction.NAME));
6364
ALLOWED_ACTIONS.put("delete", Sets.newHashSet(DeleteAction.NAME));
6465
}
6566

Lines changed: 96 additions & 0 deletions
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+
}
Lines changed: 74 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,74 @@
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.indexlifecycle;
21+
22+
import org.elasticsearch.common.Strings;
23+
import org.elasticsearch.common.xcontent.ObjectParser;
24+
import org.elasticsearch.common.xcontent.ToXContent;
25+
import org.elasticsearch.common.xcontent.ToXContentObject;
26+
import org.elasticsearch.common.xcontent.XContentBuilder;
27+
import org.elasticsearch.common.xcontent.XContentParser;
28+
29+
import java.io.IOException;
30+
31+
public class UnfollowAction implements LifecycleAction, ToXContentObject {
32+
public static final String NAME = "unfollow";
33+
34+
private static final ObjectParser<UnfollowAction, Void> PARSER = new ObjectParser<>(NAME, UnfollowAction::new);
35+
36+
public UnfollowAction() {}
37+
38+
@Override
39+
public String getName() {
40+
return NAME;
41+
}
42+
43+
public static UnfollowAction parse(XContentParser parser) {
44+
return PARSER.apply(parser, null);
45+
}
46+
47+
@Override
48+
public XContentBuilder toXContent(XContentBuilder builder, ToXContent.Params params) throws IOException {
49+
builder.startObject();
50+
builder.endObject();
51+
return builder;
52+
}
53+
54+
@Override
55+
public int hashCode() {
56+
return 36970;
57+
}
58+
59+
@Override
60+
public boolean equals(Object obj) {
61+
if (obj == null) {
62+
return false;
63+
}
64+
if (obj.getClass() != getClass()) {
65+
return false;
66+
}
67+
return true;
68+
}
69+
70+
@Override
71+
public String toString() {
72+
return Strings.toString(this);
73+
}
74+
}

0 commit comments

Comments
 (0)