-
Notifications
You must be signed in to change notification settings - Fork 25.8k
Add delayed datacheck to the datafeed job runner #35387
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
benwtrent
merged 23 commits into
elastic:master
from
benwtrent:feature/ml-datafeed-job-check-missing-data
Nov 15, 2018
Merged
Changes from 8 commits
Commits
Show all changes
23 commits
Select commit
Hold shift + click to select a range
2066230
ML: Adding missing datacheck to datafeedjob
benwtrent a74221c
Adding client side and docs
benwtrent bdf37b1
Making adjustments to validations
benwtrent a74421c
Making values default to on, having more sensible limits
benwtrent c075d26
Merge branch 'master' into feature/ml-datafeed-job-check-missing-data
benwtrent 37c7319
Intermittent commit, still need to figure out interval
benwtrent 7f30afe
Adjusting delayed data check interval
benwtrent b462a72
updating docs
benwtrent de21564
Making parameter Boolean, so it is nullable
benwtrent f678265
Merge branch 'master' into feature/ml-datafeed-job-check-missing-data
benwtrent faa5fe1
Merge branch 'master' into feature/ml-datafeed-job-check-missing-data
benwtrent 352a03f
Merge branch 'master' into feature/ml-datafeed-job-check-missing-data
benwtrent 4e00aba
bumping bwc to 7 before backport
benwtrent f42f6a4
changing to version current
benwtrent 8c87189
Merge branch 'master' into feature/ml-datafeed-job-check-missing-data
benwtrent 061f9a3
moving delayed data check config its own object
benwtrent 183f7e7
Separation of duties for delayed data detection
benwtrent 9655add
fixing checkstyles
benwtrent 2becd81
fixing checkstyles
benwtrent 47bbedb
Adjusting default behavior so that null windows are allowed
benwtrent 1fc77a9
Mentioning the default value
benwtrent 49de320
Fixing comments, syncing up validations
benwtrent 55d0980
Merge branch 'master' into feature/ml-datafeed-job-check-missing-data
benwtrent File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -62,6 +62,8 @@ public class DatafeedConfig implements ToXContentObject { | |
| public static final ParseField AGGREGATIONS = new ParseField("aggregations"); | ||
| public static final ParseField SCRIPT_FIELDS = new ParseField("script_fields"); | ||
| public static final ParseField CHUNKING_CONFIG = new ParseField("chunking_config"); | ||
| public static final ParseField DELAYED_DATA_CHECK_WINDOW = new ParseField("delayed_data_check_window"); | ||
| public static final ParseField SHOULD_RUN_DELAYED_DATA_CHECK = new ParseField("should_run_delayed_data_check"); | ||
|
|
||
| public static final ConstructingObjectParser<Builder, Void> PARSER = new ConstructingObjectParser<>( | ||
| "datafeed_config", true, a -> new Builder((String)a[0], (String)a[1])); | ||
|
|
@@ -88,6 +90,9 @@ public class DatafeedConfig implements ToXContentObject { | |
| }, SCRIPT_FIELDS); | ||
| PARSER.declareInt(Builder::setScrollSize, SCROLL_SIZE); | ||
| PARSER.declareObject(Builder::setChunkingConfig, ChunkingConfig.PARSER, CHUNKING_CONFIG); | ||
| PARSER.declareString((builder, val) -> builder.setDelayedDataCheckWindow( | ||
| TimeValue.parseTimeValue(val, DELAYED_DATA_CHECK_WINDOW.getPreferredName())), DELAYED_DATA_CHECK_WINDOW); | ||
| PARSER.declareBoolean(Builder::setShouldRunDelayedDataCheck, SHOULD_RUN_DELAYED_DATA_CHECK); | ||
| } | ||
|
|
||
| private static BytesReference parseBytes(XContentParser parser) throws IOException { | ||
|
|
@@ -108,9 +113,16 @@ private static BytesReference parseBytes(XContentParser parser) throws IOExcepti | |
| private final Integer scrollSize; | ||
| private final ChunkingConfig chunkingConfig; | ||
|
|
||
| /** | ||
| * The window of time to check for missing data | ||
| */ | ||
| private final TimeValue delayedDataCheckWindow; | ||
| private final boolean shouldRunDelayedDataCheck; | ||
benwtrent marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
|
|
||
| private DatafeedConfig(String id, String jobId, TimeValue queryDelay, TimeValue frequency, List<String> indices, List<String> types, | ||
| BytesReference query, BytesReference aggregations, List<SearchSourceBuilder.ScriptField> scriptFields, | ||
| Integer scrollSize, ChunkingConfig chunkingConfig) { | ||
| Integer scrollSize, ChunkingConfig chunkingConfig, TimeValue delayedDataCheckWindow, | ||
| boolean shouldRunDelayedDataCheck) { | ||
| this.id = id; | ||
| this.jobId = jobId; | ||
| this.queryDelay = queryDelay; | ||
|
|
@@ -122,6 +134,8 @@ private DatafeedConfig(String id, String jobId, TimeValue queryDelay, TimeValue | |
| this.scriptFields = scriptFields == null ? null : Collections.unmodifiableList(scriptFields); | ||
| this.scrollSize = scrollSize; | ||
| this.chunkingConfig = chunkingConfig; | ||
| this.delayedDataCheckWindow = delayedDataCheckWindow; | ||
| this.shouldRunDelayedDataCheck = shouldRunDelayedDataCheck; | ||
| } | ||
|
|
||
| public String getId() { | ||
|
|
@@ -168,6 +182,21 @@ public ChunkingConfig getChunkingConfig() { | |
| return chunkingConfig; | ||
| } | ||
|
|
||
| /** | ||
| * The window of time in which to check for latent data | ||
| * @return The delayed data check window | ||
| */ | ||
| public TimeValue getDelayedDataCheckWindow() { | ||
| return delayedDataCheckWindow; | ||
| } | ||
|
|
||
| /** | ||
| * Should we check for delayed data | ||
| */ | ||
| public boolean getShouldRunDelayedDataCheck() { | ||
| return shouldRunDelayedDataCheck; | ||
| } | ||
|
|
||
| @Override | ||
| public XContentBuilder toXContent(XContentBuilder builder, Params params) throws IOException { | ||
| builder.startObject(); | ||
|
|
@@ -204,6 +233,10 @@ public XContentBuilder toXContent(XContentBuilder builder, Params params) throws | |
| if (chunkingConfig != null) { | ||
| builder.field(CHUNKING_CONFIG.getPreferredName(), chunkingConfig); | ||
| } | ||
| if (delayedDataCheckWindow != null) { | ||
| builder.field(DELAYED_DATA_CHECK_WINDOW.getPreferredName(), delayedDataCheckWindow.getStringRep()); | ||
| } | ||
| builder.field(SHOULD_RUN_DELAYED_DATA_CHECK.getPreferredName(), shouldRunDelayedDataCheck); | ||
|
|
||
| builder.endObject(); | ||
| return builder; | ||
|
|
@@ -244,7 +277,9 @@ public boolean equals(Object other) { | |
| && Objects.equals(this.scrollSize, that.scrollSize) | ||
| && Objects.equals(asMap(this.aggregations), asMap(that.aggregations)) | ||
| && Objects.equals(this.scriptFields, that.scriptFields) | ||
| && Objects.equals(this.chunkingConfig, that.chunkingConfig); | ||
| && Objects.equals(this.chunkingConfig, that.chunkingConfig) | ||
| && Objects.equals(this.delayedDataCheckWindow, that.delayedDataCheckWindow) | ||
| && Objects.equals(this.shouldRunDelayedDataCheck, that.shouldRunDelayedDataCheck); | ||
| } | ||
|
|
||
| /** | ||
|
|
@@ -255,7 +290,7 @@ public boolean equals(Object other) { | |
| @Override | ||
| public int hashCode() { | ||
| return Objects.hash(id, jobId, frequency, queryDelay, indices, types, asMap(query), scrollSize, asMap(aggregations), scriptFields, | ||
| chunkingConfig); | ||
| chunkingConfig, delayedDataCheckWindow, shouldRunDelayedDataCheck); | ||
| } | ||
|
|
||
| public static Builder builder(String id, String jobId) { | ||
|
|
@@ -275,6 +310,8 @@ public static class Builder { | |
| private List<SearchSourceBuilder.ScriptField> scriptFields; | ||
| private Integer scrollSize; | ||
| private ChunkingConfig chunkingConfig; | ||
| private TimeValue delayedDataCheckWindow; | ||
| private boolean shouldRunDelayedDataCheck; | ||
|
|
||
| public Builder(String id, String jobId) { | ||
| this.id = Objects.requireNonNull(id, ID.getPreferredName()); | ||
|
|
@@ -293,6 +330,8 @@ public Builder(DatafeedConfig config) { | |
| this.scriptFields = config.scriptFields; | ||
| this.scrollSize = config.scrollSize; | ||
| this.chunkingConfig = config.chunkingConfig; | ||
| this.delayedDataCheckWindow = config.getDelayedDataCheckWindow(); | ||
| this.shouldRunDelayedDataCheck = config.getShouldRunDelayedDataCheck(); | ||
| } | ||
|
|
||
| public Builder setIndices(List<String> indices) { | ||
|
|
@@ -366,9 +405,38 @@ public Builder setChunkingConfig(ChunkingConfig chunkingConfig) { | |
| return this; | ||
| } | ||
|
|
||
| /** | ||
| * This determines how far in the past we look for data being indexed too late for the datafeed to pick it up. | ||
| * | ||
| * We query the index to the latest finalized bucket from this TimeValue in the past looking to see if any data has been indexed | ||
| * since the data was read with the Datafeed. | ||
| * | ||
| * The window must be larger than the {@link org.elasticsearch.client.ml.job.config.AnalysisConfig#bucketSpan}, less than | ||
| * 24 hours, and span less than 10,000x buckets. | ||
| * | ||
| * @param delayedDataCheckWindow The time length in the past from the latest finalized bucket to look for latent data | ||
|
||
| * Defaults to 2 hours. | ||
| */ | ||
| public Builder setDelayedDataCheckWindow(TimeValue delayedDataCheckWindow) { | ||
| this.delayedDataCheckWindow = delayedDataCheckWindow; | ||
| return this; | ||
| } | ||
|
|
||
| /** | ||
| * When running the datafeed in real-time, should there be additional checks for data being indexed after the datafeed | ||
| * reads from the index. | ||
| * | ||
| * @param shouldRunDelayedDataCheck when {@code false} no checks are made for latent data in the real-time datafeed | ||
| * Defaults to {@code true} | ||
| */ | ||
| public Builder setShouldRunDelayedDataCheck(boolean shouldRunDelayedDataCheck) { | ||
| this.shouldRunDelayedDataCheck = shouldRunDelayedDataCheck; | ||
| return this; | ||
| } | ||
|
|
||
| public DatafeedConfig build() { | ||
| return new DatafeedConfig(id, jobId, queryDelay, frequency, indices, types, query, aggregations, scriptFields, scrollSize, | ||
| chunkingConfig); | ||
| chunkingConfig, delayedDataCheckWindow, shouldRunDelayedDataCheck); | ||
| } | ||
|
|
||
| private static BytesReference xContentToBytes(ToXContentObject object) throws IOException { | ||
|
|
||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.