Skip to content

Commit 030a3e9

Browse files
committed
Merge remote-tracking branch 'elastic/master' into no-copy-settings-for-you
* elastic/master: (22 commits) Docs: Test examples that recreate lang analyzers (elastic#29535) BulkProcessor to retry based on status code (elastic#29329) Add GET Repository High Level REST API (elastic#30362) add a comment explaining the need for RetryOnReplicaException on missing mappings Add `coordinating_only` node selector (elastic#30313) Stop forking groovyc (elastic#30471) Avoid setting connection request timeout (elastic#30384) Use date format in `date_range` mapping before fallback to default (elastic#29310) Watcher: Increase HttpClient parallel sent requests (elastic#30130) Mute ML upgrade test (elastic#30458) Stop forking javac (elastic#30462) Client: Deprecate many argument performRequest (elastic#30315) Docs: Use task_id in examples of tasks (elastic#30436) Security: Rename IndexLifecycleManager to SecurityIndexManager (elastic#30442) [Docs] Fix typo in cardinality-aggregation.asciidoc (elastic#30434) Avoid NPE in `more_like_this` when field has zero tokens (elastic#30365) Build: Switch to building javadoc with html5 (elastic#30440) Add a quick tour of the project to CONTRIBUTING (elastic#30187) Reindex: Use request flavored methods (elastic#30317) Silence SplitIndexIT.testSplitIndexPrimaryTerm test failure. (elastic#30432) ...
2 parents 2c20228 + f9dc868 commit 030a3e9

File tree

90 files changed

+1946
-663
lines changed

Some content is hidden

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

90 files changed

+1946
-663
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

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")

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

+12
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;
@@ -644,6 +645,17 @@ static Request indexPutSettings(UpdateSettingsRequest updateSettingsRequest) thr
644645
return request;
645646
}
646647

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+
647659
static Request putTemplate(PutIndexTemplateRequest putIndexTemplateRequest) throws IOException {
648660
String endpoint = new EndpointBuilder().addPathPartAsIs("_template").addPathPart(putIndexTemplateRequest.name()).build();
649661
Request request = new Request(HttpPut.METHOD_NAME, endpoint);

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

+12
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,8 @@
2626
import org.elasticsearch.action.ActionListener;
2727
import org.elasticsearch.action.ActionRequest;
2828
import org.elasticsearch.action.ActionRequestValidationException;
29+
import org.elasticsearch.action.admin.cluster.repositories.get.GetRepositoriesRequest;
30+
import org.elasticsearch.action.admin.cluster.repositories.get.GetRepositoriesResponse;
2931
import org.elasticsearch.action.bulk.BulkRequest;
3032
import org.elasticsearch.action.bulk.BulkResponse;
3133
import org.elasticsearch.action.delete.DeleteRequest;
@@ -189,6 +191,7 @@ public class RestHighLevelClient implements Closeable {
189191

190192
private final IndicesClient indicesClient = new IndicesClient(this);
191193
private final ClusterClient clusterClient = new ClusterClient(this);
194+
private final SnapshotClient snapshotClient = new SnapshotClient(this);
192195

193196
/**
194197
* Creates a {@link RestHighLevelClient} given the low level {@link RestClientBuilder} that allows to build the
@@ -252,6 +255,15 @@ public final ClusterClient cluster() {
252255
return clusterClient;
253256
}
254257

258+
/**
259+
* Provides a {@link SnapshotClient} which can be used to access the Snapshot API.
260+
*
261+
* See <a href="https://www.elastic.co/guide/en/elasticsearch/reference/current/modules-snapshots.html">Snapshot API on elastic.co</a>
262+
*/
263+
public final SnapshotClient snapshot() {
264+
return snapshotClient;
265+
}
266+
255267
/**
256268
* Executes a bulk request using the Bulk API
257269
*
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,70 @@
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.Header;
23+
import org.elasticsearch.action.ActionListener;
24+
import org.elasticsearch.action.admin.cluster.repositories.get.GetRepositoriesRequest;
25+
import org.elasticsearch.action.admin.cluster.repositories.get.GetRepositoriesResponse;
26+
import org.elasticsearch.action.admin.cluster.settings.ClusterUpdateSettingsRequest;
27+
import org.elasticsearch.action.admin.cluster.settings.ClusterUpdateSettingsResponse;
28+
29+
import java.io.IOException;
30+
31+
import static java.util.Collections.emptySet;
32+
33+
/**
34+
* A wrapper for the {@link RestHighLevelClient} that provides methods for accessing the Snapshot API.
35+
* <p>
36+
* See <a href="https://www.elastic.co/guide/en/elasticsearch/reference/current/modules-snapshots.html">Snapshot API on elastic.co</a>
37+
*/
38+
public final class SnapshotClient {
39+
private final RestHighLevelClient restHighLevelClient;
40+
41+
SnapshotClient(RestHighLevelClient restHighLevelClient) {
42+
this.restHighLevelClient = restHighLevelClient;
43+
}
44+
45+
/**
46+
* Gets a list of snapshot repositories. If the list of repositories is empty or it contains a single element "_all", all
47+
* registered repositories are returned.
48+
* <p>
49+
* See <a href="https://www.elastic.co/guide/en/elasticsearch/reference/current/modules-snapshots.html"> Snapshot and Restore
50+
* API on elastic.co</a>
51+
*/
52+
public GetRepositoriesResponse getRepositories(GetRepositoriesRequest getRepositoriesRequest, Header... headers)
53+
throws IOException {
54+
return restHighLevelClient.performRequestAndParseEntity(getRepositoriesRequest, RequestConverters::getRepositories,
55+
GetRepositoriesResponse::fromXContent, emptySet(), headers);
56+
}
57+
58+
/**
59+
* Asynchronously gets a list of snapshot repositories. If the list of repositories is empty or it contains a single element "_all", all
60+
* registered repositories are returned.
61+
* <p>
62+
* See <a href="https://www.elastic.co/guide/en/elasticsearch/reference/current/modules-snapshots.html"> Snapshot and Restore
63+
* API on elastic.co</a>
64+
*/
65+
public void getRepositoriesAsync(GetRepositoriesRequest getRepositoriesRequest,
66+
ActionListener<GetRepositoriesResponse> listener, Header... headers) {
67+
restHighLevelClient.performRequestAsyncAndParseEntity(getRepositoriesRequest, RequestConverters::getRepositories,
68+
GetRepositoriesResponse::fromXContent, listener, emptySet(), headers);
69+
}
70+
}

0 commit comments

Comments
 (0)