Skip to content

Commit 4d6f556

Browse files
committed
Merge branch '6.x' into feature-jindex-6x
2 parents a3ce149 + 6869ace commit 4d6f556

File tree

662 files changed

+25717
-8779
lines changed

Some content is hidden

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

662 files changed

+25717
-8779
lines changed

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

Lines changed: 40 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -215,6 +215,7 @@ class BuildPlugin implements Plugin<Project> {
215215
project.rootProject.ext.inFipsJvm = inFipsJvm
216216
project.rootProject.ext.gradleJavaVersion = JavaVersion.toVersion(gradleJavaVersion)
217217
project.rootProject.ext.java9Home = "${-> findJavaHome("9")}"
218+
project.rootProject.ext.defaultParallel = findDefaultParallel(project.rootProject)
218219
}
219220

220221
project.targetCompatibility = project.rootProject.ext.minimumRuntimeVersion
@@ -774,32 +775,9 @@ class BuildPlugin implements Plugin<Project> {
774775
}
775776

776777
static void applyCommonTestConfig(Project project) {
777-
String defaultParallel = 'auto'
778-
// Count physical cores on any Linux distro ( don't count hyper-threading )
779-
if (project.file("/proc/cpuinfo").exists()) {
780-
Map<String, Integer> socketToCore = [:]
781-
String currentID = ""
782-
project.file("/proc/cpuinfo").readLines().forEach({ line ->
783-
if (line.contains(":")) {
784-
List<String> parts = line.split(":", 2).collect({it.trim()})
785-
String name = parts[0], value = parts[1]
786-
// the ID of the CPU socket
787-
if (name == "physical id") {
788-
currentID = value
789-
}
790-
// Number of cores not including hyper-threading
791-
if (name == "cpu cores") {
792-
assert currentID.isEmpty() == false
793-
socketToCore[currentID] = Integer.valueOf(value)
794-
currentID = ""
795-
}
796-
}
797-
})
798-
defaultParallel = socketToCore.values().sum().toString();
799-
}
800778
project.tasks.withType(RandomizedTestingTask) {
801779
jvm "${project.runtimeJavaHome}/bin/java"
802-
parallelism System.getProperty('tests.jvms', defaultParallel)
780+
parallelism System.getProperty('tests.jvms', project.rootProject.ext.defaultParallel)
803781
ifNoTests System.getProperty('tests.ifNoTests', 'fail')
804782
onNonEmptyWorkDirectory 'wipe'
805783
leaveTemporary true
@@ -849,6 +827,9 @@ class BuildPlugin implements Plugin<Project> {
849827
// TODO: remove this once ctx isn't added to update script params in 7.0
850828
systemProperty 'es.scripting.update.ctx_in_params', 'false'
851829

830+
//TODO: remove this once the cname is prepended to the address by default in 7.0
831+
systemProperty 'es.http.cname_in_publish_address', 'true'
832+
852833
// Set the system keystore/truststore password if we're running tests in a FIPS-140 JVM
853834
if (project.inFipsJvm) {
854835
systemProperty 'javax.net.ssl.trustStorePassword', 'password'
@@ -905,6 +886,41 @@ class BuildPlugin implements Plugin<Project> {
905886
}
906887
}
907888

889+
private static String findDefaultParallel(Project project) {
890+
if (project.file("/proc/cpuinfo").exists()) {
891+
// Count physical cores on any Linux distro ( don't count hyper-threading )
892+
Map<String, Integer> socketToCore = [:]
893+
String currentID = ""
894+
project.file("/proc/cpuinfo").readLines().forEach({ line ->
895+
if (line.contains(":")) {
896+
List<String> parts = line.split(":", 2).collect({it.trim()})
897+
String name = parts[0], value = parts[1]
898+
// the ID of the CPU socket
899+
if (name == "physical id") {
900+
currentID = value
901+
}
902+
// Number of cores not including hyper-threading
903+
if (name == "cpu cores") {
904+
assert currentID.isEmpty() == false
905+
socketToCore[currentID] = Integer.valueOf(value)
906+
currentID = ""
907+
}
908+
}
909+
})
910+
return socketToCore.values().sum().toString();
911+
} else if ('Mac OS X'.equals(System.getProperty('os.name'))) {
912+
// Ask macOS to count physical CPUs for us
913+
ByteArrayOutputStream stdout = new ByteArrayOutputStream()
914+
project.exec {
915+
executable 'sysctl'
916+
args '-n', 'hw.physicalcpu'
917+
standardOutput = stdout
918+
}
919+
return stdout.toString('UTF-8').trim();
920+
}
921+
return 'auto';
922+
}
923+
908924
/** Configures the test task */
909925
static Task configureTest(Project project) {
910926
project.tasks.getByName('test') {

buildSrc/src/main/resources/checkstyle_suppressions.xml

Lines changed: 2 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -174,16 +174,7 @@
174174
<suppress files="server[/\\]src[/\\]test[/\\]java[/\\]org[/\\]elasticsearch[/\\]search[/\\]suggest[/\\]completion[/\\]CategoryContextMappingTests.java" checks="LineLength" />
175175
<suppress files="server[/\\]src[/\\]test[/\\]java[/\\]org[/\\]elasticsearch[/\\]search[/\\]suggest[/\\]completion[/\\]GeoContextMappingTests.java" checks="LineLength" />
176176
<suppress files="server[/\\]src[/\\]test[/\\]java[/\\]org[/\\]elasticsearch[/\\]search[/\\]suggest[/\\]phrase[/\\]NoisyChannelSpellCheckerTests.java" checks="LineLength" />
177-
<suppress files="server[/\\]src[/\\]test[/\\]java[/\\]org[/\\]elasticsearch[/\\]similarity[/\\]SimilarityIT.java" checks="LineLength" />
178-
<suppress files="server[/\\]src[/\\]test[/\\]java[/\\]org[/\\]elasticsearch[/\\]snapshots[/\\]AbstractSnapshotIntegTestCase.java" checks="LineLength" />
179-
<suppress files="server[/\\]src[/\\]test[/\\]java[/\\]org[/\\]elasticsearch[/\\]snapshots[/\\]DedicatedClusterSnapshotRestoreIT.java" checks="LineLength" />
180-
<suppress files="server[/\\]src[/\\]test[/\\]java[/\\]org[/\\]elasticsearch[/\\]snapshots[/\\]RepositoriesIT.java" checks="LineLength" />
181-
<suppress files="server[/\\]src[/\\]test[/\\]java[/\\]org[/\\]elasticsearch[/\\]snapshots[/\\]SharedClusterSnapshotRestoreIT.java" checks="LineLength" />
182-
<suppress files="server[/\\]src[/\\]test[/\\]java[/\\]org[/\\]elasticsearch[/\\]snapshots[/\\]SnapshotUtilsTests.java" checks="LineLength" />
183-
<suppress files="server[/\\]src[/\\]test[/\\]java[/\\]org[/\\]elasticsearch[/\\]test[/\\]geo[/\\]RandomShapeGenerator.java" checks="LineLength" />
184-
<suppress files="server[/\\]src[/\\]test[/\\]java[/\\]org[/\\]elasticsearch[/\\]test[/\\]hamcrest[/\\]ElasticsearchGeoAssertions.java" checks="LineLength" />
185-
<suppress files="server[/\\]src[/\\]test[/\\]java[/\\]org[/\\]elasticsearch[/\\]update[/\\]UpdateIT.java" checks="LineLength" />
186-
<suppress files="server[/\\]src[/\\]test[/\\]java[/\\]org[/\\]elasticsearch[/\\]validate[/\\]SimpleValidateQueryIT.java" checks="LineLength" />
187-
<suppress files="server[/\\]src[/\\]test[/\\]java[/\\]org[/\\]elasticsearch[/\\]versioning[/\\]SimpleVersioningIT.java" checks="LineLength" />
177+
178+
<!-- Temporarily contains extra-long lines as examples for tests to be written, see https://github.com/elastic/elasticsearch/issues/34829 -->
188179
<suppress files="modules[/\\]lang-painless[/\\]src[/\\]test[/\\]java[/\\]org[/\\]elasticsearch[/\\]painless[/\\]ContextExampleTests.java" checks="LineLength" />
189180
</suppressions>

buildSrc/src/main/resources/eclipse.settings/org.eclipse.jdt.core.prefs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@ eclipse.preferences.version=1
1616
# org.eclipse.jdt.core.compiler.problem.potentialNullReference=warning
1717

1818
org.eclipse.jdt.core.compiler.problem.forbiddenReference=warning
19+
org.eclipse.jdt.core.formatter.comment.line_length=140
1920
org.eclipse.jdt.core.formatter.lineSplit=140
2021
org.eclipse.jdt.core.formatter.tabulation.char=space
2122
org.eclipse.jdt.core.formatter.tabulation.size=4

buildSrc/version.properties

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ slf4j = 1.6.2
1515
# when updating the JNA version, also update the version in buildSrc/build.gradle
1616
jna = 4.5.1
1717

18-
netty = 4.1.30.Final
18+
netty = 4.1.31.Final
1919
joda = 2.10.1
2020

2121
# test dependencies

client/benchmark/README.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
### Steps to execute the benchmark
22

3-
1. Build `client-benchmark-noop-api-plugin` with `gradle :client:client-benchmark-noop-api-plugin:assemble`
4-
2. Install it on the target host with `bin/elasticsearch-plugin install file:///full/path/to/client-benchmark-noop-api-plugin.zip`
3+
1. Build `client-benchmark-noop-api-plugin` with `./gradlew :client:client-benchmark-noop-api-plugin:assemble`
4+
2. Install it on the target host with `bin/elasticsearch-plugin install file:///full/path/to/client-benchmark-noop-api-plugin.zip`.
55
3. Start Elasticsearch on the target host (ideally *not* on the machine
66
that runs the benchmarks)
77
4. Run the benchmark with
@@ -49,7 +49,7 @@ The parameters are all in the `'`s and are in order:
4949
Example invocation:
5050

5151
```
52-
gradlew -p client/benchmark run --args ' rest search localhost geonames {"query":{"match_phrase":{"name":"Sankt Georgen"}}} 500,1000,1100,1200'
52+
./gradlew -p client/benchmark run --args ' rest search localhost geonames {"query":{"match_phrase":{"name":"Sankt Georgen"}}} 500,1000,1100,1200'
5353
```
5454

5555
The parameters are in order:

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

Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@
2121

2222
import org.elasticsearch.action.ActionListener;
2323
import org.elasticsearch.client.ccr.PauseFollowRequest;
24+
import org.elasticsearch.client.ccr.PutAutoFollowPatternRequest;
2425
import org.elasticsearch.client.ccr.PutFollowRequest;
2526
import org.elasticsearch.client.ccr.PutFollowResponse;
2627
import org.elasticsearch.client.ccr.ResumeFollowRequest;
@@ -219,4 +220,46 @@ public void unfollowAsync(UnfollowRequest request,
219220
);
220221
}
221222

223+
/**
224+
* Stores an auto follow pattern.
225+
*
226+
* See <a href="https://www.elastic.co/guide/en/elasticsearch/reference/current/ccr-put-auto-follow-pattern.html">
227+
* the docs</a> for more.
228+
*
229+
* @param request the request
230+
* @param options the request options (e.g. headers), use {@link RequestOptions#DEFAULT} if nothing needs to be customized
231+
* @return the response
232+
* @throws IOException in case there is a problem sending the request or parsing back the response
233+
*/
234+
public AcknowledgedResponse putAutoFollowPattern(PutAutoFollowPatternRequest request, RequestOptions options) throws IOException {
235+
return restHighLevelClient.performRequestAndParseEntity(
236+
request,
237+
CcrRequestConverters::putAutoFollowPattern,
238+
options,
239+
AcknowledgedResponse::fromXContent,
240+
Collections.emptySet()
241+
);
242+
}
243+
244+
/**
245+
* Asynchronously stores an auto follow pattern.
246+
*
247+
* See <a href="https://www.elastic.co/guide/en/elasticsearch/reference/current/ccr-put-auto-follow-pattern.html">
248+
* the docs</a> for more.
249+
*
250+
* @param request the request
251+
* @param options the request options (e.g. headers), use {@link RequestOptions#DEFAULT} if nothing needs to be customized
252+
*/
253+
public void putAutoFollowPatternAsync(PutAutoFollowPatternRequest request,
254+
RequestOptions options,
255+
ActionListener<AcknowledgedResponse> listener) {
256+
restHighLevelClient.performRequestAsyncAndParseEntity(
257+
request,
258+
CcrRequestConverters::putAutoFollowPattern,
259+
options,
260+
AcknowledgedResponse::fromXContent,
261+
listener,
262+
Collections.emptySet());
263+
}
264+
222265
}

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

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@
2222
import org.apache.http.client.methods.HttpPost;
2323
import org.apache.http.client.methods.HttpPut;
2424
import org.elasticsearch.client.ccr.PauseFollowRequest;
25+
import org.elasticsearch.client.ccr.PutAutoFollowPatternRequest;
2526
import org.elasticsearch.client.ccr.PutFollowRequest;
2627
import org.elasticsearch.client.ccr.ResumeFollowRequest;
2728
import org.elasticsearch.client.ccr.UnfollowRequest;
@@ -69,4 +70,14 @@ static Request unfollow(UnfollowRequest unfollowRequest) {
6970
return new Request(HttpPost.METHOD_NAME, endpoint);
7071
}
7172

73+
static Request putAutoFollowPattern(PutAutoFollowPatternRequest putAutoFollowPatternRequest) throws IOException {
74+
String endpoint = new RequestConverters.EndpointBuilder()
75+
.addPathPartAsIs("_ccr", "auto_follow")
76+
.addPathPart(putAutoFollowPatternRequest.getName())
77+
.build();
78+
Request request = new Request(HttpPut.METHOD_NAME, endpoint);
79+
request.setEntity(createEntity(putAutoFollowPatternRequest, REQUEST_BODY_CONTENT_TYPE));
80+
return request;
81+
}
82+
7283
}

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

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -126,10 +126,9 @@ static Request lifecycleManagementStatus(LifecycleManagementStatusRequest lifecy
126126
}
127127

128128
static Request explainLifecycle(ExplainLifecycleRequest explainLifecycleRequest) {
129-
String[] indices = explainLifecycleRequest.indices() == null ? Strings.EMPTY_ARRAY : explainLifecycleRequest.indices();
130129
Request request = new Request(HttpGet.METHOD_NAME,
131130
new RequestConverters.EndpointBuilder()
132-
.addCommaSeparatedPathParts(indices)
131+
.addCommaSeparatedPathParts(explainLifecycleRequest.getIndices())
133132
.addPathPartAsIs("_ilm")
134133
.addPathPartAsIs("explain")
135134
.build());

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

Lines changed: 50 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -60,6 +60,9 @@
6060
import org.elasticsearch.action.admin.indices.validate.query.ValidateQueryRequest;
6161
import org.elasticsearch.action.admin.indices.validate.query.ValidateQueryResponse;
6262
import org.elasticsearch.action.support.master.AcknowledgedResponse;
63+
import org.elasticsearch.client.core.ShardsAcknowledgedResponse;
64+
import org.elasticsearch.client.indices.FreezeIndexRequest;
65+
import org.elasticsearch.client.indices.UnfreezeIndexRequest;
6366
import org.elasticsearch.rest.RestStatus;
6467

6568
import java.io.IOException;
@@ -1266,4 +1269,51 @@ public void analyzeAsync(AnalyzeRequest request, RequestOptions options,
12661269
restHighLevelClient.performRequestAsyncAndParseEntity(request, IndicesRequestConverters::analyze, options,
12671270
AnalyzeResponse::fromXContent, listener, emptySet());
12681271
}
1272+
1273+
/**
1274+
* Synchronously calls the _freeze API
1275+
*
1276+
* @param request the request
1277+
* @param options the request options (e.g. headers), use {@link RequestOptions#DEFAULT} if nothing needs to be customized
1278+
*/
1279+
public ShardsAcknowledgedResponse freeze(FreezeIndexRequest request, RequestOptions options) throws IOException {
1280+
return restHighLevelClient.performRequestAndParseEntity(request, IndicesRequestConverters::freezeIndex, options,
1281+
ShardsAcknowledgedResponse::fromXContent, emptySet());
1282+
}
1283+
1284+
/**
1285+
* Asynchronously calls the _freeze API
1286+
*
1287+
* @param request the request
1288+
* @param options the request options (e.g. headers), use {@link RequestOptions#DEFAULT} if nothing needs to be customized
1289+
* @param listener the listener to be notified upon request completion
1290+
*/
1291+
public void freezeAsync(FreezeIndexRequest request, RequestOptions options, ActionListener<ShardsAcknowledgedResponse> listener) {
1292+
restHighLevelClient.performRequestAsyncAndParseEntity(request, IndicesRequestConverters::freezeIndex, options,
1293+
ShardsAcknowledgedResponse::fromXContent, listener, emptySet());
1294+
}
1295+
1296+
/**
1297+
* Synchronously calls the _unfreeze API
1298+
*
1299+
* @param request the request
1300+
* @param options the request options (e.g. headers), use {@link RequestOptions#DEFAULT} if nothing needs to be customized
1301+
*/
1302+
public ShardsAcknowledgedResponse unfreeze(UnfreezeIndexRequest request, RequestOptions options) throws IOException {
1303+
return restHighLevelClient.performRequestAndParseEntity(request, IndicesRequestConverters::unfreezeIndex, options,
1304+
ShardsAcknowledgedResponse::fromXContent, emptySet());
1305+
}
1306+
1307+
/**
1308+
* Asynchronously calls the _unfreeze API
1309+
*
1310+
* @param request the request
1311+
* @param options the request options (e.g. headers), use {@link RequestOptions#DEFAULT} if nothing needs to be customized
1312+
* @param listener the listener to be notified upon request completion
1313+
*/
1314+
public void unfreezeAsync(UnfreezeIndexRequest request, RequestOptions options, ActionListener<ShardsAcknowledgedResponse> listener) {
1315+
restHighLevelClient.performRequestAsyncAndParseEntity(request, IndicesRequestConverters::unfreezeIndex, options,
1316+
ShardsAcknowledgedResponse::fromXContent, listener, emptySet());
1317+
}
1318+
12691319
}

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

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,8 @@
4949
import org.elasticsearch.action.admin.indices.template.put.PutIndexTemplateRequest;
5050
import org.elasticsearch.action.admin.indices.validate.query.ValidateQueryRequest;
5151
import org.elasticsearch.action.support.ActiveShardCount;
52+
import org.elasticsearch.client.indices.FreezeIndexRequest;
53+
import org.elasticsearch.client.indices.UnfreezeIndexRequest;
5254
import org.elasticsearch.common.Strings;
5355

5456
import java.io.IOException;
@@ -404,4 +406,26 @@ static Request analyze(AnalyzeRequest request) throws IOException {
404406
req.setEntity(RequestConverters.createEntity(request, RequestConverters.REQUEST_BODY_CONTENT_TYPE));
405407
return req;
406408
}
409+
410+
static Request freezeIndex(FreezeIndexRequest freezeIndexRequest) {
411+
String endpoint = RequestConverters.endpoint(freezeIndexRequest.getIndices(), "_freeze");
412+
Request request = new Request(HttpPost.METHOD_NAME, endpoint);
413+
RequestConverters.Params parameters = new RequestConverters.Params(request);
414+
parameters.withTimeout(freezeIndexRequest.timeout());
415+
parameters.withMasterTimeout(freezeIndexRequest.masterNodeTimeout());
416+
parameters.withIndicesOptions(freezeIndexRequest.indicesOptions());
417+
parameters.withWaitForActiveShards(freezeIndexRequest.getWaitForActiveShards(), ActiveShardCount.DEFAULT);
418+
return request;
419+
}
420+
421+
static Request unfreezeIndex(UnfreezeIndexRequest unfreezeIndexRequest) {
422+
String endpoint = RequestConverters.endpoint(unfreezeIndexRequest.getIndices(), "_unfreeze");
423+
Request request = new Request(HttpPost.METHOD_NAME, endpoint);
424+
RequestConverters.Params parameters = new RequestConverters.Params(request);
425+
parameters.withTimeout(unfreezeIndexRequest.timeout());
426+
parameters.withMasterTimeout(unfreezeIndexRequest.masterNodeTimeout());
427+
parameters.withIndicesOptions(unfreezeIndexRequest.indicesOptions());
428+
parameters.withWaitForActiveShards(unfreezeIndexRequest.getWaitForActiveShards(), ActiveShardCount.DEFAULT);
429+
return request;
430+
}
407431
}

0 commit comments

Comments
 (0)