Skip to content

Commit 05debeb

Browse files
committed
Merge branch 'master' into replicated-closed-indices
2 parents 0519016 + 4144864 commit 05debeb

File tree

123 files changed

+4501
-831
lines changed

Some content is hidden

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

123 files changed

+4501
-831
lines changed

Vagrantfile

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -346,6 +346,11 @@ def sh_install_deps(config,
346346
echo "==> Java is not installed"
347347
return 1
348348
}
349+
cat \<\<JAVA > /etc/profile.d/java_home.sh
350+
if [ -z "\\\$JAVA_HOME" ]; then
351+
export JAVA_HOME=$(dirname $(dirname $(readlink -f $(which java))))
352+
fi
353+
JAVA
349354
ensure tar
350355
ensure curl
351356
ensure unzip
@@ -382,6 +387,7 @@ Defaults env_keep += "BATS_UTILS"
382387
Defaults env_keep += "BATS_TESTS"
383388
Defaults env_keep += "PACKAGING_ARCHIVES"
384389
Defaults env_keep += "PACKAGING_TESTS"
390+
Defaults env_keep += "JAVA_HOME"
385391
SUDOERS_VARS
386392
chmod 0440 /etc/sudoers.d/elasticsearch_vars
387393
SHELL

build.gradle

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -162,7 +162,6 @@ task verifyVersions {
162162

163163
boolean bwc_tests_enabled = true
164164
final String bwc_tests_disabled_issue = "" /* place a PR link here when committing bwc changes */
165-
166165
if (bwc_tests_enabled == false) {
167166
if (bwc_tests_disabled_issue.isEmpty()) {
168167
throw new GradleException("bwc_tests_disabled_issue must be set when bwc_tests_enabled == false")

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

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@ package org.elasticsearch.gradle.doc
2020

2121
import org.elasticsearch.gradle.Version
2222
import org.elasticsearch.gradle.VersionProperties
23+
import org.elasticsearch.gradle.test.ClusterFormationTasks
2324
import org.elasticsearch.gradle.test.RestTestPlugin
2425
import org.gradle.api.Project
2526
import org.gradle.api.Task
@@ -46,6 +47,7 @@ public class DocsTestPlugin extends RestTestPlugin {
4647
'\\{version_qualified\\}': VersionProperties.elasticsearch,
4748
'\\{lucene_version\\}' : VersionProperties.lucene.replaceAll('-snapshot-\\w+$', ''),
4849
'\\{build_flavor\\}' : project.integTestCluster.distribution,
50+
'\\{build_type\\}' : ClusterFormationTasks.getOs().equals("windows") ? "zip" : "tar",
4951
]
5052
Task listSnippets = project.tasks.create('listSnippets', SnippetsTask)
5153
listSnippets.group 'Docs'

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

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -274,7 +274,7 @@ class ClusterFormationTasks {
274274
}
275275
setup = configureCheckPreviousTask(taskName(prefix, node, 'checkPrevious'), project, setup, node)
276276
setup = configureStopTask(taskName(prefix, node, 'stopPrevious'), project, setup, node)
277-
setup = configureExtractTask(taskName(prefix, node, 'extract'), project, setup, node, distribution)
277+
setup = configureExtractTask(taskName(prefix, node, 'extract'), project, setup, node, distribution, config.distribution)
278278
setup = configureWriteConfigTask(taskName(prefix, node, 'configure'), project, setup, node, writeConfig)
279279
setup = configureCreateKeystoreTask(taskName(prefix, node, 'createKeystore'), project, setup, node)
280280
setup = configureAddKeystoreSettingTasks(prefix, project, setup, node)
@@ -343,14 +343,15 @@ class ClusterFormationTasks {
343343
}
344344

345345
/** Adds a task to extract the elasticsearch distribution */
346-
static Task configureExtractTask(String name, Project project, Task setup, NodeInfo node, Configuration configuration) {
346+
static Task configureExtractTask(String name, Project project, Task setup, NodeInfo node,
347+
Configuration configuration, String distribution) {
347348
List extractDependsOn = [configuration, setup]
348349
/* configuration.singleFile will be an external artifact if this is being run by a plugin not living in the
349350
elasticsearch source tree. If this is a plugin built in the elasticsearch source tree or this is a distro in
350351
the elasticsearch source tree then this should be the version of elasticsearch built by the source tree.
351352
If it isn't then Bad Things(TM) will happen. */
352353
Task extract = project.tasks.create(name: name, type: Copy, dependsOn: extractDependsOn) {
353-
if (getOs().equals("windows")) {
354+
if (getOs().equals("windows") || distribution.equals("integ-test-zip")) {
354355
from {
355356
project.zipTree(configuration.singleFile)
356357
}
@@ -971,9 +972,9 @@ class ClusterFormationTasks {
971972
/** Find the current OS */
972973
static String getOs() {
973974
String os = "linux"
974-
if (Os.FAMILY_WINDOWS) {
975+
if (Os.isFamily(Os.FAMILY_WINDOWS)) {
975976
os = "windows"
976-
} else if (Os.FAMILY_MAC) {
977+
} else if (Os.isFamily(Os.FAMILY_MAC)) {
977978
os = "darwin"
978979
}
979980
return os

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,7 @@ java.nio.channels.FileChannel#read(java.nio.ByteBuffer, long)
6161
@defaultMessage Use Lucene.parseLenient instead it strips off minor version
6262
org.apache.lucene.util.Version#parseLeniently(java.lang.String)
6363

64-
@defaultMessage Spawns a new thread which is solely under lucenes control use ThreadPool#estimatedTimeInMillisCounter instead
64+
@defaultMessage Spawns a new thread which is solely under lucenes control use ThreadPool#relativeTimeInMillis instead
6565
org.apache.lucene.search.TimeLimitingCollector#getGlobalTimerThread()
6666
org.apache.lucene.search.TimeLimitingCollector#getGlobalCounter()
6767

@@ -146,4 +146,4 @@ org.apache.logging.log4j.Logger#warn(java.lang.Object, java.lang.Throwable)
146146
org.apache.logging.log4j.Logger#error(java.lang.Object)
147147
org.apache.logging.log4j.Logger#error(java.lang.Object, java.lang.Throwable)
148148
org.apache.logging.log4j.Logger#fatal(java.lang.Object)
149-
org.apache.logging.log4j.Logger#fatal(java.lang.Object, java.lang.Throwable)
149+
org.apache.logging.log4j.Logger#fatal(java.lang.Object, java.lang.Throwable)

buildSrc/version.properties

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,9 @@ lucene = 8.0.0-snapshot-83f9835
44
# optional dependencies
55
spatial4j = 0.7
66
jts = 1.15.0
7+
# note that ingest-geoip has a hard-coded version; if you modify this version,
8+
# you should also inspect that version to see if it can be advanced along with
9+
# the com.maxmind.geoip2:geoip2 dependency
710
jackson = 2.8.11
811
snakeyaml = 1.17
912
icu4j = 62.1

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

Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,8 @@
2323
import org.elasticsearch.client.ccr.CcrStatsRequest;
2424
import org.elasticsearch.client.ccr.CcrStatsResponse;
2525
import org.elasticsearch.client.ccr.DeleteAutoFollowPatternRequest;
26+
import org.elasticsearch.client.ccr.FollowInfoRequest;
27+
import org.elasticsearch.client.ccr.FollowInfoResponse;
2628
import org.elasticsearch.client.ccr.FollowStatsRequest;
2729
import org.elasticsearch.client.ccr.FollowStatsResponse;
2830
import org.elasticsearch.client.ccr.GetAutoFollowPatternRequest;
@@ -452,4 +454,46 @@ public void getFollowStatsAsync(FollowStatsRequest request,
452454
);
453455
}
454456

457+
/**
458+
* Gets follow info for specific indices.
459+
*
460+
* See <a href="https://www.elastic.co/guide/en/elasticsearch/reference/current/ccr-get-follow-info.html">
461+
* the docs</a> for more.
462+
*
463+
* @param request the request
464+
* @param options the request options (e.g. headers), use {@link RequestOptions#DEFAULT} if nothing needs to be customized
465+
* @return the response
466+
* @throws IOException in case there is a problem sending the request or parsing back the response
467+
*/
468+
public FollowInfoResponse getFollowInfo(FollowInfoRequest request, RequestOptions options) throws IOException {
469+
return restHighLevelClient.performRequestAndParseEntity(
470+
request,
471+
CcrRequestConverters::getFollowInfo,
472+
options,
473+
FollowInfoResponse::fromXContent,
474+
Collections.emptySet()
475+
);
476+
}
477+
478+
/**
479+
* Asynchronously gets follow info for specific indices.
480+
*
481+
* See <a href="https://www.elastic.co/guide/en/elasticsearch/reference/current/ccr-get-follow-info.html">
482+
* the docs</a> for more.
483+
*
484+
* @param request the request
485+
* @param options the request options (e.g. headers), use {@link RequestOptions#DEFAULT} if nothing needs to be customized
486+
*/
487+
public void getFollowInfoAsync(FollowInfoRequest request,
488+
RequestOptions options,
489+
ActionListener<FollowInfoResponse> listener) {
490+
restHighLevelClient.performRequestAsyncAndParseEntity(
491+
request,
492+
CcrRequestConverters::getFollowInfo,
493+
options,
494+
FollowInfoResponse::fromXContent,
495+
listener,
496+
Collections.emptySet()
497+
);
498+
}
455499
}

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

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@
2525
import org.apache.http.client.methods.HttpPut;
2626
import org.elasticsearch.client.ccr.CcrStatsRequest;
2727
import org.elasticsearch.client.ccr.DeleteAutoFollowPatternRequest;
28+
import org.elasticsearch.client.ccr.FollowInfoRequest;
2829
import org.elasticsearch.client.ccr.FollowStatsRequest;
2930
import org.elasticsearch.client.ccr.GetAutoFollowPatternRequest;
3031
import org.elasticsearch.client.ccr.PauseFollowRequest;
@@ -119,4 +120,12 @@ static Request getFollowStats(FollowStatsRequest followStatsRequest) {
119120
return new Request(HttpGet.METHOD_NAME, endpoint);
120121
}
121122

123+
static Request getFollowInfo(FollowInfoRequest followInfoRequest) {
124+
String endpoint = new RequestConverters.EndpointBuilder()
125+
.addPathPart(followInfoRequest.getFollowerIndex())
126+
.addPathPartAsIs("_ccr", "info")
127+
.build();
128+
return new Request(HttpGet.METHOD_NAME, endpoint);
129+
}
130+
122131
}

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

Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,8 +22,10 @@
2222
import org.elasticsearch.common.ParseField;
2323
import org.elasticsearch.common.unit.ByteSizeValue;
2424
import org.elasticsearch.common.unit.TimeValue;
25+
import org.elasticsearch.common.xcontent.ObjectParser;
2526
import org.elasticsearch.common.xcontent.ToXContent;
2627
import org.elasticsearch.common.xcontent.XContentBuilder;
28+
import org.elasticsearch.common.xcontent.XContentParser;
2729

2830
import java.io.IOException;
2931
import java.util.Objects;
@@ -41,6 +43,44 @@ public class FollowConfig {
4143
static final ParseField MAX_RETRY_DELAY_FIELD = new ParseField("max_retry_delay");
4244
static final ParseField READ_POLL_TIMEOUT = new ParseField("read_poll_timeout");
4345

46+
private static final ObjectParser<FollowConfig, Void> PARSER = new ObjectParser<>(
47+
"follow_config",
48+
true,
49+
FollowConfig::new);
50+
51+
static {
52+
PARSER.declareInt(FollowConfig::setMaxReadRequestOperationCount, MAX_READ_REQUEST_OPERATION_COUNT);
53+
PARSER.declareInt(FollowConfig::setMaxOutstandingReadRequests, MAX_OUTSTANDING_READ_REQUESTS);
54+
PARSER.declareField(
55+
FollowConfig::setMaxReadRequestSize,
56+
(p, c) -> ByteSizeValue.parseBytesSizeValue(p.text(), MAX_READ_REQUEST_SIZE.getPreferredName()),
57+
MAX_READ_REQUEST_SIZE,
58+
ObjectParser.ValueType.STRING);
59+
PARSER.declareInt(FollowConfig::setMaxWriteRequestOperationCount, MAX_WRITE_REQUEST_OPERATION_COUNT);
60+
PARSER.declareField(
61+
FollowConfig::setMaxWriteRequestSize,
62+
(p, c) -> ByteSizeValue.parseBytesSizeValue(p.text(), MAX_WRITE_REQUEST_SIZE.getPreferredName()),
63+
MAX_WRITE_REQUEST_SIZE,
64+
ObjectParser.ValueType.STRING);
65+
PARSER.declareInt(FollowConfig::setMaxOutstandingWriteRequests, MAX_OUTSTANDING_WRITE_REQUESTS);
66+
PARSER.declareInt(FollowConfig::setMaxWriteBufferCount, MAX_WRITE_BUFFER_COUNT);
67+
PARSER.declareField(
68+
FollowConfig::setMaxWriteBufferSize,
69+
(p, c) -> ByteSizeValue.parseBytesSizeValue(p.text(), MAX_WRITE_BUFFER_SIZE.getPreferredName()),
70+
MAX_WRITE_BUFFER_SIZE,
71+
ObjectParser.ValueType.STRING);
72+
PARSER.declareField(FollowConfig::setMaxRetryDelay,
73+
(p, c) -> TimeValue.parseTimeValue(p.text(), MAX_RETRY_DELAY_FIELD.getPreferredName()),
74+
MAX_RETRY_DELAY_FIELD, ObjectParser.ValueType.STRING);
75+
PARSER.declareField(FollowConfig::setReadPollTimeout,
76+
(p, c) -> TimeValue.parseTimeValue(p.text(), READ_POLL_TIMEOUT.getPreferredName()),
77+
READ_POLL_TIMEOUT, ObjectParser.ValueType.STRING);
78+
}
79+
80+
static FollowConfig fromXContent(XContentParser parser) {
81+
return PARSER.apply(parser, null);
82+
}
83+
4484
private Integer maxReadRequestOperationCount;
4585
private Integer maxOutstandingReadRequests;
4686
private ByteSizeValue maxReadRequestSize;
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 FollowInfoRequest implements Validatable {
27+
28+
private final String followerIndex;
29+
30+
public FollowInfoRequest(String followerIndex) {
31+
this.followerIndex = Objects.requireNonNull(followerIndex);
32+
}
33+
34+
public String getFollowerIndex() {
35+
return followerIndex;
36+
}
37+
}

0 commit comments

Comments
 (0)