Skip to content

Commit 51a8f86

Browse files
committed
Merge branch '6.x' into ccr-6.x
* 6.x: SQL: Fix build on Java 10 [Tests] Mutualize fixtures code in BaseHttpFixture (#31210) [TEST] Fix RemoteClusterClientTests#testEnsureWeReconnect [ML] Update test thresholds to account for changes to memory control (#31289) Reenable Checkstyle's unused import rule (#31270) [ML] Check licence when datafeeds use cross cluster search (#31247) Fix non-REST doc snippet [DOC] Extend SQL docs [DOCS] Shortens ML API intros Use quotes in the call invocation (#31249) move security ingest processors to a sub ingest directory (#31306) SQL: Whitelist SQL utility class for better scripting (#30681) Add 5.6.11 version constant. Fix version detection. [Docs] All Rollup docs experimental, agg limitations, clarify DeleteJob (#31299) Add missing release notes. Security: fix token bwc with pre 6.0.0-beta2 (#31254) Fix compilation error in UpdateSettingsIT (#31304) Test: Remove broken yml test feature (#31255) Add unreleased version 6.3.1 [Rollup] Metric config parser must use builder so validation runs (#31159) Removes experimental tag from scripted_metric aggregation (#31298) [DOCS] Removes coming tag from 6.3.0 release notes 6.3 release notes. Add notion of internal index settings (#31286) REST high-level client: add Cluster Health API (#29331) Remove leftover usage of deprecated client API SyncedFlushResponse to implement ToXContentObject (#31155) Add Get Aliases API to the high-level REST client (#28799) HLRest: Add get index templates API (#31161) Log warnings when cluster state publication failed to some nodes (#31233) Fix AntFixture waiting condition (#31272) [TEST] Mute RecoveryIT.testHistoryUUIDIsGenerated Ignore numeric shard count if waiting for ALL (#31265) Update checkstyle to 8.10.1 (#31269) Set analyzer version in PreBuiltAnalyzerProviderFactory (#31202) Revert upgrade to Netty 4.1.25.Final (#31282) Use armored input stream for reading public key (#31229) [DOCS] Added 'fail_on_unsupported_field' param to MLT. Closes #28008 (#31160) Fix Netty 4 Server Transport tests. Again. [DOCS] Fixed typo. [DOCS] Added release highlights for 6.3 (#31256) [DOCS] Mark SQL feature as experimental [DOCS] Updates machine learning custom URL screenshots (#31222) Fix naming conventions check for XPackTestCase Fix security Netty 4 transport tests Fix race in clear scroll (#31259) [DOCS] Clarify audit index settings when remote indexing (#30923) [ML][TEST] Mute tests using rules (#31204) Support RequestedAuthnContext (#31238) Validate xContentType in PutWatchRequest. (#31088) [INGEST] Interrupt the current thread if evaluation grok expressions take too long (#31024) Upgrade to Netty 4.1.25.Final (#31232) Suppress extras FS on caching directory tests Revert "[DOCS] Added 6.3 info & updated the upgrade table. (#30940)" Revert "Fix snippets in upgrade docs" Fix snippets in upgrade docs [DOCS] Added 6.3 info & updated the upgrade table. (#30940) Enable custom credentials for core REST tests (#31235) Move ESIndexLevelReplicationTestCase to test framework (#31243) Encapsulate Translog in Engine (#31220) [DOCS] Adds machine learning 6.3.0 release notes (#31217) Remove all unused imports and fix CRLF (#31207) [TEST] Fix testRecoveryAfterPrimaryPromotion [Docs] Remove mention pattern files in Grok processor (#31170) Use stronger write-once semantics for Azure repository (#30437) Don't swallow exceptions on replication (#31179) Compliant SAML Response destination check (#31175) Move java version checker back to its own jar (#30708) TEST: Retry synced-flush if ongoing ops on primary (#30978) [test] add fix for rare virtualbox error (#31212)
2 parents 438903f + 8305332 commit 51a8f86

File tree

799 files changed

+8268
-3933
lines changed

Some content is hidden

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

799 files changed

+8268
-3933
lines changed

Vagrantfile

+3
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,9 @@ Vagrant.configure(2) do |config|
3131
# Give the box more memory and cpu because our tests are beasts!
3232
vbox.memory = Integer(ENV['VAGRANT_MEMORY'] || 8192)
3333
vbox.cpus = Integer(ENV['VAGRANT_CPUS'] || 4)
34+
35+
# see https://github.com/hashicorp/vagrant/issues/9524
36+
vbox.customize ["modifyvm", :id, "--audio", "none"]
3437
end
3538

3639
# Switch the default share for the project root from /vagrant to

build.gradle

+1-1
Original file line numberDiff line numberDiff line change
@@ -121,7 +121,7 @@ task verifyVersions {
121121
new URL('https://repo1.maven.org/maven2/org/elasticsearch/elasticsearch/maven-metadata.xml').openStream().withStream { s ->
122122
xml = new XmlParser().parse(s)
123123
}
124-
Set<Version> knownVersions = new TreeSet<>(xml.versioning.versions.version.collect { it.text() }.findAll { it ==~ /\d\.\d\.\d/ }.collect { Version.fromString(it) })
124+
Set<Version> knownVersions = new TreeSet<>(xml.versioning.versions.version.collect { it.text() }.findAll { it ==~ /\d+\.\d+\.\d+/ }.collect { Version.fromString(it) })
125125

126126
// Limit the known versions to those that should be index compatible, and are not future versions
127127
knownVersions = knownVersions.findAll { it.major >= bwcVersions.currentVersion.major - 1 && it.before(VersionProperties.elasticsearch) }

buildSrc/src/main/groovy/org/elasticsearch/gradle/precommit/PrecommitTasks.groovy

+1-1
Original file line numberDiff line numberDiff line change
@@ -140,7 +140,7 @@ class PrecommitTasks {
140140
configProperties = [
141141
suppressions: checkstyleSuppressions
142142
]
143-
toolVersion = 7.5
143+
toolVersion = '8.10.1'
144144
}
145145

146146
project.tasks.withType(Checkstyle) { task ->

buildSrc/src/main/groovy/org/elasticsearch/gradle/test/AntFixture.groovy

+2-2
Original file line numberDiff line numberDiff line change
@@ -149,11 +149,11 @@ public class AntFixture extends AntTask implements Fixture {
149149
}
150150

151151
// the process is started (has a pid) and is bound to a network interface
152-
// so now wait undil the waitCondition has been met
152+
// so now evaluates if the waitCondition is successful
153153
// TODO: change this to a loop?
154154
boolean success
155155
try {
156-
success = waitCondition(this, ant) == false
156+
success = waitCondition(this, ant)
157157
} catch (Exception e) {
158158
String msg = "Wait condition caught exception for ${name}"
159159
logger.error(msg, e)

buildSrc/src/main/resources/checkstyle.xml

+3-7
Original file line numberDiff line numberDiff line change
@@ -26,13 +26,9 @@
2626
</module>
2727

2828
<module name="AvoidStarImport" />
29-
<!-- Doesn't pass but we could make it pass pretty quick.
30-
<module name="UnusedImports">
31-
The next property is optional. If we remove it then imports that are
32-
only referenced by Javadoc cause the check to fail.
33-
<property name="processJavadoc" value="true" />
34-
</module>
35-
-->
29+
30+
<!-- Unused imports are forbidden -->
31+
<module name="UnusedImports" />
3632

3733
<!-- Non-inner classes must be in files that match their names. -->
3834
<module name="OuterTypeFilename" />

buildSrc/src/main/resources/checkstyle_suppressions.xml

-1
Original file line numberDiff line numberDiff line change
@@ -600,7 +600,6 @@
600600
<suppress files="server[/\\]src[/\\]test[/\\]java[/\\]org[/\\]elasticsearch[/\\]index[/\\]query[/\\]SpanMultiTermQueryBuilderTests.java" checks="LineLength" />
601601
<suppress files="server[/\\]src[/\\]test[/\\]java[/\\]org[/\\]elasticsearch[/\\]index[/\\]query[/\\]SpanNotQueryBuilderTests.java" checks="LineLength" />
602602
<suppress files="server[/\\]src[/\\]test[/\\]java[/\\]org[/\\]elasticsearch[/\\]index[/\\]query[/\\]functionscore[/\\]FunctionScoreTests.java" checks="LineLength" />
603-
<suppress files="server[/\\]src[/\\]test[/\\]java[/\\]org[/\\]elasticsearch[/\\]index[/\\]replication[/\\]ESIndexLevelReplicationTestCase.java" checks="LineLength" />
604603
<suppress files="server[/\\]src[/\\]test[/\\]java[/\\]org[/\\]elasticsearch[/\\]index[/\\]search[/\\]MultiMatchQueryTests.java" checks="LineLength" />
605604
<suppress files="server[/\\]src[/\\]test[/\\]java[/\\]org[/\\]elasticsearch[/\\]index[/\\]search[/\\]geo[/\\]GeoUtilsTests.java" checks="LineLength" />
606605
<suppress files="server[/\\]src[/\\]test[/\\]java[/\\]org[/\\]elasticsearch[/\\]index[/\\]search[/\\]nested[/\\]AbstractNumberNestedSortingTestCase.java" checks="LineLength" />

client/benchmark/src/main/java/org/elasticsearch/client/benchmark/AbstractBenchmark.java

-2
Original file line numberDiff line numberDiff line change
@@ -28,8 +28,6 @@
2828
import java.lang.management.GarbageCollectorMXBean;
2929
import java.lang.management.ManagementFactory;
3030
import java.util.Arrays;
31-
import java.util.Collection;
32-
import java.util.Collections;
3331
import java.util.List;
3432
import java.util.stream.Collectors;
3533

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

+34
Original file line numberDiff line numberDiff line change
@@ -21,12 +21,16 @@
2121

2222
import org.apache.http.Header;
2323
import org.elasticsearch.action.ActionListener;
24+
import org.elasticsearch.action.admin.cluster.health.ClusterHealthRequest;
25+
import org.elasticsearch.action.admin.cluster.health.ClusterHealthResponse;
2426
import org.elasticsearch.action.admin.cluster.settings.ClusterUpdateSettingsRequest;
2527
import org.elasticsearch.action.admin.cluster.settings.ClusterUpdateSettingsResponse;
28+
import org.elasticsearch.rest.RestStatus;
2629

2730
import java.io.IOException;
2831

2932
import static java.util.Collections.emptySet;
33+
import static java.util.Collections.singleton;
3034

3135
/**
3236
* A wrapper for the {@link RestHighLevelClient} that provides methods for accessing the Cluster API.
@@ -95,4 +99,34 @@ public void putSettingsAsync(ClusterUpdateSettingsRequest clusterUpdateSettingsR
9599
restHighLevelClient.performRequestAsyncAndParseEntity(clusterUpdateSettingsRequest, RequestConverters::clusterPutSettings,
96100
ClusterUpdateSettingsResponse::fromXContent, listener, emptySet(), headers);
97101
}
102+
103+
/**
104+
* Get cluster health using the Cluster Health API.
105+
* See
106+
* <a href="https://www.elastic.co/guide/en/elasticsearch/reference/current/cluster-health.html"> Cluster Health API on elastic.co</a>
107+
* <p>
108+
* If timeout occurred, {@link ClusterHealthResponse} will have isTimedOut() == true and status() == RestStatus.REQUEST_TIMEOUT
109+
* @param healthRequest the request
110+
* @param options the request options (e.g. headers), use {@link RequestOptions#DEFAULT} if nothing needs to be customized
111+
* @return the response
112+
* @throws IOException in case there is a problem sending the request or parsing back the response
113+
*/
114+
public ClusterHealthResponse health(ClusterHealthRequest healthRequest, RequestOptions options) throws IOException {
115+
return restHighLevelClient.performRequestAndParseEntity(healthRequest, RequestConverters::clusterHealth, options,
116+
ClusterHealthResponse::fromXContent, singleton(RestStatus.REQUEST_TIMEOUT.getStatus()));
117+
}
118+
119+
/**
120+
* Asynchronously get cluster health using the Cluster Health API.
121+
* See
122+
* <a href="https://www.elastic.co/guide/en/elasticsearch/reference/current/cluster-health.html"> Cluster Health API on elastic.co</a>
123+
* If timeout occurred, {@link ClusterHealthResponse} will have isTimedOut() == true and status() == RestStatus.REQUEST_TIMEOUT
124+
* @param healthRequest the request
125+
* @param options the request options (e.g. headers), use {@link RequestOptions#DEFAULT} if nothing needs to be customized
126+
* @param listener the listener to be notified upon request completion
127+
*/
128+
public void healthAsync(ClusterHealthRequest healthRequest, RequestOptions options, ActionListener<ClusterHealthResponse> listener) {
129+
restHighLevelClient.performRequestAsyncAndParseEntity(healthRequest, RequestConverters::clusterHealth, options,
130+
ClusterHealthResponse::fromXContent, listener, singleton(RestStatus.REQUEST_TIMEOUT.getStatus()));
131+
}
98132
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,199 @@
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.ElasticsearchException;
23+
import org.elasticsearch.action.ActionResponse;
24+
import org.elasticsearch.cluster.metadata.AliasMetaData;
25+
import org.elasticsearch.common.xcontent.StatusToXContentObject;
26+
import org.elasticsearch.common.xcontent.ToXContent;
27+
import org.elasticsearch.common.xcontent.XContentBuilder;
28+
import org.elasticsearch.common.xcontent.XContentParser;
29+
import org.elasticsearch.common.xcontent.XContentParser.Token;
30+
import org.elasticsearch.rest.RestStatus;
31+
32+
import java.io.IOException;
33+
import java.util.Collections;
34+
import java.util.HashMap;
35+
import java.util.HashSet;
36+
import java.util.Map;
37+
import java.util.Set;
38+
39+
import static org.elasticsearch.common.xcontent.XContentParserUtils.ensureExpectedToken;
40+
41+
/**
42+
* Response obtained from the get aliases API.
43+
* The format is pretty horrible as it holds aliases, but at the same time errors can come back through the status and error fields.
44+
* Such errors are mostly 404 - NOT FOUND for aliases that were specified but not found. In such case the client won't throw exception
45+
* so it allows to retrieve the returned aliases, while at the same time checking if errors were returned.
46+
* There's also the case where an exception is returned, like for instance an {@link org.elasticsearch.index.IndexNotFoundException}.
47+
* We would usually throw such exception, but we configure the client to not throw for 404 to support the case above, hence we also not
48+
* throw in case an index is not found, although it is a hard error that doesn't come back with aliases.
49+
*/
50+
public class GetAliasesResponse extends ActionResponse implements StatusToXContentObject {
51+
52+
private final RestStatus status;
53+
private final String error;
54+
private final ElasticsearchException exception;
55+
56+
private final Map<String, Set<AliasMetaData>> aliases;
57+
58+
GetAliasesResponse(RestStatus status, String error, Map<String, Set<AliasMetaData>> aliases) {
59+
this.status = status;
60+
this.error = error;
61+
this.aliases = aliases;
62+
this.exception = null;
63+
}
64+
65+
private GetAliasesResponse(RestStatus status, ElasticsearchException exception) {
66+
this.status = status;
67+
this.error = null;
68+
this.aliases = Collections.emptyMap();
69+
this.exception = exception;
70+
}
71+
72+
@Override
73+
public RestStatus status() {
74+
return status;
75+
}
76+
77+
/**
78+
* Return the possibly returned error, null otherwise
79+
*/
80+
public String getError() {
81+
return error;
82+
}
83+
84+
/**
85+
* Return the exception that may have been returned
86+
*/
87+
public ElasticsearchException getException() {
88+
return exception;
89+
}
90+
91+
/**
92+
* Return the requested aliases
93+
*/
94+
public Map<String, Set<AliasMetaData>> getAliases() {
95+
return aliases;
96+
}
97+
98+
@Override
99+
public XContentBuilder toXContent(XContentBuilder builder, Params params) throws IOException {
100+
builder.startObject();
101+
{
102+
if (status != RestStatus.OK) {
103+
builder.field("error", error);
104+
builder.field("status", status.getStatus());
105+
}
106+
107+
for (Map.Entry<String, Set<AliasMetaData>> entry : aliases.entrySet()) {
108+
builder.startObject(entry.getKey());
109+
{
110+
builder.startObject("aliases");
111+
{
112+
for (final AliasMetaData alias : entry.getValue()) {
113+
AliasMetaData.Builder.toXContent(alias, builder, ToXContent.EMPTY_PARAMS);
114+
}
115+
}
116+
builder.endObject();
117+
}
118+
builder.endObject();
119+
}
120+
}
121+
builder.endObject();
122+
return builder;
123+
}
124+
125+
/**
126+
* Parse the get aliases response
127+
*/
128+
public static GetAliasesResponse fromXContent(XContentParser parser) throws IOException {
129+
if (parser.currentToken() == null) {
130+
parser.nextToken();
131+
}
132+
ensureExpectedToken(Token.START_OBJECT, parser.currentToken(), parser::getTokenLocation);
133+
Map<String, Set<AliasMetaData>> aliases = new HashMap<>();
134+
135+
String currentFieldName;
136+
Token token;
137+
String error = null;
138+
ElasticsearchException exception = null;
139+
RestStatus status = RestStatus.OK;
140+
141+
while (parser.nextToken() != Token.END_OBJECT) {
142+
if (parser.currentToken() == Token.FIELD_NAME) {
143+
currentFieldName = parser.currentName();
144+
145+
if ("status".equals(currentFieldName)) {
146+
if ((token = parser.nextToken()) != Token.FIELD_NAME) {
147+
ensureExpectedToken(Token.VALUE_NUMBER, token, parser::getTokenLocation);
148+
status = RestStatus.fromCode(parser.intValue());
149+
}
150+
} else if ("error".equals(currentFieldName)) {
151+
token = parser.nextToken();
152+
if (token == Token.VALUE_STRING) {
153+
error = parser.text();
154+
} else if (token == Token.START_OBJECT) {
155+
parser.nextToken();
156+
exception = ElasticsearchException.innerFromXContent(parser, true);
157+
} else if (token == Token.START_ARRAY) {
158+
parser.skipChildren();
159+
}
160+
} else {
161+
String indexName = parser.currentName();
162+
if (parser.nextToken() == Token.START_OBJECT) {
163+
Set<AliasMetaData> parseInside = parseAliases(parser);
164+
aliases.put(indexName, parseInside);
165+
}
166+
}
167+
}
168+
}
169+
if (exception != null) {
170+
assert error == null;
171+
assert aliases.isEmpty();
172+
return new GetAliasesResponse(status, exception);
173+
}
174+
return new GetAliasesResponse(status, error, aliases);
175+
}
176+
177+
private static Set<AliasMetaData> parseAliases(XContentParser parser) throws IOException {
178+
Set<AliasMetaData> aliases = new HashSet<>();
179+
Token token;
180+
String currentFieldName = null;
181+
while ((token = parser.nextToken()) != Token.END_OBJECT) {
182+
if (token == Token.FIELD_NAME) {
183+
currentFieldName = parser.currentName();
184+
} else if (token == Token.START_OBJECT) {
185+
if ("aliases".equals(currentFieldName)) {
186+
while (parser.nextToken() != Token.END_OBJECT) {
187+
AliasMetaData fromXContent = AliasMetaData.Builder.fromXContent(parser);
188+
aliases.add(fromXContent);
189+
}
190+
} else {
191+
parser.skipChildren();
192+
}
193+
} else if (token == Token.START_ARRAY) {
194+
parser.skipChildren();
195+
}
196+
}
197+
return aliases;
198+
}
199+
}

0 commit comments

Comments
 (0)