Skip to content

Commit e6c646c

Browse files
committed
Merge branch 'master' into feature/windows-packaging-tests-vagrant
2 parents 8e93e6b + cbba37c commit e6c646c

File tree

188 files changed

+3830
-1561
lines changed

Some content is hidden

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

188 files changed

+3830
-1561
lines changed

CONTRIBUTING.md

+11-10
Original file line numberDiff line numberDiff line change
@@ -111,19 +111,20 @@ then `File->New Project From Existing Sources`. Point to the root of
111111
the source directory, select
112112
`Import project from external model->Gradle`, enable
113113
`Use auto-import`. In order to run tests directly from
114-
IDEA 2017.2 and above it is required to disable IDEA run launcher to avoid
115-
finding yourself in "jar hell", which can be achieved by adding the
114+
IDEA 2017.2 and above, it is required to disable the IDEA run launcher in order to avoid
115+
`idea_rt.jar` causing "jar hell". This can be achieved by adding the
116116
`-Didea.no.launcher=true` [JVM
117-
option](https://intellij-support.jetbrains.com/hc/en-us/articles/206544869-Configuring-JVM-options-and-platform-properties)
118-
or by adding `idea.no.launcher=true` to the
117+
option](https://intellij-support.jetbrains.com/hc/en-us/articles/206544869-Configuring-JVM-options-and-platform-properties).
118+
Alternatively, `idea.no.launcher=true` can be set in the
119119
[`idea.properties`](https://www.jetbrains.com/help/idea/file-idea-properties.html)
120-
file which can be accessed under Help > Edit Custom Properties within IDEA. You
121-
may also need to [remove `ant-javafx.jar` from your
120+
file which can be accessed under Help > Edit Custom Properties (this will require a
121+
restart of IDEA). For IDEA 2017.3 and above, in addition to the JVM option, you will need to go to
122+
`Run->Edit Configurations->...->Defaults->JUnit` and change the value for the `Shorten command line` setting from
123+
`user-local default: none` to `classpath file`. You may also need to [remove `ant-javafx.jar` from your
122124
classpath](https://github.com/elastic/elasticsearch/issues/14348) if that is
123-
reported as a source of jar hell. Additionally, in order to run tests directly
124-
from IDEA 2017.3 and above, go to `Run->Edit Configurations...` and change the
125-
value for the `Shorten command line` setting from `user-local default: none` to
126-
`classpath file`.
125+
reported as a source of jar hell.
126+
127+
To run an instance of elasticsearch from the source code run `gradle run`
127128

128129
The Elasticsearch codebase makes heavy use of Java `assert`s and the
129130
test runner requires that assertions be enabled within the JVM. This

Vagrantfile

+5
Original file line numberDiff line numberDiff line change
@@ -392,6 +392,11 @@ Defaults env_keep += "BATS_ARCHIVES"
392392
SUDOERS_VARS
393393
chmod 0440 /etc/sudoers.d/elasticsearch_vars
394394
SHELL
395+
# This prevents leftovers from previous tests using the
396+
# same VM from messing up the current test
397+
config.vm.provision "clean_tmp", run: "always", type: "shell", inline: <<-SHELL
398+
rm -rf /tmp/elasticsearch*
399+
SHELL
395400
end
396401

397402
def windows_common(config, name)

buildSrc/src/main/resources/checkstyle_suppressions.xml

-1
Original file line numberDiff line numberDiff line change
@@ -658,7 +658,6 @@
658658
<suppress files="core[/\\]src[/\\]test[/\\]java[/\\]org[/\\]elasticsearch[/\\]recovery[/\\]RelocationIT.java" checks="LineLength" />
659659
<suppress files="core[/\\]src[/\\]test[/\\]java[/\\]org[/\\]elasticsearch[/\\]recovery[/\\]TruncatedRecoveryIT.java" checks="LineLength" />
660660
<suppress files="core[/\\]src[/\\]test[/\\]java[/\\]org[/\\]elasticsearch[/\\]rest[/\\]BytesRestResponseTests.java" checks="LineLength" />
661-
<suppress files="core[/\\]src[/\\]test[/\\]java[/\\]org[/\\]elasticsearch[/\\]routing[/\\]AliasResolveRoutingIT.java" checks="LineLength" />
662661
<suppress files="core[/\\]src[/\\]test[/\\]java[/\\]org[/\\]elasticsearch[/\\]routing[/\\]AliasRoutingIT.java" checks="LineLength" />
663662
<suppress files="core[/\\]src[/\\]test[/\\]java[/\\]org[/\\]elasticsearch[/\\]routing[/\\]SimpleRoutingIT.java" checks="LineLength" />
664663
<suppress files="core[/\\]src[/\\]test[/\\]java[/\\]org[/\\]elasticsearch[/\\]script[/\\]FileScriptTests.java" checks="LineLength" />

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

+54-3
Original file line numberDiff line numberDiff line change
@@ -21,21 +21,25 @@
2121

2222
import org.apache.http.Header;
2323
import org.elasticsearch.action.ActionListener;
24+
import org.elasticsearch.action.admin.indices.create.CreateIndexRequest;
25+
import org.elasticsearch.action.admin.indices.create.CreateIndexResponse;
2426
import org.elasticsearch.action.admin.indices.delete.DeleteIndexRequest;
2527
import org.elasticsearch.action.admin.indices.delete.DeleteIndexResponse;
28+
import org.elasticsearch.action.admin.indices.open.OpenIndexRequest;
29+
import org.elasticsearch.action.admin.indices.open.OpenIndexResponse;
2630

2731
import java.io.IOException;
2832
import java.util.Collections;
2933

3034
/**
3135
* A wrapper for the {@link RestHighLevelClient} that provides methods for accessing the Indices API.
32-
*
36+
* <p>
3337
* See <a href="https://www.elastic.co/guide/en/elasticsearch/reference/current/indices.html">Indices API on elastic.co</a>
3438
*/
3539
public final class IndicesClient {
3640
private final RestHighLevelClient restHighLevelClient;
3741

38-
public IndicesClient(RestHighLevelClient restHighLevelClient) {
42+
IndicesClient(RestHighLevelClient restHighLevelClient) {
3943
this.restHighLevelClient = restHighLevelClient;
4044
}
4145

@@ -56,8 +60,55 @@ public DeleteIndexResponse deleteIndex(DeleteIndexRequest deleteIndexRequest, He
5660
* See <a href="https://www.elastic.co/guide/en/elasticsearch/reference/current/indices-delete-index.html">
5761
* Delete Index API on elastic.co</a>
5862
*/
59-
public void deleteIndexAsync(DeleteIndexRequest deleteIndexRequest, ActionListener<DeleteIndexResponse> listener, Header... headers) {
63+
public void deleteIndexAsync(DeleteIndexRequest deleteIndexRequest, ActionListener<DeleteIndexResponse> listener,
64+
Header... headers) {
6065
restHighLevelClient.performRequestAsyncAndParseEntity(deleteIndexRequest, Request::deleteIndex, DeleteIndexResponse::fromXContent,
6166
listener, Collections.emptySet(), headers);
6267
}
68+
69+
/**
70+
* Creates an index using the Create Index API
71+
* <p>
72+
* See <a href="https://www.elastic.co/guide/en/elasticsearch/reference/current/indices-create-index.html">
73+
* Create Index API on elastic.co</a>
74+
*/
75+
public CreateIndexResponse createIndex(CreateIndexRequest createIndexRequest, Header... headers) throws IOException {
76+
return restHighLevelClient.performRequestAndParseEntity(createIndexRequest, Request::createIndex, CreateIndexResponse::fromXContent,
77+
Collections.emptySet(), headers);
78+
}
79+
80+
/**
81+
* Asynchronously creates an index using the Create Index API
82+
* <p>
83+
* See <a href="https://www.elastic.co/guide/en/elasticsearch/reference/current/indices-create-index.html">
84+
* Create Index API on elastic.co</a>
85+
*/
86+
public void createIndexAsync(CreateIndexRequest createIndexRequest, ActionListener<CreateIndexResponse> listener,
87+
Header... headers) {
88+
restHighLevelClient.performRequestAsyncAndParseEntity(createIndexRequest, Request::createIndex, CreateIndexResponse::fromXContent,
89+
listener, Collections.emptySet(), headers);
90+
}
91+
92+
/**
93+
* Opens an index using the Open Index API
94+
* <p>
95+
* See <a href="https://www.elastic.co/guide/en/elasticsearch/reference/current/indices-open-close.html">
96+
* Open Index API on elastic.co</a>
97+
*/
98+
public OpenIndexResponse openIndex(OpenIndexRequest openIndexRequest, Header... headers) throws IOException {
99+
return restHighLevelClient.performRequestAndParseEntity(openIndexRequest, Request::openIndex, OpenIndexResponse::fromXContent,
100+
Collections.emptySet(), headers);
101+
}
102+
103+
/**
104+
* Asynchronously opens an index using the Open Index API
105+
* <p>
106+
* See <a href="https://www.elastic.co/guide/en/elasticsearch/reference/current/indices-open-close.html">
107+
* Open Index API on elastic.co</a>
108+
*/
109+
public void openIndexAsync(OpenIndexRequest openIndexRequest, ActionListener<OpenIndexResponse> listener, Header... headers) {
110+
restHighLevelClient.performRequestAsyncAndParseEntity(openIndexRequest, Request::openIndex, OpenIndexResponse::fromXContent,
111+
listener, Collections.emptySet(), headers);
112+
}
113+
63114
}

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

+35
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,9 @@
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.indices.create.CreateIndexRequest;
3233
import org.elasticsearch.action.admin.indices.delete.DeleteIndexRequest;
34+
import org.elasticsearch.action.admin.indices.open.OpenIndexRequest;
3335
import org.elasticsearch.action.bulk.BulkRequest;
3436
import org.elasticsearch.action.delete.DeleteRequest;
3537
import org.elasticsearch.action.get.GetRequest;
@@ -137,6 +139,32 @@ static Request deleteIndex(DeleteIndexRequest deleteIndexRequest) {
137139
return new Request(HttpDelete.METHOD_NAME, endpoint, parameters.getParams(), null);
138140
}
139141

142+
static Request openIndex(OpenIndexRequest openIndexRequest) {
143+
String endpoint = endpoint(openIndexRequest.indices(), Strings.EMPTY_ARRAY, "_open");
144+
145+
Params parameters = Params.builder();
146+
147+
parameters.withTimeout(openIndexRequest.timeout());
148+
parameters.withMasterTimeout(openIndexRequest.masterNodeTimeout());
149+
parameters.withWaitForActiveShards(openIndexRequest.waitForActiveShards());
150+
parameters.withIndicesOptions(openIndexRequest.indicesOptions());
151+
152+
return new Request(HttpPost.METHOD_NAME, endpoint, parameters.getParams(), null);
153+
}
154+
155+
static Request createIndex(CreateIndexRequest createIndexRequest) throws IOException {
156+
String endpoint = endpoint(createIndexRequest.indices(), Strings.EMPTY_ARRAY, "");
157+
158+
Params parameters = Params.builder();
159+
parameters.withTimeout(createIndexRequest.timeout());
160+
parameters.withMasterTimeout(createIndexRequest.masterNodeTimeout());
161+
parameters.withWaitForActiveShards(createIndexRequest.waitForActiveShards());
162+
parameters.withUpdateAllTypes(createIndexRequest.updateAllTypes());
163+
164+
HttpEntity entity = createEntity(createIndexRequest, REQUEST_BODY_CONTENT_TYPE);
165+
return new Request(HttpPut.METHOD_NAME, endpoint, parameters.getParams(), entity);
166+
}
167+
140168
static Request info() {
141169
return new Request(HttpGet.METHOD_NAME, "/", Collections.emptyMap(), null);
142170
}
@@ -534,6 +562,13 @@ Params withTimeout(TimeValue timeout) {
534562
return putParam("timeout", timeout);
535563
}
536564

565+
Params withUpdateAllTypes(boolean updateAllTypes) {
566+
if (updateAllTypes) {
567+
return putParam("update_all_types", Boolean.TRUE.toString());
568+
}
569+
return this;
570+
}
571+
537572
Params withVersion(long version) {
538573
if (version != Versions.MATCH_ANY) {
539574
return putParam("version", Long.toString(version));

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

+3-1
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.indices.open.OpenIndexRequest;
30+
import org.elasticsearch.action.admin.indices.open.OpenIndexResponse;
2931
import org.elasticsearch.action.bulk.BulkRequest;
3032
import org.elasticsearch.action.bulk.BulkResponse;
3133
import org.elasticsearch.action.delete.DeleteRequest;
@@ -283,7 +285,7 @@ public final GetResponse get(GetRequest getRequest, Header... headers) throws IO
283285
*
284286
* See <a href="https://www.elastic.co/guide/en/elasticsearch/reference/current/docs-get.html">Get API on elastic.co</a>
285287
*/
286-
public void getAsync(GetRequest getRequest, ActionListener<GetResponse> listener, Header... headers) {
288+
public final void getAsync(GetRequest getRequest, ActionListener<GetResponse> listener, Header... headers) {
287289
performRequestAsyncAndParseEntity(getRequest, Request::get, GetResponse::fromXContent, listener, singleton(404), headers);
288290
}
289291

0 commit comments

Comments
 (0)