Skip to content

Commit 2a65635

Browse files
committed
Merge branch 'master' into pr/35195
* master: (24 commits) Replicate index settings to followers (elastic#35089) Rename RealmConfig.globalSettings() to settings() (elastic#35330) [TEST] Cleanup FileUserPasswdStoreTests (elastic#35329) Scripting: Add back lookup vars in score script (elastic#34833) watcher: Fix integration tests to ensure correct start/stop of Watcher (elastic#35271) Remove ALL shard check in CheckShrinkReadyStep (elastic#35346) Use soft-deleted docs to resolve strategy for engine operation (elastic#35230) [ILM] Check shard and relocation status in AllocationRoutedStep (elastic#35316) Ignore date ranges containing 'now' when pre-processing a percolator query (elastic#35160) Add a frozen engine implementation (elastic#34357) Put a fake allocation id on allocate stale primary command (elastic#34140) [CCR] Enforce auto follow pattern name restrictions (elastic#35197) [ILM] rolling upgrade tests (elastic#35328) [ML] Add Missing data checking class (elastic#35310) Apply `ignore_throttled` also to concrete indices (elastic#35335) Make version field names more meaningful (elastic#35334) [CCR] Added HLRC support for pause follow API (elastic#35216) [Docs] Improve Convert Processor description (elastic#35280) [Painless] Removes extraneous compile method (elastic#35323) [CCR] Fail with a better error if leader index is red (elastic#35298) ...
2 parents 287715c + 4f4fc3b commit 2a65635

File tree

200 files changed

+4450
-847
lines changed

Some content is hidden

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

200 files changed

+4450
-847
lines changed

.ci/java-versions.properties

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,4 +8,3 @@ ES_BUILD_JAVA=java11
88
ES_RUNTIME_JAVA=java8
99
GRADLE_TASK=build
1010

11-
GRADLE_EXTRA_ARGS=-Dtests.bwc.refspec=elastic/index-lifecycle-6.x

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -699,7 +699,7 @@ class BuildPlugin implements Plugin<Project> {
699699
// this doFirst is added before the info plugin, therefore it will run
700700
// after the doFirst added by the info plugin, and we can override attributes
701701
jarTask.manifest.attributes(
702-
'X-Compile-Elasticsearch-Version': VersionProperties.elasticsearch.replace("-SNAPSHOT", ""),
702+
'X-Compile-Elasticsearch-Version': VersionProperties.elasticsearch,
703703
'X-Compile-Lucene-Version': VersionProperties.lucene,
704704
'X-Compile-Elasticsearch-Snapshot': VersionProperties.isElasticsearchSnapshot(),
705705
'Build-Date': ZonedDateTime.now(ZoneOffset.UTC),

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

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@
1818
*/
1919
package org.elasticsearch.gradle.doc
2020

21+
import org.elasticsearch.gradle.Version
2122
import org.elasticsearch.gradle.VersionProperties
2223
import org.elasticsearch.gradle.test.RestTestPlugin
2324
import org.gradle.api.Project
@@ -37,12 +38,12 @@ public class DocsTestPlugin extends RestTestPlugin {
3738
// Docs are published separately so no need to assemble
3839
project.tasks.assemble.enabled = false
3940
Map<String, String> defaultSubstitutions = [
40-
/* These match up with the asciidoc syntax for substitutions but
41-
* the values may differ. In particular {version} needs to resolve
42-
* to the version being built for testing but needs to resolve to
43-
* the last released version for docs. */
44-
'\\{version\\}':
45-
VersionProperties.elasticsearch.replace('-SNAPSHOT', ''),
41+
/* These match up with the asciidoc syntax for substitutions but
42+
* the values may differ. In particular {version} needs to resolve
43+
* to the version being built for testing but needs to resolve to
44+
* the last released version for docs. */
45+
'\\{version\\}': Version.fromString(VersionProperties.elasticsearch).toString(),
46+
'\\{version_qualified\\}': VersionProperties.elasticsearch,
4647
'\\{lucene_version\\}' : VersionProperties.lucene.replaceAll('-snapshot-\\w+$', ''),
4748
'\\{build_flavor\\}' :
4849
project.integTestCluster.distribution.startsWith('oss-') ? 'oss' : 'default',

buildSrc/src/main/groovy/org/elasticsearch/gradle/plugin/PluginPropertiesTask.groovy

Lines changed: 3 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@
1818
*/
1919
package org.elasticsearch.gradle.plugin
2020

21+
import org.elasticsearch.gradle.Version
2122
import org.elasticsearch.gradle.VersionProperties
2223
import org.gradle.api.InvalidUserDataException
2324
import org.gradle.api.Task
@@ -66,17 +67,11 @@ class PluginPropertiesTask extends Copy {
6667
}
6768

6869
Map<String, String> generateSubstitutions() {
69-
def stringSnap = { version ->
70-
if (version.endsWith("-SNAPSHOT")) {
71-
return version.substring(0, version.length() - 9)
72-
}
73-
return version
74-
}
7570
return [
7671
'name': extension.name,
7772
'description': extension.description,
78-
'version': stringSnap(extension.version),
79-
'elasticsearchVersion': stringSnap(VersionProperties.elasticsearch),
73+
'version': extension.version,
74+
'elasticsearchVersion': Version.fromString(VersionProperties.elasticsearch).toString(),
8075
'javaVersion': project.targetCompatibility as String,
8176
'classname': extension.classname,
8277
'extendedPlugins': extension.extendedPlugins.join(','),

buildSrc/src/main/groovy/org/elasticsearch/gradle/vagrant/VagrantTestPlugin.groovy

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -278,9 +278,13 @@ class VagrantTestPlugin implements Plugin<Project> {
278278
}
279279

280280
Task createUpgradeFromFile = project.tasks.create('createUpgradeFromFile', FileContentsTask) {
281+
String version = project.extensions.esvagrant.upgradeFromVersion
282+
if (project.bwcVersions.unreleased.contains(project.extensions.esvagrant.upgradeFromVersion)) {
283+
version += "-SNAPSHOT"
284+
}
281285
dependsOn copyPackagingArchives
282286
file "${archivesDir}/upgrade_from_version"
283-
contents project.extensions.esvagrant.upgradeFromVersion.toString()
287+
contents version
284288
}
285289

286290
Task createUpgradeIsOssFile = project.tasks.create('createUpgradeIsOssFile', FileContentsTask) {
Lines changed: 86 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,86 @@
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.ccr.PauseFollowRequest;
24+
import org.elasticsearch.client.core.AcknowledgedResponse;
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 ccr related methods
32+
* <p>
33+
* See the <a href="https://www.elastic.co/guide/en/elasticsearch/reference/current/ccr-apis.html">
34+
* X-Pack Rollup APIs on elastic.co</a> for more information.
35+
*/
36+
public final class CcrClient {
37+
38+
private final RestHighLevelClient restHighLevelClient;
39+
40+
CcrClient(RestHighLevelClient restHighLevelClient) {
41+
this.restHighLevelClient = restHighLevelClient;
42+
}
43+
44+
/**
45+
* Instructs a follower index the pause the following of a leader index.
46+
*
47+
* See <a href="https://www.elastic.co/guide/en/elasticsearch/reference/current/ccr-pause-follow.html">
48+
* the docs</a> for more.
49+
*
50+
* @param request the request
51+
* @param options the request options (e.g. headers), use {@link RequestOptions#DEFAULT} if nothing needs to be customized
52+
* @return the response
53+
* @throws IOException in case there is a problem sending the request or parsing back the response
54+
*/
55+
public AcknowledgedResponse pauseFollow(PauseFollowRequest request, RequestOptions options) throws IOException {
56+
return restHighLevelClient.performRequestAndParseEntity(
57+
request,
58+
CcrRequestConverters::pauseFollow,
59+
options,
60+
AcknowledgedResponse::fromXContent,
61+
Collections.emptySet()
62+
);
63+
}
64+
65+
/**
66+
* Asynchronously instruct a follower index the pause the following of a leader index.
67+
*
68+
* See <a href="https://www.elastic.co/guide/en/elasticsearch/reference/current/ccr-pause-follow.html">
69+
* the docs</a> for more.
70+
*
71+
* @param request the request
72+
* @param options the request options (e.g. headers), use {@link RequestOptions#DEFAULT} if nothing needs to be customized
73+
*/
74+
public void pauseFollowAsync(PauseFollowRequest request,
75+
RequestOptions options,
76+
ActionListener<AcknowledgedResponse> listener) {
77+
restHighLevelClient.performRequestAsyncAndParseEntity(
78+
request,
79+
CcrRequestConverters::pauseFollow,
80+
options,
81+
AcknowledgedResponse::fromXContent,
82+
listener,
83+
Collections.emptySet());
84+
}
85+
86+
}
Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
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.apache.http.client.methods.HttpPost;
23+
import org.elasticsearch.client.ccr.PauseFollowRequest;
24+
25+
final class CcrRequestConverters {
26+
27+
static Request pauseFollow(PauseFollowRequest pauseFollowRequest) {
28+
String endpoint = new RequestConverters.EndpointBuilder()
29+
.addPathPart(pauseFollowRequest.getFollowerIndex())
30+
.addPathPartAsIs("_ccr", "pause_follow")
31+
.build();
32+
return new Request(HttpPost.METHOD_NAME, endpoint);
33+
}
34+
35+
}

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

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -228,6 +228,7 @@ public class RestHighLevelClient implements Closeable {
228228
private final SecurityClient securityClient = new SecurityClient(this);
229229
private final IndexLifecycleClient ilmClient = new IndexLifecycleClient(this);
230230
private final RollupClient rollupClient = new RollupClient(this);
231+
private final CcrClient ccrClient = new CcrClient(this);
231232

232233
/**
233234
* Creates a {@link RestHighLevelClient} given the low level {@link RestClientBuilder} that allows to build the
@@ -321,6 +322,20 @@ public RollupClient rollup() {
321322
return rollupClient;
322323
}
323324

325+
/**
326+
* Provides methods for accessing the Elastic Licensed CCR APIs that
327+
* are shipped with the Elastic Stack distribution of Elasticsearch. All of
328+
* these APIs will 404 if run against the OSS distribution of Elasticsearch.
329+
* <p>
330+
* See the <a href="https://www.elastic.co/guide/en/elasticsearch/reference/current/ccr-api.html">
331+
* CCR APIs on elastic.co</a> for more information.
332+
*
333+
* @return the client wrapper for making CCR API calls
334+
*/
335+
public final CcrClient ccr() {
336+
return ccrClient;
337+
}
338+
324339
/**
325340
* Provides a {@link TasksClient} which can be used to access the Tasks API.
326341
*
Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
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.ccr;
21+
22+
import org.elasticsearch.client.Validatable;
23+
24+
import java.util.Objects;
25+
26+
public final class PauseFollowRequest implements Validatable {
27+
28+
private final String followerIndex;
29+
30+
public PauseFollowRequest(String followerIndex) {
31+
this.followerIndex = Objects.requireNonNull(followerIndex);
32+
}
33+
34+
public String getFollowerIndex() {
35+
return followerIndex;
36+
}
37+
}

client/rest-high-level/src/main/java/org/elasticsearch/client/rollup/AcknowledgedResponse.java renamed to client/rest-high-level/src/main/java/org/elasticsearch/client/core/AcknowledgedResponse.java

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,23 +17,27 @@
1717
* under the License.
1818
*/
1919

20-
package org.elasticsearch.client.rollup;
20+
package org.elasticsearch.client.core;
2121

2222
import org.elasticsearch.common.ParseField;
2323
import org.elasticsearch.common.xcontent.ConstructingObjectParser;
2424
import org.elasticsearch.common.xcontent.ToXContent;
2525
import org.elasticsearch.common.xcontent.ToXContentObject;
2626
import org.elasticsearch.common.xcontent.XContentBuilder;
27+
import org.elasticsearch.common.xcontent.XContentParser;
2728

2829
import java.io.IOException;
2930
import java.util.Objects;
3031
import java.util.function.Function;
3132

3233
import static org.elasticsearch.common.xcontent.ConstructingObjectParser.constructorArg;
3334

34-
public abstract class AcknowledgedResponse implements ToXContentObject {
35+
public class AcknowledgedResponse implements ToXContentObject {
3536

3637
protected static final String PARSE_FIELD_NAME = "acknowledged";
38+
private static final ConstructingObjectParser<AcknowledgedResponse, Void> PARSER = AcknowledgedResponse
39+
.generateParser("acknowledged_response", AcknowledgedResponse::new, AcknowledgedResponse.PARSE_FIELD_NAME);
40+
3741
private final boolean acknowledged;
3842

3943
public AcknowledgedResponse(final boolean acknowledged) {
@@ -50,6 +54,10 @@ protected static <T> ConstructingObjectParser<T, Void> generateParser(String nam
5054
return p;
5155
}
5256

57+
public static AcknowledgedResponse fromXContent(final XContentParser parser) throws IOException {
58+
return PARSER.parse(parser, null);
59+
}
60+
5361
@Override
5462
public boolean equals(Object o) {
5563
if (this == o) {

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

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@
1919

2020
package org.elasticsearch.client.rollup;
2121

22+
import org.elasticsearch.client.core.AcknowledgedResponse;
2223
import org.elasticsearch.common.xcontent.ConstructingObjectParser;
2324
import org.elasticsearch.common.xcontent.XContentParser;
2425

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

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@
1818
*/
1919
package org.elasticsearch.client.rollup;
2020

21+
import org.elasticsearch.client.core.AcknowledgedResponse;
2122
import org.elasticsearch.common.xcontent.ConstructingObjectParser;
2223
import org.elasticsearch.common.xcontent.XContentParser;
2324

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

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@
1919

2020
package org.elasticsearch.client.rollup;
2121

22+
import org.elasticsearch.client.core.AcknowledgedResponse;
2223
import org.elasticsearch.common.xcontent.ConstructingObjectParser;
2324
import org.elasticsearch.common.xcontent.XContentParser;
2425

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

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -84,8 +84,7 @@ public void testXPackInfo() throws IOException {
8484
assertNotNull(ml.description());
8585
assertTrue(ml.available());
8686
assertTrue(ml.enabled());
87-
assertEquals(mainResponse.getVersion().toString(),
88-
ml.nativeCodeInfo().get("version").toString().replace("-SNAPSHOT", ""));
87+
assertEquals(mainResponse.getBuild().getQualifiedVersion(), ml.nativeCodeInfo().get("version").toString());
8988
}
9089

9190
public void testXPackInfoEmptyRequest() throws IOException {

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

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -785,7 +785,8 @@ public void testApiNamingConventions() throws Exception {
785785
apiName.startsWith("graph.") == false &&
786786
apiName.startsWith("migration.") == false &&
787787
apiName.startsWith("security.") == false &&
788-
apiName.startsWith("index_lifecycle.") == false) {
788+
apiName.startsWith("index_lifecycle.") == false &&
789+
apiName.startsWith("ccr.") == false) {
789790
apiNotFound.add(apiName);
790791
}
791792
}

0 commit comments

Comments
 (0)