Skip to content

Commit 11f4565

Browse files
committed
Merge branch 'rename-ccr-stats' into follow-stats-structure
* rename-ccr-stats: (25 commits) HLRC: ML Adding get datafeed stats API (elastic#34271) Small fixes to the HLRC watcher documentation. (elastic#34306) Tasks: Document that status is not semvered (elastic#34270) HLRC: ML Add preview datafeed api (elastic#34284) [CI] Fix bogus ScheduleWithFixedDelayTests.testRunnableRunsAtMostOnceAfterCancellation Fix error in documentation for activete watch SCRIPTING: Terms set query expression (elastic#33856) Logging: Drop remaining Settings log ctor (elastic#34149) [ML] Remove unused last_data_time member from Job (elastic#34262) Docs: Allow skipping response assertions (elastic#34240) HLRC: Add activate watch action (elastic#33988) [Security] Multi Index Expression alias wildcard exclusion (elastic#34144) [ML] Label anomalies with multi_bucket_impact (elastic#34233) Document smtp.ssl.trust configuration option (elastic#34275) Support PKCS#11 tokens as keystores and truststores (elastic#34063) Fix sporadic failure in NestedObjectMapperTests [Authz] Allow update settings action for system user (elastic#34030) Replace version with reader cache key in IndicesRequestCache (elastic#34189) [TESTS] Set SO_LINGER and SO_REUSEADDR on the mock socket (elastic#34211) Security: upgrade unboundid ldapsdk to 4.0.8 (elastic#34247) ...
2 parents ae70db7 + 6833ad7 commit 11f4565

File tree

268 files changed

+4156
-1168
lines changed

Some content is hidden

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

268 files changed

+4156
-1168
lines changed

CONTRIBUTING.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -320,7 +320,7 @@ have to test Elasticsearch.
320320
#### Configurations
321321

322322
Gradle organizes dependencies and build artifacts into "configurations" and
323-
allows you to use these configurations arbitrarilly. Here are some of the most
323+
allows you to use these configurations arbitrarily. Here are some of the most
324324
common configurations in our build and how we use them:
325325

326326
<dl>

TESTING.asciidoc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -250,7 +250,7 @@ Pass arbitrary jvm arguments.
250250

251251
Running backwards compatibility tests is disabled by default since it
252252
requires a release version of elasticsearch to be present on the test system.
253-
To run backwards compatibilty tests untar or unzip a release and run the tests
253+
To run backwards compatibility tests untar or unzip a release and run the tests
254254
with the following command:
255255

256256
---------------------------------------------------------------------------

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -122,7 +122,7 @@ class VersionCollection {
122122
if (isReleased(version) == false) {
123123
// caveat 1 - This should only ever contain 2 non released branches in flight. An example is 6.x is frozen,
124124
// and 6.2 is cut but not yet released there is some simple logic to make sure that in the case of more than 2,
125-
// it will bail. The order is that the minor snapshot is fufilled first, and then the staged minor snapshot
125+
// it will bail. The order is that the minor snapshot is fulfilled first, and then the staged minor snapshot
126126
if (nextMinorSnapshot == null) {
127127
// it has not been set yet
128128
nextMinorSnapshot = replaceAsSnapshot(version)

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

Lines changed: 12 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -72,7 +72,7 @@ public class RestTestsFromSnippetsTask extends SnippetsTask {
7272

7373
/**
7474
* Root directory containing all the files generated by this task. It is
75-
* contained withing testRoot.
75+
* contained within testRoot.
7676
*/
7777
File outputRoot() {
7878
return new File(testRoot, '/rest-api-spec/test')
@@ -226,10 +226,10 @@ public class RestTestsFromSnippetsTask extends SnippetsTask {
226226
} else {
227227
current.println('---')
228228
current.println("\"line_$test.start\":")
229-
/* The Elasticsearch test runner doesn't support the warnings
230-
* construct unless you output this skip. Since we don't know
231-
* if this snippet will use the warnings construct we emit this
232-
* warning every time. */
229+
/* The Elasticsearch test runner doesn't support quite a few
230+
* constructs unless we output this skip. We don't know if
231+
* we're going to use these constructs, but we might so we
232+
* output the skip just in case. */
233233
current.println(" - skip:")
234234
current.println(" features: ")
235235
current.println(" - default_shards")
@@ -250,13 +250,13 @@ public class RestTestsFromSnippetsTask extends SnippetsTask {
250250
}
251251
}
252252
}
253-
if (test.skipTest) {
253+
if (test.skip) {
254254
if (test.continued) {
255255
throw new InvalidUserDataException("Continued snippets "
256256
+ "can't be skipped")
257257
}
258258
current.println(" - always_skip")
259-
current.println(" reason: $test.skipTest")
259+
current.println(" reason: $test.skip")
260260
}
261261
if (test.setup != null) {
262262
// Insert a setup defined outside of the docs
@@ -274,9 +274,11 @@ public class RestTestsFromSnippetsTask extends SnippetsTask {
274274
}
275275

276276
private void response(Snippet response) {
277-
current.println(" - match: ")
278-
current.println(" \$body: ")
279-
response.contents.eachLine { current.println(" $it") }
277+
if (null == response.skip) {
278+
current.println(" - match: ")
279+
current.println(" \$body: ")
280+
response.contents.eachLine { current.println(" $it") }
281+
}
280282
}
281283

282284
void emitDo(String method, String pathAndQuery, String body,

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

Lines changed: 14 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -122,7 +122,9 @@ public class SnippetsTask extends DefaultTask {
122122
+ "contain `curl`.")
123123
}
124124
}
125-
if (snippet.testResponse && snippet.language == 'js') {
125+
if (snippet.testResponse
126+
&& 'js' == snippet.language
127+
&& null == snippet.skip) {
126128
String quoted = snippet.contents
127129
// quote values starting with $
128130
.replaceAll(/([:,])\s*(\$[^ ,\n}]+)/, '$1 "$2"')
@@ -216,7 +218,7 @@ public class SnippetsTask extends DefaultTask {
216218
return
217219
}
218220
if (it.group(4) != null) {
219-
snippet.skipTest = it.group(4)
221+
snippet.skip = it.group(4)
220222
return
221223
}
222224
if (it.group(5) != null) {
@@ -249,7 +251,7 @@ public class SnippetsTask extends DefaultTask {
249251
substitutions = []
250252
}
251253
String loc = "$file:$lineNumber"
252-
parse(loc, matcher.group(2), /(?:$SUBSTITUTION|$CAT) ?/) {
254+
parse(loc, matcher.group(2), /(?:$SUBSTITUTION|$CAT|$SKIP) ?/) {
253255
if (it.group(1) != null) {
254256
// TESTRESPONSE[s/adsf/jkl/]
255257
substitutions.add([it.group(1), it.group(2)])
@@ -259,6 +261,9 @@ public class SnippetsTask extends DefaultTask {
259261
substitutions.add(['\n$', '\\\\s*/'])
260262
substitutions.add(['( +)', '$1\\\\s+'])
261263
substitutions.add(['\n', '\\\\s*\n '])
264+
} else if (it.group(4) != null) {
265+
// TESTRESPONSE[skip:reason]
266+
snippet.skip = it.group(4)
262267
}
263268
}
264269
}
@@ -312,7 +317,7 @@ public class SnippetsTask extends DefaultTask {
312317
boolean test = false
313318
boolean testResponse = false
314319
boolean testSetup = false
315-
String skipTest = null
320+
String skip = null
316321
boolean continued = false
317322
String language = null
318323
String catchPart = null
@@ -337,8 +342,8 @@ public class SnippetsTask extends DefaultTask {
337342
if (catchPart) {
338343
result += "[catch: $catchPart]"
339344
}
340-
if (skipTest) {
341-
result += "[skip=$skipTest]"
345+
if (skip) {
346+
result += "[skip=$skip]"
342347
}
343348
if (continued) {
344349
result += '[continued]'
@@ -352,6 +357,9 @@ public class SnippetsTask extends DefaultTask {
352357
}
353358
if (testResponse) {
354359
result += '// TESTRESPONSE'
360+
if (skip) {
361+
result += "[skip=$skip]"
362+
}
355363
}
356364
if (testSetup) {
357365
result += '// TESTSETUP'

buildSrc/src/main/groovy/org/elasticsearch/gradle/test/NodeInfo.groovy

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -337,7 +337,7 @@ class NodeInfo {
337337
case 'deb':
338338
return new File(baseDir, "${distro}-extracted/etc/elasticsearch")
339339
default:
340-
throw new InvalidUserDataException("Unkown distribution: ${distro}")
340+
throw new InvalidUserDataException("Unknown distribution: ${distro}")
341341
}
342342
}
343343
}

buildSrc/src/testKit/elasticsearch-build-resources/build.gradle

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ task sample {
2222
// dependsOn buildResources.outputDir
2323
// for now it's just
2424
dependsOn buildResources
25-
// we have to refference it at configuration time in order to be picked up
25+
// we have to reference it at configuration time in order to be picked up
2626
ext.checkstyle_suppressions = buildResources.copy('checkstyle_suppressions.xml')
2727
doLast {
2828
println "This task is using ${file(checkstyle_suppressions)}"
@@ -35,4 +35,4 @@ task noConfigAfterExecution {
3535
println "This should cause an error because we are refferencing " +
3636
"${buildResources.copy('checkstyle_suppressions.xml')} after the `buildResources` task has ran."
3737
}
38-
}
38+
}

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

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,13 +38,15 @@
3838
import org.elasticsearch.client.ml.GetCalendarsRequest;
3939
import org.elasticsearch.client.ml.GetCategoriesRequest;
4040
import org.elasticsearch.client.ml.GetDatafeedRequest;
41+
import org.elasticsearch.client.ml.GetDatafeedStatsRequest;
4142
import org.elasticsearch.client.ml.GetInfluencersRequest;
4243
import org.elasticsearch.client.ml.GetJobRequest;
4344
import org.elasticsearch.client.ml.GetJobStatsRequest;
4445
import org.elasticsearch.client.ml.GetOverallBucketsRequest;
4546
import org.elasticsearch.client.ml.GetRecordsRequest;
4647
import org.elasticsearch.client.ml.OpenJobRequest;
4748
import org.elasticsearch.client.ml.PostDataRequest;
49+
import org.elasticsearch.client.ml.PreviewDatafeedRequest;
4850
import org.elasticsearch.client.ml.PutCalendarRequest;
4951
import org.elasticsearch.client.ml.PutDatafeedRequest;
5052
import org.elasticsearch.client.ml.PutJobRequest;
@@ -259,6 +261,34 @@ static Request stopDatafeed(StopDatafeedRequest stopDatafeedRequest) throws IOEx
259261
return request;
260262
}
261263

264+
static Request getDatafeedStats(GetDatafeedStatsRequest getDatafeedStatsRequest) {
265+
String endpoint = new EndpointBuilder()
266+
.addPathPartAsIs("_xpack")
267+
.addPathPartAsIs("ml")
268+
.addPathPartAsIs("datafeeds")
269+
.addPathPart(Strings.collectionToCommaDelimitedString(getDatafeedStatsRequest.getDatafeedIds()))
270+
.addPathPartAsIs("_stats")
271+
.build();
272+
Request request = new Request(HttpGet.METHOD_NAME, endpoint);
273+
274+
RequestConverters.Params params = new RequestConverters.Params(request);
275+
if (getDatafeedStatsRequest.isAllowNoDatafeeds() != null) {
276+
params.putParam("allow_no_datafeeds", Boolean.toString(getDatafeedStatsRequest.isAllowNoDatafeeds()));
277+
}
278+
return request;
279+
}
280+
281+
static Request previewDatafeed(PreviewDatafeedRequest previewDatafeedRequest) {
282+
String endpoint = new EndpointBuilder()
283+
.addPathPartAsIs("_xpack")
284+
.addPathPartAsIs("ml")
285+
.addPathPartAsIs("datafeeds")
286+
.addPathPart(previewDatafeedRequest.getDatafeedId())
287+
.addPathPartAsIs("_preview")
288+
.build();
289+
return new Request(HttpGet.METHOD_NAME, endpoint);
290+
}
291+
262292
static Request deleteForecast(DeleteForecastRequest deleteForecastRequest) {
263293
String endpoint = new EndpointBuilder()
264294
.addPathPartAsIs("_xpack")

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

Lines changed: 89 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,8 @@
3838
import org.elasticsearch.client.ml.GetCategoriesResponse;
3939
import org.elasticsearch.client.ml.GetDatafeedRequest;
4040
import org.elasticsearch.client.ml.GetDatafeedResponse;
41+
import org.elasticsearch.client.ml.GetDatafeedStatsRequest;
42+
import org.elasticsearch.client.ml.GetDatafeedStatsResponse;
4143
import org.elasticsearch.client.ml.GetInfluencersRequest;
4244
import org.elasticsearch.client.ml.GetInfluencersResponse;
4345
import org.elasticsearch.client.ml.GetJobRequest;
@@ -52,6 +54,8 @@
5254
import org.elasticsearch.client.ml.OpenJobResponse;
5355
import org.elasticsearch.client.ml.PostDataRequest;
5456
import org.elasticsearch.client.ml.PostDataResponse;
57+
import org.elasticsearch.client.ml.PreviewDatafeedRequest;
58+
import org.elasticsearch.client.ml.PreviewDatafeedResponse;
5559
import org.elasticsearch.client.ml.PutCalendarRequest;
5660
import org.elasticsearch.client.ml.PutCalendarResponse;
5761
import org.elasticsearch.client.ml.PutDatafeedRequest;
@@ -181,7 +185,7 @@ public GetJobStatsResponse getJobStats(GetJobStatsRequest request, RequestOption
181185
}
182186

183187
/**
184-
* Gets one or more Machine Learning job configuration info, asynchronously.
188+
* Gets usage statistics for one or more Machine Learning jobs, asynchronously.
185189
* <p>
186190
* For additional info
187191
* see <a href="https://www.elastic.co/guide/en/elasticsearch/reference/current/ml-get-job-stats.html">Get job stats docs</a>
@@ -649,6 +653,90 @@ public void stopDatafeedAsync(StopDatafeedRequest request, RequestOptions option
649653
Collections.emptySet());
650654
}
651655

656+
/**
657+
* Gets statistics for one or more Machine Learning datafeeds
658+
* <p>
659+
* For additional info
660+
* see <a href="https://www.elastic.co/guide/en/elasticsearch/reference/current/ml-get-datafeed-stats.html">Get datafeed stats docs</a>
661+
*
662+
* @param request {@link GetDatafeedStatsRequest} Request containing a list of datafeedId(s) and additional options
663+
* @param options Additional request options (e.g. headers), use {@link RequestOptions#DEFAULT} if nothing needs to be customized
664+
* @return {@link GetDatafeedStatsResponse} response object containing
665+
* the {@link org.elasticsearch.client.ml.datafeed.DatafeedStats} objects and the number of datafeeds found
666+
* @throws IOException when there is a serialization issue sending the request or receiving the response
667+
*/
668+
public GetDatafeedStatsResponse getDatafeedStats(GetDatafeedStatsRequest request, RequestOptions options) throws IOException {
669+
return restHighLevelClient.performRequestAndParseEntity(request,
670+
MLRequestConverters::getDatafeedStats,
671+
options,
672+
GetDatafeedStatsResponse::fromXContent,
673+
Collections.emptySet());
674+
}
675+
676+
/**
677+
* Previews the given Machine Learning Datafeed
678+
* <p>
679+
* For additional info
680+
* see <a href="http://www.elastic.co/guide/en/elasticsearch/reference/current/ml-preview-datafeed.html">
681+
* ML Preview Datafeed documentation</a>
682+
*
683+
* @param request The request to preview the datafeed
684+
* @param options Additional request options (e.g. headers), use {@link RequestOptions#DEFAULT} if nothing needs to be customized
685+
* @return {@link PreviewDatafeedResponse} object containing a {@link org.elasticsearch.common.bytes.BytesReference} of the data in
686+
* JSON format
687+
* @throws IOException when there is a serialization issue sending the request or receiving the response
688+
*/
689+
public PreviewDatafeedResponse previewDatafeed(PreviewDatafeedRequest request, RequestOptions options) throws IOException {
690+
return restHighLevelClient.performRequestAndParseEntity(request,
691+
MLRequestConverters::previewDatafeed,
692+
options,
693+
PreviewDatafeedResponse::fromXContent,
694+
Collections.emptySet());
695+
}
696+
697+
/**
698+
* Gets statistics for one or more Machine Learning datafeeds, asynchronously.
699+
* <p>
700+
* For additional info
701+
* see <a href="https://www.elastic.co/guide/en/elasticsearch/reference/current/ml-get-datafeed-stats.html">Get datafeed stats docs</a>
702+
*
703+
* @param request {@link GetDatafeedStatsRequest} Request containing a list of datafeedId(s) and additional options
704+
* @param options Additional request options (e.g. headers), use {@link RequestOptions#DEFAULT} if nothing needs to be customized
705+
* @param listener Listener to be notified with {@link GetDatafeedStatsResponse} upon request completion
706+
*/
707+
public void getDatafeedStatsAsync(GetDatafeedStatsRequest request,
708+
RequestOptions options,
709+
ActionListener<GetDatafeedStatsResponse> listener) {
710+
restHighLevelClient.performRequestAsyncAndParseEntity(request,
711+
MLRequestConverters::getDatafeedStats,
712+
options,
713+
GetDatafeedStatsResponse::fromXContent,
714+
listener,
715+
Collections.emptySet());
716+
}
717+
718+
/**
719+
* Previews the given Machine Learning Datafeed asynchronously and notifies the listener on completion
720+
* <p>
721+
* For additional info
722+
* see <a href="http://www.elastic.co/guide/en/elasticsearch/reference/current/ml-preview-datafeed.html">
723+
* ML Preview Datafeed documentation</a>
724+
*
725+
* @param request The request to preview the datafeed
726+
* @param options Additional request options (e.g. headers), use {@link RequestOptions#DEFAULT} if nothing needs to be customized
727+
* @param listener Listener to be notified upon request completion
728+
*/
729+
public void previewDatafeedAsync(PreviewDatafeedRequest request,
730+
RequestOptions options,
731+
ActionListener<PreviewDatafeedResponse> listener) {
732+
restHighLevelClient.performRequestAsyncAndParseEntity(request,
733+
MLRequestConverters::previewDatafeed,
734+
options,
735+
PreviewDatafeedResponse::fromXContent,
736+
listener,
737+
Collections.emptySet());
738+
}
739+
652740
/**
653741
* Updates a Machine Learning {@link org.elasticsearch.client.ml.job.config.Job}
654742
* <p>

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

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,8 @@
1919
package org.elasticsearch.client;
2020

2121
import org.elasticsearch.action.ActionListener;
22+
import org.elasticsearch.client.watcher.ActivateWatchRequest;
23+
import org.elasticsearch.client.watcher.ActivateWatchResponse;
2224
import org.elasticsearch.client.watcher.AckWatchRequest;
2325
import org.elasticsearch.client.watcher.AckWatchResponse;
2426
import org.elasticsearch.protocol.xpack.watcher.DeleteWatchRequest;
@@ -121,4 +123,31 @@ public void ackWatchAsync(AckWatchRequest request, RequestOptions options, Actio
121123
AckWatchResponse::fromXContent, listener, emptySet());
122124
}
123125

126+
/**
127+
* Activate a watch from the cluster
128+
* See <a href="https://www.elastic.co/guide/en/elasticsearch/reference/current/watcher-api-activate-watch.html">
129+
* the docs</a> for more.
130+
* @param request the request
131+
* @param options the request options (e.g. headers), use {@link RequestOptions#DEFAULT} if nothing needs to be customized
132+
* @return the response
133+
* @throws IOException in case there is a problem sending the request or parsing back the response
134+
*/
135+
public ActivateWatchResponse activateWatch(ActivateWatchRequest request, RequestOptions options) throws IOException {
136+
return restHighLevelClient.performRequestAndParseEntity(request, WatcherRequestConverters::activateWatch, options,
137+
ActivateWatchResponse::fromXContent, singleton(404));
138+
}
139+
140+
/**
141+
* Asynchronously activates a watch from the cluster
142+
* See <a href="https://www.elastic.co/guide/en/elasticsearch/reference/current/watcher-api-activate-watch.html">
143+
* the docs</a> for more.
144+
* @param request the request
145+
* @param options the request options (e.g. headers), use {@link RequestOptions#DEFAULT} if nothing needs to be customized
146+
* @param listener the listener to be notified upon request completion
147+
*/
148+
public void activateWatchAsync(ActivateWatchRequest request, RequestOptions options, ActionListener<ActivateWatchResponse> listener) {
149+
restHighLevelClient.performRequestAsyncAndParseEntity(request, WatcherRequestConverters::activateWatch, options,
150+
ActivateWatchResponse::fromXContent, listener, singleton(404));
151+
}
152+
124153
}

0 commit comments

Comments
 (0)