Skip to content

Commit 6f969f5

Browse files
committed
Merge remote-tracking branch 'es/ccr' into ccr_security
* es/ccr: (78 commits) Upgrade to Lucene-7.4-snapshot-6705632810 (#30519) add version compatibility from 6.4.0 after backport, see #30319 (#30390) Security: Simplify security index listeners (#30466) Add proper longitude validation in geo_polygon_query (#30497) Remove Discovery.AckListener.onTimeout() (#30514) Build: move generated-resources to build (#30366) Reindex: Fold "with all deps" project into reindex (#30154) Isolate REST client single host tests (#30504) Solve Gradle deprecation warnings around shadowJar (#30483) SAML: Process only signed data (#30420) Remove BWC repository test (#30500) Build: Remove xpack specific run task (#30487) AwaitsFix IntegTestZipClientYamlTestSuiteIT#indices.split tests Enable soft-deletes in v6.4 LLClient: Add setJsonEntity (#30447) [CCR] Read changes from Lucene instead of translog (#30120) Expose CommonStatsFlags directly in IndicesStatsRequest. (#30163) Silence IndexUpgradeIT test failures. (#30430) Bump Gradle heap to 1792m (#30484) [docs] add warning for read-write indices in force merge documentation (#28869) ...
2 parents 9f42dd1 + a5be414 commit 6f969f5

File tree

353 files changed

+7516
-2215
lines changed

Some content is hidden

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

353 files changed

+7516
-2215
lines changed

CONTRIBUTING.md

+90-1
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ We enjoy working with contributors to get their code accepted. There are many ap
4141
Note that it is unlikely the project will merge refactors for the sake of refactoring. These
4242
types of pull requests have a high cost to maintainers in reviewing and testing with little
4343
to no tangible benefit. This especially includes changes generated by tools. For example,
44-
converting all generic interface instances to use the diamond operator.
44+
converting all generic interface instances to use the diamond operator.
4545

4646
The process for contributing to any of the [Elastic repositories](https://github.com/elastic/) is similar. Details for individual projects can be found below.
4747

@@ -209,6 +209,95 @@ Before submitting your changes, run the test suite to make sure that nothing is
209209
./gradlew check
210210
```
211211

212+
### Project layout
213+
214+
This repository is split into many top level directories. The most important
215+
ones are:
216+
217+
#### `docs`
218+
Documentation for the project.
219+
220+
#### `distribution`
221+
Builds our tar and zip archives and our rpm and deb packages.
222+
223+
#### `libs`
224+
Libraries used to build other parts of the project. These are meant to be
225+
internal rather than general purpose. We have no plans to
226+
[semver](https://semver.org/) their APIs or accept feature requests for them.
227+
We publish them to maven central because they are dependencies of our plugin
228+
test framework, high level rest client, and jdbc driver but they really aren't
229+
general purpose enough to *belong* in maven central. We're still working out
230+
what to do here.
231+
232+
#### `modules`
233+
Features that are shipped with Elasticsearch by default but are not built in to
234+
the server. We typically separate features from the server because they require
235+
permissions that we don't believe *all* of Elasticsearch should have or because
236+
they depend on libraries that we don't believe *all* of Elasticsearch should
237+
depend on.
238+
239+
For example, reindex requires the `connect` permission so it can perform
240+
reindex-from-remote but we don't believe that the *all* of Elasticsearch should
241+
have the "connect". For another example, Painless is implemented using antlr4
242+
and asm and we don't believe that *all* of Elasticsearch should have access to
243+
them.
244+
245+
#### `plugins`
246+
Officially supported plugins to Elasticsearch. We decide that a feature should
247+
be a plugin rather than shipped as a module because we feel that it is only
248+
important to a subset of users, especially if it requires extra dependencies.
249+
250+
The canonical example of this is the ICU analysis plugin. It is important for
251+
folks who want the fairly language neutral ICU analyzer but the library to
252+
implement the analyzer is 11MB so we don't ship it with Elasticsearch by
253+
default.
254+
255+
Another example is the `discovery-gce` plugin. It is *vital* to folks running
256+
in [GCP](https://cloud.google.com/) but useless otherwise and it depends on a
257+
dozen extra jars.
258+
259+
#### `qa`
260+
Honestly this is kind of in flux and we're not 100% sure where we'll end up.
261+
Right now the directory contains
262+
* Tests that require multiple modules or plugins to work
263+
* Tests that form a cluster made up of multiple versions of Elasticsearch like
264+
full cluster restart, rolling restarts, and mixed version tests
265+
* Tests that test the Elasticsearch clients in "interesting" places like the
266+
`wildfly` project.
267+
* Tests that test Elasticsearch in funny configurations like with ingest
268+
disabled
269+
* Tests that need to do strange things like install plugins that thrown
270+
uncaught `Throwable`s or add a shutdown hook
271+
But we're not convinced that all of these things *belong* in the qa directory.
272+
We're fairly sure that tests that require multiple modules or plugins to work
273+
should just pick a "home" plugin. We're fairly sure that the multi-version
274+
tests *do* belong in qa. Beyond that, we're not sure. If you want to add a new
275+
qa project, open a PR and be ready to discuss options.
276+
277+
#### `server`
278+
The server component of Elasticsearch that contains all of the modules and
279+
plugins. Right now things like the high level rest client depend on the server
280+
but we'd like to fix that in the future.
281+
282+
#### `test`
283+
Our test framework and test fixtures. We use the test framework for testing the
284+
server, the plugins, and modules, and pretty much everything else. We publish
285+
the test framework so folks who develop Elasticsearch plugins can use it to
286+
test the plugins. The test fixtures are external processes that we start before
287+
running specific tests that rely on them.
288+
289+
For example, we have an hdfs test that uses mini-hdfs to test our
290+
repository-hdfs plugin.
291+
292+
#### `x-pack`
293+
Commercially licensed code that integrates with the rest of Elasticsearch. The
294+
`docs` subdirectory functions just like the top level `docs` subdirectory and
295+
the `qa` subdirectory functions just like the top level `qa` subdirectory. The
296+
`plugin` subdirectory contains the x-pack module which runs inside the
297+
Elasticsearch process. The `transport-client` subdirectory contains extensions
298+
to Elasticsearch's standard transport client to work properly with x-pack.
299+
300+
212301
Contributing as part of a class
213302
-------------------------------
214303
In general Elasticsearch is happy to accept contributions that were created as

benchmarks/build.gradle

+6-6
Original file line numberDiff line numberDiff line change
@@ -24,22 +24,22 @@ buildscript {
2424
}
2525
}
2626
dependencies {
27-
classpath 'com.github.jengelman.gradle.plugins:shadow:2.0.2'
27+
classpath 'com.github.jengelman.gradle.plugins:shadow:2.0.4'
2828
}
2929
}
3030

3131
apply plugin: 'elasticsearch.build'
32-
// build an uberjar with all benchmarks
33-
apply plugin: 'com.github.johnrengelman.shadow'
34-
// have the shadow plugin provide the runShadow task
35-
apply plugin: 'application'
32+
33+
// order of this seciont matters, see: https://github.com/johnrengelman/shadow/issues/336
34+
apply plugin: 'application' // have the shadow plugin provide the runShadow task
35+
mainClassName = 'org.openjdk.jmh.Main'
36+
apply plugin: 'com.github.johnrengelman.shadow' // build an uberjar with all benchmarks
3637

3738
// Not published so no need to assemble
3839
tasks.remove(assemble)
3940
build.dependsOn.remove('assemble')
4041

4142
archivesBaseName = 'elasticsearch-benchmarks'
42-
mainClassName = 'org.openjdk.jmh.Main'
4343

4444
test.enabled = false
4545

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

+23-8
Original file line numberDiff line numberDiff line change
@@ -497,10 +497,15 @@ class BuildPlugin implements Plugin<Project> {
497497
project.afterEvaluate {
498498
project.tasks.withType(JavaCompile) {
499499
final JavaVersion targetCompatibilityVersion = JavaVersion.toVersion(it.targetCompatibility)
500-
// we fork because compiling lots of different classes in a shared jvm can eventually trigger GC overhead limitations
501-
options.fork = true
502-
options.forkOptions.javaHome = new File(project.compilerJavaHome)
503-
options.forkOptions.memoryMaximumSize = "512m"
500+
final compilerJavaHomeFile = new File(project.compilerJavaHome)
501+
// we only fork if the Gradle JDK is not the same as the compiler JDK
502+
if (compilerJavaHomeFile.canonicalPath == Jvm.current().javaHome.canonicalPath) {
503+
options.fork = false
504+
} else {
505+
options.fork = true
506+
options.forkOptions.javaHome = compilerJavaHomeFile
507+
options.forkOptions.memoryMaximumSize = "512m"
508+
}
504509
if (targetCompatibilityVersion == JavaVersion.VERSION_1_8) {
505510
// compile with compact 3 profile by default
506511
// NOTE: this is just a compile time check: does not replace testing with a compact3 JRE
@@ -530,10 +535,15 @@ class BuildPlugin implements Plugin<Project> {
530535
}
531536
// also apply release flag to groovy, which is used in build-tools
532537
project.tasks.withType(GroovyCompile) {
533-
final JavaVersion targetCompatibilityVersion = JavaVersion.toVersion(it.targetCompatibility)
534-
options.fork = true
535-
options.forkOptions.javaHome = new File(project.compilerJavaHome)
536-
options.compilerArgs << '--release' << targetCompatibilityVersion.majorVersion
538+
final compilerJavaHomeFile = new File(project.compilerJavaHome)
539+
// we only fork if the Gradle JDK is not the same as the compiler JDK
540+
if (compilerJavaHomeFile.canonicalPath == Jvm.current().javaHome.canonicalPath) {
541+
options.fork = false
542+
} else {
543+
options.fork = true
544+
options.forkOptions.javaHome = compilerJavaHomeFile
545+
options.compilerArgs << '--release' << JavaVersion.toVersion(it.targetCompatibility).majorVersion
546+
}
537547
}
538548
}
539549
}
@@ -549,6 +559,11 @@ class BuildPlugin implements Plugin<Project> {
549559
javadoc.classpath = javadoc.getClasspath().filter { f ->
550560
return classes.contains(f) == false
551561
}
562+
/*
563+
* Generate docs using html5 to suppress a warning from `javadoc`
564+
* that the default will change to html5 in the future.
565+
*/
566+
javadoc.options.addBooleanOption('html5', true)
552567
}
553568
configureJavadocJar(project)
554569
}

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

+9-2
Original file line numberDiff line numberDiff line change
@@ -141,9 +141,11 @@ public class RestTestsFromSnippetsTask extends SnippetsTask {
141141
private static final String SYNTAX = {
142142
String method = /(?<method>GET|PUT|POST|HEAD|OPTIONS|DELETE)/
143143
String pathAndQuery = /(?<pathAndQuery>[^\n]+)/
144-
String badBody = /GET|PUT|POST|HEAD|OPTIONS|DELETE|#/
144+
String badBody = /GET|PUT|POST|HEAD|OPTIONS|DELETE|startyaml|#/
145145
String body = /(?<body>(?:\n(?!$badBody)[^\n]+)+)/
146-
String nonComment = /$method\s+$pathAndQuery$body?/
146+
String rawRequest = /(?:$method\s+$pathAndQuery$body?)/
147+
String yamlRequest = /(?:startyaml(?s)(?<yaml>.+?)(?-s)endyaml)/
148+
String nonComment = /(?:$rawRequest|$yamlRequest)/
147149
String comment = /(?<comment>#.+)/
148150
/(?:$comment|$nonComment)\n+/
149151
}()
@@ -333,6 +335,11 @@ public class RestTestsFromSnippetsTask extends SnippetsTask {
333335
// Comment
334336
return
335337
}
338+
String yamlRequest = matcher.group("yaml");
339+
if (yamlRequest != null) {
340+
current.println(yamlRequest)
341+
return
342+
}
336343
String method = matcher.group("method")
337344
String pathAndQuery = matcher.group("pathAndQuery")
338345
String body = matcher.group("body")

buildSrc/version.properties

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
elasticsearch = 7.0.0-alpha1
2-
lucene = 7.4.0-snapshot-1ed95c097b
2+
lucene = 7.4.0-snapshot-6705632810
33

44
# optional dependencies
55
spatial4j = 0.7

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

+48
Original file line numberDiff line numberDiff line change
@@ -43,12 +43,16 @@
4343
import org.elasticsearch.action.admin.indices.open.OpenIndexResponse;
4444
import org.elasticsearch.action.admin.indices.refresh.RefreshRequest;
4545
import org.elasticsearch.action.admin.indices.refresh.RefreshResponse;
46+
import org.elasticsearch.action.admin.indices.settings.get.GetSettingsRequest;
47+
import org.elasticsearch.action.admin.indices.settings.get.GetSettingsResponse;
4648
import org.elasticsearch.action.admin.indices.rollover.RolloverRequest;
4749
import org.elasticsearch.action.admin.indices.rollover.RolloverResponse;
4850
import org.elasticsearch.action.admin.indices.settings.put.UpdateSettingsRequest;
4951
import org.elasticsearch.action.admin.indices.settings.put.UpdateSettingsResponse;
5052
import org.elasticsearch.action.admin.indices.shrink.ResizeRequest;
5153
import org.elasticsearch.action.admin.indices.shrink.ResizeResponse;
54+
import org.elasticsearch.action.admin.indices.template.put.PutIndexTemplateRequest;
55+
import org.elasticsearch.action.admin.indices.template.put.PutIndexTemplateResponse;
5256

5357
import java.io.IOException;
5458
import java.util.Collections;
@@ -265,6 +269,28 @@ public void flushAsync(FlushRequest flushRequest, ActionListener<FlushResponse>
265269
listener, emptySet(), headers);
266270
}
267271

272+
/**
273+
* Retrieve the settings of one or more indices
274+
* <p>
275+
* See <a href="https://www.elastic.co/guide/en/elasticsearch/reference/current/indices-get-settings.html">
276+
* Indices Get Settings API on elastic.co</a>
277+
*/
278+
public GetSettingsResponse getSettings(GetSettingsRequest getSettingsRequest, Header... headers) throws IOException {
279+
return restHighLevelClient.performRequestAndParseEntity(getSettingsRequest, RequestConverters::getSettings,
280+
GetSettingsResponse::fromXContent, emptySet(), headers);
281+
}
282+
283+
/**
284+
* Asynchronously retrieve the settings of one or more indices
285+
* <p>
286+
* See <a href="https://www.elastic.co/guide/en/elasticsearch/reference/current/indices-get-settings.html">
287+
* Indices Get Settings API on elastic.co</a>
288+
*/
289+
public void getSettingsAsync(GetSettingsRequest getSettingsRequest, ActionListener<GetSettingsResponse> listener, Header... headers) {
290+
restHighLevelClient.performRequestAsyncAndParseEntity(getSettingsRequest, RequestConverters::getSettings,
291+
GetSettingsResponse::fromXContent, listener, emptySet(), headers);
292+
}
293+
268294
/**
269295
* Force merge one or more indices using the Force Merge API
270296
* <p>
@@ -432,4 +458,26 @@ public void putSettingsAsync(UpdateSettingsRequest updateSettingsRequest, Action
432458
UpdateSettingsResponse::fromXContent, listener, emptySet(), headers);
433459
}
434460

461+
/**
462+
* Puts an index template using the Index Templates API
463+
* <p>
464+
* See <a href="https://www.elastic.co/guide/en/elasticsearch/reference/current/indices-templates.html"> Index Templates API
465+
* on elastic.co</a>
466+
*/
467+
public PutIndexTemplateResponse putTemplate(PutIndexTemplateRequest putIndexTemplateRequest, Header... headers) throws IOException {
468+
return restHighLevelClient.performRequestAndParseEntity(putIndexTemplateRequest, RequestConverters::putTemplate,
469+
PutIndexTemplateResponse::fromXContent, emptySet(), headers);
470+
}
471+
472+
/**
473+
* Asynchronously puts an index template using the Index Templates API
474+
* <p>
475+
* See <a href="https://www.elastic.co/guide/en/elasticsearch/reference/current/indices-templates.html"> Index Templates API
476+
* on elastic.co</a>
477+
*/
478+
public void putTemplateAsync(PutIndexTemplateRequest putIndexTemplateRequest,
479+
ActionListener<PutIndexTemplateResponse> listener, Header... headers) {
480+
restHighLevelClient.performRequestAsyncAndParseEntity(putIndexTemplateRequest, RequestConverters::putTemplate,
481+
PutIndexTemplateResponse::fromXContent, listener, emptySet(), headers);
482+
}
435483
}

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

+45-4
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@
2929
import org.apache.http.entity.ContentType;
3030
import org.apache.lucene.util.BytesRef;
3131
import org.elasticsearch.action.DocWriteRequest;
32+
import org.elasticsearch.action.admin.cluster.repositories.get.GetRepositoriesRequest;
3233
import org.elasticsearch.action.admin.cluster.settings.ClusterUpdateSettingsRequest;
3334
import org.elasticsearch.action.admin.indices.alias.IndicesAliasesRequest;
3435
import org.elasticsearch.action.admin.indices.alias.get.GetAliasesRequest;
@@ -44,8 +45,10 @@
4445
import org.elasticsearch.action.admin.indices.refresh.RefreshRequest;
4546
import org.elasticsearch.action.admin.indices.rollover.RolloverRequest;
4647
import org.elasticsearch.action.admin.indices.settings.put.UpdateSettingsRequest;
48+
import org.elasticsearch.action.admin.indices.settings.get.GetSettingsRequest;
4749
import org.elasticsearch.action.admin.indices.shrink.ResizeRequest;
4850
import org.elasticsearch.action.admin.indices.shrink.ResizeType;
51+
import org.elasticsearch.action.admin.indices.template.put.PutIndexTemplateRequest;
4952
import org.elasticsearch.action.bulk.BulkRequest;
5053
import org.elasticsearch.action.delete.DeleteRequest;
5154
import org.elasticsearch.action.fieldcaps.FieldCapabilitiesRequest;
@@ -76,7 +79,6 @@
7679
import org.elasticsearch.common.xcontent.XContentType;
7780
import org.elasticsearch.index.VersionType;
7881
import org.elasticsearch.index.rankeval.RankEvalRequest;
79-
import org.elasticsearch.rest.action.RestFieldCapabilitiesAction;
8082
import org.elasticsearch.rest.action.search.RestSearchAction;
8183
import org.elasticsearch.search.fetch.subphase.FetchSourceContext;
8284

@@ -85,10 +87,7 @@
8587
import java.net.URI;
8688
import java.net.URISyntaxException;
8789
import java.nio.charset.Charset;
88-
import java.util.Collections;
89-
import java.util.HashMap;
9090
import java.util.Locale;
91-
import java.util.Map;
9291
import java.util.StringJoiner;
9392

9493
final class RequestConverters {
@@ -600,6 +599,22 @@ static Request rollover(RolloverRequest rolloverRequest) throws IOException {
600599
return request;
601600
}
602601

602+
static Request getSettings(GetSettingsRequest getSettingsRequest) throws IOException {
603+
String[] indices = getSettingsRequest.indices() == null ? Strings.EMPTY_ARRAY : getSettingsRequest.indices();
604+
String[] names = getSettingsRequest.names() == null ? Strings.EMPTY_ARRAY : getSettingsRequest.names();
605+
606+
String endpoint = endpoint(indices, "_settings", names);
607+
Request request = new Request(HttpGet.METHOD_NAME, endpoint);
608+
609+
Params params = new Params(request);
610+
params.withIndicesOptions(getSettingsRequest.indicesOptions());
611+
params.withLocal(getSettingsRequest.local());
612+
params.withIncludeDefaults(getSettingsRequest.includeDefaults());
613+
params.withMasterTimeout(getSettingsRequest.masterNodeTimeout());
614+
615+
return request;
616+
}
617+
603618
static Request indicesExist(GetIndexRequest getIndexRequest) {
604619
// this can be called with no indices as argument by transport client, not via REST though
605620
if (getIndexRequest.indices() == null || getIndexRequest.indices().length == 0) {
@@ -630,6 +645,32 @@ static Request indexPutSettings(UpdateSettingsRequest updateSettingsRequest) thr
630645
return request;
631646
}
632647

648+
static Request getRepositories(GetRepositoriesRequest getRepositoriesRequest) {
649+
String[] repositories = getRepositoriesRequest.repositories() == null ? Strings.EMPTY_ARRAY : getRepositoriesRequest.repositories();
650+
String endpoint = new EndpointBuilder().addPathPartAsIs("_snapshot").addCommaSeparatedPathParts(repositories).build();
651+
Request request = new Request(HttpGet.METHOD_NAME, endpoint);
652+
653+
Params parameters = new Params(request);
654+
parameters.withMasterTimeout(getRepositoriesRequest.masterNodeTimeout());
655+
parameters.withLocal(getRepositoriesRequest.local());
656+
return request;
657+
}
658+
659+
static Request putTemplate(PutIndexTemplateRequest putIndexTemplateRequest) throws IOException {
660+
String endpoint = new EndpointBuilder().addPathPartAsIs("_template").addPathPart(putIndexTemplateRequest.name()).build();
661+
Request request = new Request(HttpPut.METHOD_NAME, endpoint);
662+
Params params = new Params(request);
663+
params.withMasterTimeout(putIndexTemplateRequest.masterNodeTimeout());
664+
if (putIndexTemplateRequest.create()) {
665+
params.putParam("create", Boolean.TRUE.toString());
666+
}
667+
if (Strings.hasText(putIndexTemplateRequest.cause())) {
668+
params.putParam("cause", putIndexTemplateRequest.cause());
669+
}
670+
request.setEntity(createEntity(putIndexTemplateRequest, REQUEST_BODY_CONTENT_TYPE));
671+
return request;
672+
}
673+
633674
private static HttpEntity createEntity(ToXContent toXContent, XContentType xContentType) throws IOException {
634675
BytesRef source = XContentHelper.toXContent(toXContent, xContentType, false).toBytesRef();
635676
return new ByteArrayEntity(source.bytes, source.offset, source.length, createContentType(xContentType));

0 commit comments

Comments
 (0)