Skip to content

Commit 84ef915

Browse files
committed
Merge branch 'master' into index-lifecycle
2 parents 9cb0bb8 + 3036ab1 commit 84ef915

File tree

215 files changed

+5470
-1882
lines changed

Some content is hidden

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

215 files changed

+5470
-1882
lines changed

buildSrc/src/main/resources/checkstyle_suppressions.xml

Lines changed: 0 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -372,9 +372,6 @@
372372
<suppress files="server[/\\]src[/\\]main[/\\]java[/\\]org[/\\]elasticsearch[/\\]search[/\\]suggest[/\\]completion[/\\]context[/\\]ContextMapping.java" checks="LineLength" />
373373
<suppress files="server[/\\]src[/\\]main[/\\]java[/\\]org[/\\]elasticsearch[/\\]search[/\\]suggest[/\\]completion[/\\]context[/\\]GeoContextMapping.java" checks="LineLength" />
374374
<suppress files="server[/\\]src[/\\]main[/\\]java[/\\]org[/\\]elasticsearch[/\\]search[/\\]suggest[/\\]completion[/\\]context[/\\]GeoQueryContext.java" checks="LineLength" />
375-
<suppress files="server[/\\]src[/\\]main[/\\]java[/\\]org[/\\]elasticsearch[/\\]search[/\\]suggest[/\\]phrase[/\\]CandidateScorer.java" checks="LineLength" />
376-
<suppress files="server[/\\]src[/\\]main[/\\]java[/\\]org[/\\]elasticsearch[/\\]search[/\\]suggest[/\\]phrase[/\\]NoisyChannelSpellChecker.java" checks="LineLength" />
377-
<suppress files="server[/\\]src[/\\]main[/\\]java[/\\]org[/\\]elasticsearch[/\\]search[/\\]suggest[/\\]phrase[/\\]WordScorer.java" checks="LineLength" />
378375
<suppress files="server[/\\]src[/\\]main[/\\]java[/\\]org[/\\]elasticsearch[/\\]snapshots[/\\]RestoreService.java" checks="LineLength" />
379376
<suppress files="server[/\\]src[/\\]main[/\\]java[/\\]org[/\\]elasticsearch[/\\]snapshots[/\\]SnapshotShardFailure.java" checks="LineLength" />
380377
<suppress files="server[/\\]src[/\\]main[/\\]java[/\\]org[/\\]elasticsearch[/\\]snapshots[/\\]SnapshotShardsService.java" checks="LineLength" />
@@ -564,7 +561,6 @@
564561
<suppress files="server[/\\]src[/\\]test[/\\]java[/\\]org[/\\]elasticsearch[/\\]index[/\\]store[/\\]CorruptedTranslogIT.java" checks="LineLength" />
565562
<suppress files="server[/\\]src[/\\]test[/\\]java[/\\]org[/\\]elasticsearch[/\\]index[/\\]store[/\\]IndexStoreTests.java" checks="LineLength" />
566563
<suppress files="server[/\\]src[/\\]test[/\\]java[/\\]org[/\\]elasticsearch[/\\]index[/\\]store[/\\]StoreTests.java" checks="LineLength" />
567-
<suppress files="server[/\\]src[/\\]test[/\\]java[/\\]org[/\\]elasticsearch[/\\]index[/\\]suggest[/\\]stats[/\\]SuggestStatsIT.java" checks="LineLength" />
568564
<suppress files="server[/\\]src[/\\]test[/\\]java[/\\]org[/\\]elasticsearch[/\\]index[/\\]translog[/\\]TranslogTests.java" checks="LineLength" />
569565
<suppress files="server[/\\]src[/\\]test[/\\]java[/\\]org[/\\]elasticsearch[/\\]indexing[/\\]IndexActionIT.java" checks="LineLength" />
570566
<suppress files="server[/\\]src[/\\]test[/\\]java[/\\]org[/\\]elasticsearch[/\\]indexlifecycle[/\\]IndexLifecycleActionIT.java" checks="LineLength" />
@@ -644,7 +640,6 @@
644640
<suppress files="server[/\\]src[/\\]test[/\\]java[/\\]org[/\\]elasticsearch[/\\]search[/\\]suggest[/\\]ContextCompletionSuggestSearchIT.java" checks="LineLength" />
645641
<suppress files="server[/\\]src[/\\]test[/\\]java[/\\]org[/\\]elasticsearch[/\\]search[/\\]suggest[/\\]completion[/\\]CategoryContextMappingTests.java" checks="LineLength" />
646642
<suppress files="server[/\\]src[/\\]test[/\\]java[/\\]org[/\\]elasticsearch[/\\]search[/\\]suggest[/\\]completion[/\\]GeoContextMappingTests.java" checks="LineLength" />
647-
<suppress files="server[/\\]src[/\\]test[/\\]java[/\\]org[/\\]elasticsearch[/\\]search[/\\]suggest[/\\]phrase[/\\]NoisyChannelSpellCheckerTests.java" checks="LineLength" />
648643
<suppress files="server[/\\]src[/\\]test[/\\]java[/\\]org[/\\]elasticsearch[/\\]similarity[/\\]SimilarityIT.java" checks="LineLength" />
649644
<suppress files="server[/\\]src[/\\]test[/\\]java[/\\]org[/\\]elasticsearch[/\\]snapshots[/\\]AbstractSnapshotIntegTestCase.java" checks="LineLength" />
650645
<suppress files="server[/\\]src[/\\]test[/\\]java[/\\]org[/\\]elasticsearch[/\\]snapshots[/\\]DedicatedClusterSnapshotRestoreIT.java" checks="LineLength" />
@@ -658,11 +653,4 @@
658653
<suppress files="server[/\\]src[/\\]test[/\\]java[/\\]org[/\\]elasticsearch[/\\]versioning[/\\]SimpleVersioningIT.java" checks="LineLength" />
659654
<suppress files="modules[/\\]lang-painless[/\\]src[/\\]test[/\\]java[/\\]org[/\\]elasticsearch[/\\]painless[/\\]ContextExampleTests.java" checks="LineLength" />
660655
<suppress files="modules[/\\]reindex[/\\]src[/\\]main[/\\]java[/\\]org[/\\]elasticsearch[/\\]index[/\\]reindex[/\\]TransportUpdateByQueryAction.java" checks="LineLength" />
661-
<suppress files="plugins[/\\]discovery-ec2[/\\]src[/\\]test[/\\]java[/\\]org[/\\]elasticsearch[/\\]discovery[/\\]ec2[/\\]AbstractAwsTestCase.java" checks="LineLength" />
662-
<suppress files="plugins[/\\]discovery-ec2[/\\]src[/\\]test[/\\]java[/\\]org[/\\]elasticsearch[/\\]discovery[/\\]ec2[/\\]AmazonEC2Mock.java" checks="LineLength" />
663-
<suppress files="plugins[/\\]mapper-murmur3[/\\]src[/\\]main[/\\]java[/\\]org[/\\]elasticsearch[/\\]index[/\\]mapper[/\\]murmur3[/\\]Murmur3FieldMapper.java" checks="LineLength" />
664-
<suppress files="plugins[/\\]repository-hdfs[/\\]src[/\\]main[/\\]java[/\\]org[/\\]elasticsearch[/\\]repositories[/\\]hdfs[/\\]HdfsRepository.java" checks="LineLength" />
665-
<suppress files="plugins[/\\]repository-hdfs[/\\]src[/\\]test[/\\]java[/\\]org[/\\]elasticsearch[/\\]repositories[/\\]hdfs[/\\]HdfsTests.java" checks="LineLength" />
666-
<suppress files="plugins[/\\]repository-s3[/\\]src[/\\]main[/\\]java[/\\]org[/\\]elasticsearch[/\\]repositories[/\\]s3[/\\]S3Repository.java" checks="LineLength" />
667-
<suppress files="plugins[/\\]repository-s3[/\\]src[/\\]test[/\\]java[/\\]org[/\\]elasticsearch[/\\]repositories[/\\]s3[/\\]AmazonS3Wrapper.java" checks="LineLength" />
668656
</suppressions>

client/rest-high-level/build.gradle

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -91,7 +91,7 @@ integTestCluster {
9191
// Truststore settings are not used since TLS is not enabled. Included for testing the get certificates API
9292
setting 'xpack.ssl.certificate_authorities', 'testnode.crt'
9393
setting 'xpack.security.transport.ssl.truststore.path', 'testnode.jks'
94-
setting 'xpack.security.transport.ssl.truststore.password', 'testnode'
94+
keystoreSetting 'xpack.security.transport.ssl.truststore.secure_password', 'testnode'
9595
setupCommand 'setupDummyUser',
9696
'bin/elasticsearch-users',
9797
'useradd', System.getProperty('tests.rest.cluster.username', 'test_user'),

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

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1129,3 +1129,4 @@ private static String encodePart(String pathPart) {
11291129
}
11301130
}
11311131
}
1132+

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

Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,8 @@
2424
import org.elasticsearch.client.rollup.DeleteRollupJobResponse;
2525
import org.elasticsearch.client.rollup.GetRollupJobRequest;
2626
import org.elasticsearch.client.rollup.GetRollupJobResponse;
27+
import org.elasticsearch.client.rollup.GetRollupCapsRequest;
28+
import org.elasticsearch.client.rollup.GetRollupCapsResponse;
2729
import org.elasticsearch.client.rollup.PutRollupJobRequest;
2830
import org.elasticsearch.client.rollup.PutRollupJobResponse;
2931

@@ -137,11 +139,48 @@ public GetRollupJobResponse getRollupJob(GetRollupJobRequest request, RequestOpt
137139
* @param options the request options (e.g. headers), use {@link RequestOptions#DEFAULT} if nothing needs to be customized
138140
* @param listener the listener to be notified upon request completion
139141
*/
142+
143+
140144
public void getRollupJobAsync(GetRollupJobRequest request, RequestOptions options, ActionListener<GetRollupJobResponse> listener) {
141145
restHighLevelClient.performRequestAsyncAndParseEntity(request,
142146
RollupRequestConverters::getJob,
143147
options,
144148
GetRollupJobResponse::fromXContent,
145149
listener, Collections.emptySet());
146150
}
151+
152+
/**
153+
* Get the Rollup Capabilities of a target (non-rollup) index or pattern
154+
* See <a href="https://www.elastic.co/guide/en/elasticsearch/reference/master/rollup-get-rollup-caps.html">
155+
* the docs</a> for more.
156+
* @param request the request
157+
* @param options the request options (e.g. headers), use {@link RequestOptions#DEFAULT} if nothing needs to be customized
158+
* @return the response
159+
* @throws IOException in case there is a problem sending the request or parsing back the response
160+
*/
161+
public GetRollupCapsResponse getRollupCapabilities(GetRollupCapsRequest request, RequestOptions options) throws IOException {
162+
return restHighLevelClient.performRequestAndParseEntity(request,
163+
RollupRequestConverters::getRollupCaps,
164+
options,
165+
GetRollupCapsResponse::fromXContent,
166+
Collections.emptySet());
167+
}
168+
169+
/**
170+
* Asynchronously Get the Rollup Capabilities of a target (non-rollup) index or pattern
171+
* See <a href="https://www.elastic.co/guide/en/elasticsearch/reference/current/rollup-put-job.html">
172+
* the docs</a> for more.
173+
* @param request the request
174+
* @param options the request options (e.g. headers), use {@link RequestOptions#DEFAULT} if nothing needs to be customized
175+
* @param listener the listener to be notified upon request completion
176+
*/
177+
public void getRollupCapabilitiesAsync(GetRollupCapsRequest request, RequestOptions options,
178+
ActionListener<GetRollupCapsResponse> listener) {
179+
restHighLevelClient.performRequestAsyncAndParseEntity(request,
180+
RollupRequestConverters::getRollupCaps,
181+
options,
182+
GetRollupCapsResponse::fromXContent,
183+
listener,
184+
Collections.emptySet());
185+
}
147186
}

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

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@
2323
import org.apache.http.client.methods.HttpPut;
2424
import org.elasticsearch.client.rollup.DeleteRollupJobRequest;
2525
import org.elasticsearch.client.rollup.GetRollupJobRequest;
26+
import org.elasticsearch.client.rollup.GetRollupCapsRequest;
2627
import org.elasticsearch.client.rollup.PutRollupJobRequest;
2728

2829
import java.io.IOException;
@@ -68,4 +69,16 @@ static Request deleteJob(final DeleteRollupJobRequest deleteRollupJobRequest) th
6869
request.setEntity(createEntity(deleteRollupJobRequest, REQUEST_BODY_CONTENT_TYPE));
6970
return request;
7071
}
72+
73+
static Request getRollupCaps(final GetRollupCapsRequest getRollupCapsRequest) throws IOException {
74+
String endpoint = new RequestConverters.EndpointBuilder()
75+
.addPathPartAsIs("_xpack")
76+
.addPathPartAsIs("rollup")
77+
.addPathPartAsIs("data")
78+
.addPathPart(getRollupCapsRequest.getIndexPattern())
79+
.build();
80+
Request request = new Request(HttpGet.METHOD_NAME, endpoint);
81+
request.setEntity(createEntity(getRollupCapsRequest, REQUEST_BODY_CONTENT_TYPE));
82+
return request;
83+
}
7184
}

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

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,8 @@
3030
import org.elasticsearch.client.security.PutUserResponse;
3131
import org.elasticsearch.client.security.EmptyResponse;
3232
import org.elasticsearch.client.security.ChangePasswordRequest;
33+
import org.elasticsearch.client.security.DeleteRoleMappingRequest;
34+
import org.elasticsearch.client.security.DeleteRoleMappingResponse;
3335

3436
import java.io.IOException;
3537

@@ -221,4 +223,33 @@ public void changePasswordAsync(ChangePasswordRequest request, RequestOptions op
221223
restHighLevelClient.performRequestAsyncAndParseEntity(request, SecurityRequestConverters::changePassword, options,
222224
EmptyResponse::fromXContent, listener, emptySet());
223225
}
226+
227+
/**
228+
* Delete a role mapping.
229+
* See <a href="https://www.elastic.co/guide/en/elasticsearch/reference/current/security-api-delete-role-mapping.html">
230+
* the docs</a> for more.
231+
* @param request the request with the role mapping name to be deleted.
232+
* @param options the request options (e.g. headers), use {@link RequestOptions#DEFAULT} if nothing needs to be customized
233+
* @return the response from the delete role mapping call
234+
* @throws IOException in case there is a problem sending the request or parsing back the response
235+
*/
236+
public DeleteRoleMappingResponse deleteRoleMapping(DeleteRoleMappingRequest request, RequestOptions options) throws IOException {
237+
return restHighLevelClient.performRequestAndParseEntity(request, SecurityRequestConverters::deleteRoleMapping, options,
238+
DeleteRoleMappingResponse::fromXContent, emptySet());
239+
}
240+
241+
/**
242+
* Asynchronously delete a role mapping.
243+
* See <a href="https://www.elastic.co/guide/en/elasticsearch/reference/current/security-api-delete-role-mapping.html">
244+
* the docs</a> for more.
245+
* @param request the request with the role mapping name to be deleted.
246+
* @param options the request options (e.g. headers), use {@link RequestOptions#DEFAULT} if nothing needs to be customized
247+
* @param listener the listener to be notified upon request completion
248+
*/
249+
public void deleteRoleMappingAsync(DeleteRoleMappingRequest request, RequestOptions options,
250+
ActionListener<DeleteRoleMappingResponse> listener) {
251+
restHighLevelClient.performRequestAsyncAndParseEntity(request, SecurityRequestConverters::deleteRoleMapping, options,
252+
DeleteRoleMappingResponse::fromXContent, listener, emptySet());
253+
}
254+
224255
}

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

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,12 +19,14 @@
1919

2020
package org.elasticsearch.client;
2121

22+
import org.apache.http.client.methods.HttpDelete;
2223
import org.apache.http.client.methods.HttpPost;
2324
import org.apache.http.client.methods.HttpPut;
2425
import org.elasticsearch.client.security.PutRoleMappingRequest;
2526
import org.elasticsearch.client.security.DisableUserRequest;
2627
import org.elasticsearch.client.security.EnableUserRequest;
2728
import org.elasticsearch.client.security.ChangePasswordRequest;
29+
import org.elasticsearch.client.security.DeleteRoleMappingRequest;
2830
import org.elasticsearch.client.security.PutUserRequest;
2931
import org.elasticsearch.client.security.SetUserEnabledRequest;
3032

@@ -93,4 +95,16 @@ private static Request setUserEnabled(SetUserEnabledRequest setUserEnabledReques
9395
params.withRefreshPolicy(setUserEnabledRequest.getRefreshPolicy());
9496
return request;
9597
}
98+
99+
static Request deleteRoleMapping(DeleteRoleMappingRequest deleteRoleMappingRequest) throws IOException {
100+
final String endpoint = new RequestConverters.EndpointBuilder()
101+
.addPathPartAsIs("_xpack/security/role_mapping")
102+
.addPathPart(deleteRoleMappingRequest.getName())
103+
.build();
104+
final Request request = new Request(HttpDelete.METHOD_NAME, endpoint);
105+
final RequestConverters.Params params = new RequestConverters.Params(request);
106+
params.withRefreshPolicy(deleteRoleMappingRequest.getRefreshPolicy());
107+
return request;
108+
}
109+
96110
}
Lines changed: 70 additions & 0 deletions
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+
package org.elasticsearch.client.rollup;
20+
21+
import org.elasticsearch.client.Validatable;
22+
import org.elasticsearch.cluster.metadata.MetaData;
23+
import org.elasticsearch.common.Strings;
24+
import org.elasticsearch.common.xcontent.ToXContentObject;
25+
import org.elasticsearch.common.xcontent.XContentBuilder;
26+
27+
import java.io.IOException;
28+
import java.util.Objects;
29+
30+
public class GetRollupCapsRequest implements Validatable, ToXContentObject {
31+
private static final String ID = "id";
32+
private final String indexPattern;
33+
34+
public GetRollupCapsRequest(final String indexPattern) {
35+
if (Strings.isNullOrEmpty(indexPattern) || indexPattern.equals("*")) {
36+
this.indexPattern = MetaData.ALL;
37+
} else {
38+
this.indexPattern = indexPattern;
39+
}
40+
}
41+
42+
public String getIndexPattern() {
43+
return indexPattern;
44+
}
45+
46+
@Override
47+
public XContentBuilder toXContent(XContentBuilder builder, Params params) throws IOException {
48+
builder.startObject();
49+
builder.field(ID, indexPattern);
50+
builder.endObject();
51+
return builder;
52+
}
53+
54+
@Override
55+
public int hashCode() {
56+
return Objects.hash(indexPattern);
57+
}
58+
59+
@Override
60+
public boolean equals(Object obj) {
61+
if (obj == null) {
62+
return false;
63+
}
64+
if (getClass() != obj.getClass()) {
65+
return false;
66+
}
67+
GetRollupCapsRequest other = (GetRollupCapsRequest) obj;
68+
return Objects.equals(indexPattern, other.indexPattern);
69+
}
70+
}
Lines changed: 92 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,92 @@
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+
package org.elasticsearch.client.rollup;
20+
21+
import org.elasticsearch.common.Strings;
22+
import org.elasticsearch.common.xcontent.ToXContent;
23+
import org.elasticsearch.common.xcontent.ToXContentObject;
24+
import org.elasticsearch.common.xcontent.XContentBuilder;
25+
import org.elasticsearch.common.xcontent.XContentParser;
26+
27+
import java.io.IOException;
28+
import java.util.Collections;
29+
import java.util.HashMap;
30+
import java.util.Map;
31+
import java.util.Objects;
32+
33+
public class GetRollupCapsResponse implements ToXContentObject {
34+
35+
private final Map<String, RollableIndexCaps> jobs;
36+
37+
public GetRollupCapsResponse(final Map<String, RollableIndexCaps> jobs) {
38+
this.jobs = Collections.unmodifiableMap(Objects.requireNonNull(jobs));
39+
}
40+
41+
public Map<String, RollableIndexCaps> getJobs() {
42+
return jobs;
43+
}
44+
45+
@Override
46+
public XContentBuilder toXContent(XContentBuilder builder, ToXContent.Params params) throws IOException {
47+
builder.startObject();
48+
for (Map.Entry<String, RollableIndexCaps> entry : jobs.entrySet()) {
49+
entry.getValue().toXContent(builder, params);
50+
}
51+
builder.endObject();
52+
return builder;
53+
}
54+
55+
public static GetRollupCapsResponse fromXContent(final XContentParser parser) throws IOException {
56+
Map<String, RollableIndexCaps> jobs = new HashMap<>();
57+
XContentParser.Token token = parser.nextToken();
58+
if (token.equals(XContentParser.Token.START_OBJECT)) {
59+
while ((token = parser.nextToken()) != XContentParser.Token.END_OBJECT) {
60+
if (token.equals(XContentParser.Token.FIELD_NAME)) {
61+
String pattern = parser.currentName();
62+
63+
RollableIndexCaps cap = RollableIndexCaps.PARSER.apply(pattern).apply(parser, null);
64+
jobs.put(pattern, cap);
65+
}
66+
}
67+
}
68+
return new GetRollupCapsResponse(jobs);
69+
}
70+
71+
@Override
72+
public int hashCode() {
73+
return Objects.hash(jobs);
74+
}
75+
76+
@Override
77+
public boolean equals(Object obj) {
78+
if (obj == null) {
79+
return false;
80+
}
81+
if (getClass() != obj.getClass()) {
82+
return false;
83+
}
84+
GetRollupCapsResponse other = (GetRollupCapsResponse) obj;
85+
return Objects.equals(jobs, other.jobs);
86+
}
87+
88+
@Override
89+
public final String toString() {
90+
return Strings.toString(this);
91+
}
92+
}

0 commit comments

Comments
 (0)