Skip to content

Commit 9133299

Browse files
committed
Merge branch 'master' into security_api_keys
2 parents 2a1a59f + d291b08 commit 9133299

File tree

531 files changed

+18827
-5187
lines changed

Some content is hidden

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

531 files changed

+18827
-5187
lines changed

buildSrc/version.properties

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
elasticsearch = 7.0.0
2-
lucene = 8.0.0-snapshot-6d9c714052
2+
lucene = 8.0.0-snapshot-67cdd21996
33

44
# optional dependencies
55
spatial4j = 0.7
@@ -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/rest-high-level/src/main/java/org/elasticsearch/client/CcrClient.java

Lines changed: 91 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,8 @@
2323
import org.elasticsearch.client.ccr.PauseFollowRequest;
2424
import org.elasticsearch.client.ccr.PutFollowRequest;
2525
import org.elasticsearch.client.ccr.PutFollowResponse;
26+
import org.elasticsearch.client.ccr.ResumeFollowRequest;
27+
import org.elasticsearch.client.ccr.UnfollowRequest;
2628
import org.elasticsearch.client.core.AcknowledgedResponse;
2729

2830
import java.io.IOException;
@@ -89,7 +91,7 @@ public void putFollowAsync(PutFollowRequest request,
8991
}
9092

9193
/**
92-
* Instructs a follower index the pause the following of a leader index.
94+
* Instructs a follower index to pause the following of a leader index.
9395
*
9496
* See <a href="https://www.elastic.co/guide/en/elasticsearch/reference/current/ccr-pause-follow.html">
9597
* the docs</a> for more.
@@ -110,7 +112,7 @@ public AcknowledgedResponse pauseFollow(PauseFollowRequest request, RequestOptio
110112
}
111113

112114
/**
113-
* Asynchronously instruct a follower index the pause the following of a leader index.
115+
* Asynchronously instruct a follower index to pause the following of a leader index.
114116
*
115117
* See <a href="https://www.elastic.co/guide/en/elasticsearch/reference/current/ccr-pause-follow.html">
116118
* the docs</a> for more.
@@ -130,4 +132,91 @@ public void pauseFollowAsync(PauseFollowRequest request,
130132
Collections.emptySet());
131133
}
132134

135+
/**
136+
* Instructs a follower index to resume the following of a leader index.
137+
*
138+
* See <a href="https://www.elastic.co/guide/en/elasticsearch/reference/current/ccr-resume-follow.html">
139+
* the docs</a> for more.
140+
*
141+
* @param request the request
142+
* @param options the request options (e.g. headers), use {@link RequestOptions#DEFAULT} if nothing needs to be customized
143+
* @return the response
144+
* @throws IOException in case there is a problem sending the request or parsing back the response
145+
*/
146+
public AcknowledgedResponse resumeFollow(ResumeFollowRequest request, RequestOptions options) throws IOException {
147+
return restHighLevelClient.performRequestAndParseEntity(
148+
request,
149+
CcrRequestConverters::resumeFollow,
150+
options,
151+
AcknowledgedResponse::fromXContent,
152+
Collections.emptySet()
153+
);
154+
}
155+
156+
/**
157+
* Asynchronously instruct a follower index to resume the following of a leader index.
158+
*
159+
* See <a href="https://www.elastic.co/guide/en/elasticsearch/reference/current/ccr-resume-follow.html">
160+
* the docs</a> for more.
161+
*
162+
* @param request the request
163+
* @param options the request options (e.g. headers), use {@link RequestOptions#DEFAULT} if nothing needs to be customized
164+
*/
165+
public void resumeFollowAsync(ResumeFollowRequest request,
166+
RequestOptions options,
167+
ActionListener<AcknowledgedResponse> listener) {
168+
restHighLevelClient.performRequestAsyncAndParseEntity(
169+
request,
170+
CcrRequestConverters::resumeFollow,
171+
options,
172+
AcknowledgedResponse::fromXContent,
173+
listener,
174+
Collections.emptySet());
175+
}
176+
177+
/**
178+
* Instructs a follower index to unfollow and become a regular index.
179+
* Note that index following needs to be paused and the follower index needs to be closed.
180+
*
181+
* See <a href="https://www.elastic.co/guide/en/elasticsearch/reference/current/ccr-unfollow.html">
182+
* the docs</a> for more.
183+
*
184+
* @param request the request
185+
* @param options the request options (e.g. headers), use {@link RequestOptions#DEFAULT} if nothing needs to be customized
186+
* @return the response
187+
* @throws IOException in case there is a problem sending the request or parsing back the response
188+
*/
189+
public AcknowledgedResponse unfollow(UnfollowRequest request, RequestOptions options) throws IOException {
190+
return restHighLevelClient.performRequestAndParseEntity(
191+
request,
192+
CcrRequestConverters::unfollow,
193+
options,
194+
AcknowledgedResponse::fromXContent,
195+
Collections.emptySet()
196+
);
197+
}
198+
199+
/**
200+
* Asynchronously instructs a follower index to unfollow and become a regular index.
201+
* Note that index following needs to be paused and the follower index needs to be closed.
202+
*
203+
* See <a href="https://www.elastic.co/guide/en/elasticsearch/reference/current/ccr-unfollow.html">
204+
* the docs</a> for more.
205+
*
206+
* @param request the request
207+
* @param options the request options (e.g. headers), use {@link RequestOptions#DEFAULT} if nothing needs to be customized
208+
*/
209+
public void unfollowAsync(UnfollowRequest request,
210+
RequestOptions options,
211+
ActionListener<AcknowledgedResponse> listener) {
212+
restHighLevelClient.performRequestAsyncAndParseEntity(
213+
request,
214+
CcrRequestConverters::unfollow,
215+
options,
216+
AcknowledgedResponse::fromXContent,
217+
listener,
218+
Collections.emptySet()
219+
);
220+
}
221+
133222
}

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

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,8 @@
2323
import org.apache.http.client.methods.HttpPut;
2424
import org.elasticsearch.client.ccr.PauseFollowRequest;
2525
import org.elasticsearch.client.ccr.PutFollowRequest;
26+
import org.elasticsearch.client.ccr.ResumeFollowRequest;
27+
import org.elasticsearch.client.ccr.UnfollowRequest;
2628

2729
import java.io.IOException;
2830

@@ -49,4 +51,22 @@ static Request pauseFollow(PauseFollowRequest pauseFollowRequest) {
4951
return new Request(HttpPost.METHOD_NAME, endpoint);
5052
}
5153

54+
static Request resumeFollow(ResumeFollowRequest resumeFollowRequest) throws IOException {
55+
String endpoint = new RequestConverters.EndpointBuilder()
56+
.addPathPart(resumeFollowRequest.getFollowerIndex())
57+
.addPathPartAsIs("_ccr", "resume_follow")
58+
.build();
59+
Request request = new Request(HttpPost.METHOD_NAME, endpoint);
60+
request.setEntity(createEntity(resumeFollowRequest, REQUEST_BODY_CONTENT_TYPE));
61+
return request;
62+
}
63+
64+
static Request unfollow(UnfollowRequest unfollowRequest) {
65+
String endpoint = new RequestConverters.EndpointBuilder()
66+
.addPathPart(unfollowRequest.getFollowerIndex())
67+
.addPathPartAsIs("_ccr", "unfollow")
68+
.build();
69+
return new Request(HttpPost.METHOD_NAME, endpoint);
70+
}
71+
5272
}

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/MLRequestConverters.java

Lines changed: 92 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,13 +28,15 @@
2828
import org.apache.lucene.util.BytesRef;
2929
import org.elasticsearch.client.RequestConverters.EndpointBuilder;
3030
import org.elasticsearch.client.ml.CloseJobRequest;
31+
import org.elasticsearch.client.ml.DeleteCalendarEventRequest;
3132
import org.elasticsearch.client.ml.DeleteCalendarJobRequest;
3233
import org.elasticsearch.client.ml.DeleteCalendarRequest;
3334
import org.elasticsearch.client.ml.DeleteDatafeedRequest;
3435
import org.elasticsearch.client.ml.DeleteFilterRequest;
3536
import org.elasticsearch.client.ml.DeleteForecastRequest;
3637
import org.elasticsearch.client.ml.DeleteJobRequest;
3738
import org.elasticsearch.client.ml.DeleteModelSnapshotRequest;
39+
import org.elasticsearch.client.ml.FindFileStructureRequest;
3840
import org.elasticsearch.client.ml.FlushJobRequest;
3941
import org.elasticsearch.client.ml.ForecastJobRequest;
4042
import org.elasticsearch.client.ml.GetBucketsRequest;
@@ -59,6 +61,7 @@
5961
import org.elasticsearch.client.ml.PutDatafeedRequest;
6062
import org.elasticsearch.client.ml.PutFilterRequest;
6163
import org.elasticsearch.client.ml.PutJobRequest;
64+
import org.elasticsearch.client.ml.RevertModelSnapshotRequest;
6265
import org.elasticsearch.client.ml.StartDatafeedRequest;
6366
import org.elasticsearch.client.ml.StopDatafeedRequest;
6467
import org.elasticsearch.client.ml.UpdateDatafeedRequest;
@@ -68,6 +71,7 @@
6871
import org.elasticsearch.client.ml.job.util.PageParams;
6972
import org.elasticsearch.common.Strings;
7073
import org.elasticsearch.common.bytes.BytesReference;
74+
import org.elasticsearch.common.xcontent.XContentType;
7175

7276
import java.io.IOException;
7377

@@ -410,6 +414,21 @@ static Request updateModelSnapshot(UpdateModelSnapshotRequest updateModelSnapsho
410414
return request;
411415
}
412416

417+
static Request revertModelSnapshot(RevertModelSnapshotRequest revertModelSnapshotsRequest) throws IOException {
418+
String endpoint = new EndpointBuilder()
419+
.addPathPartAsIs("_xpack")
420+
.addPathPartAsIs("ml")
421+
.addPathPartAsIs("anomaly_detectors")
422+
.addPathPart(revertModelSnapshotsRequest.getJobId())
423+
.addPathPartAsIs("model_snapshots")
424+
.addPathPart(revertModelSnapshotsRequest.getSnapshotId())
425+
.addPathPart("_revert")
426+
.build();
427+
Request request = new Request(HttpPost.METHOD_NAME, endpoint);
428+
request.setEntity(createEntity(revertModelSnapshotsRequest, REQUEST_BODY_CONTENT_TYPE));
429+
return request;
430+
}
431+
413432
static Request getOverallBuckets(GetOverallBucketsRequest getOverallBucketsRequest) throws IOException {
414433
String endpoint = new EndpointBuilder()
415434
.addPathPartAsIs("_xpack")
@@ -568,6 +587,18 @@ static Request postCalendarEvents(PostCalendarEventRequest postCalendarEventRequ
568587
return request;
569588
}
570589

590+
static Request deleteCalendarEvent(DeleteCalendarEventRequest deleteCalendarEventRequest) {
591+
String endpoint = new EndpointBuilder()
592+
.addPathPartAsIs("_xpack")
593+
.addPathPartAsIs("ml")
594+
.addPathPartAsIs("calendars")
595+
.addPathPart(deleteCalendarEventRequest.getCalendarId())
596+
.addPathPartAsIs("events")
597+
.addPathPart(deleteCalendarEventRequest.getEventId())
598+
.build();
599+
return new Request(HttpDelete.METHOD_NAME, endpoint);
600+
}
601+
571602
static Request putFilter(PutFilterRequest putFilterRequest) throws IOException {
572603
String endpoint = new EndpointBuilder()
573604
.addPathPartAsIs("_xpack")
@@ -619,4 +650,65 @@ static Request deleteFilter(DeleteFilterRequest deleteFilterRequest) {
619650
Request request = new Request(HttpDelete.METHOD_NAME, endpoint);
620651
return request;
621652
}
653+
654+
static Request findFileStructure(FindFileStructureRequest findFileStructureRequest) {
655+
String endpoint = new EndpointBuilder()
656+
.addPathPartAsIs("_xpack")
657+
.addPathPartAsIs("ml")
658+
.addPathPartAsIs("find_file_structure")
659+
.build();
660+
Request request = new Request(HttpPost.METHOD_NAME, endpoint);
661+
662+
RequestConverters.Params params = new RequestConverters.Params(request);
663+
if (findFileStructureRequest.getLinesToSample() != null) {
664+
params.putParam(FindFileStructureRequest.LINES_TO_SAMPLE.getPreferredName(),
665+
findFileStructureRequest.getLinesToSample().toString());
666+
}
667+
if (findFileStructureRequest.getTimeout() != null) {
668+
params.putParam(FindFileStructureRequest.TIMEOUT.getPreferredName(), findFileStructureRequest.getTimeout().toString());
669+
}
670+
if (findFileStructureRequest.getCharset() != null) {
671+
params.putParam(FindFileStructureRequest.CHARSET.getPreferredName(), findFileStructureRequest.getCharset());
672+
}
673+
if (findFileStructureRequest.getFormat() != null) {
674+
params.putParam(FindFileStructureRequest.FORMAT.getPreferredName(), findFileStructureRequest.getFormat().toString());
675+
}
676+
if (findFileStructureRequest.getColumnNames() != null) {
677+
params.putParam(FindFileStructureRequest.COLUMN_NAMES.getPreferredName(),
678+
Strings.collectionToCommaDelimitedString(findFileStructureRequest.getColumnNames()));
679+
}
680+
if (findFileStructureRequest.getHasHeaderRow() != null) {
681+
params.putParam(FindFileStructureRequest.HAS_HEADER_ROW.getPreferredName(),
682+
findFileStructureRequest.getHasHeaderRow().toString());
683+
}
684+
if (findFileStructureRequest.getDelimiter() != null) {
685+
params.putParam(FindFileStructureRequest.DELIMITER.getPreferredName(),
686+
findFileStructureRequest.getDelimiter().toString());
687+
}
688+
if (findFileStructureRequest.getQuote() != null) {
689+
params.putParam(FindFileStructureRequest.QUOTE.getPreferredName(), findFileStructureRequest.getQuote().toString());
690+
}
691+
if (findFileStructureRequest.getShouldTrimFields() != null) {
692+
params.putParam(FindFileStructureRequest.SHOULD_TRIM_FIELDS.getPreferredName(),
693+
findFileStructureRequest.getShouldTrimFields().toString());
694+
}
695+
if (findFileStructureRequest.getGrokPattern() != null) {
696+
params.putParam(FindFileStructureRequest.GROK_PATTERN.getPreferredName(), findFileStructureRequest.getGrokPattern());
697+
}
698+
if (findFileStructureRequest.getTimestampFormat() != null) {
699+
params.putParam(FindFileStructureRequest.TIMESTAMP_FORMAT.getPreferredName(), findFileStructureRequest.getTimestampFormat());
700+
}
701+
if (findFileStructureRequest.getTimestampField() != null) {
702+
params.putParam(FindFileStructureRequest.TIMESTAMP_FIELD.getPreferredName(), findFileStructureRequest.getTimestampField());
703+
}
704+
if (findFileStructureRequest.getExplain() != null) {
705+
params.putParam(FindFileStructureRequest.EXPLAIN.getPreferredName(), findFileStructureRequest.getExplain().toString());
706+
}
707+
708+
BytesReference sample = findFileStructureRequest.getSample();
709+
BytesRef source = sample.toBytesRef();
710+
HttpEntity byteEntity = new ByteArrayEntity(source.bytes, source.offset, source.length, createContentType(XContentType.JSON));
711+
request.setEntity(byteEntity);
712+
return request;
713+
}
622714
}

0 commit comments

Comments
 (0)