-
Notifications
You must be signed in to change notification settings - Fork 25.2k
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 all 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
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
130 changes: 130 additions & 0 deletions
130
...high-level/src/main/java/org/elasticsearch/client/ml/datafeed/DelayedDataCheckConfig.java
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 |
---|---|---|
@@ -0,0 +1,130 @@ | ||
/* | ||
* Licensed to Elasticsearch under one or more contributor | ||
* license agreements. See the NOTICE file distributed with | ||
* this work for additional information regarding copyright | ||
* ownership. Elasticsearch licenses this file to you under | ||
* the Apache License, Version 2.0 (the "License"); you may | ||
* not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, | ||
* software distributed under the License is distributed on an | ||
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY | ||
* KIND, either express or implied. See the License for the | ||
* specific language governing permissions and limitations | ||
* under the License. | ||
*/ | ||
package org.elasticsearch.client.ml.datafeed; | ||
|
||
import org.elasticsearch.common.Nullable; | ||
import org.elasticsearch.common.ParseField; | ||
import org.elasticsearch.common.unit.TimeValue; | ||
import org.elasticsearch.common.xcontent.ConstructingObjectParser; | ||
import org.elasticsearch.common.xcontent.ObjectParser; | ||
import org.elasticsearch.common.xcontent.ToXContentObject; | ||
import org.elasticsearch.common.xcontent.XContentBuilder; | ||
import org.elasticsearch.common.xcontent.XContentParser; | ||
|
||
import java.io.IOException; | ||
import java.util.Objects; | ||
|
||
/** | ||
* The configuration object containing the delayed data check settings. | ||
* | ||
* See {@link DelayedDataCheckConfig#enabledDelayedDataCheckConfig(TimeValue)} for creating a new | ||
* enabled datacheck with the given check_window | ||
* | ||
* See {@link DelayedDataCheckConfig#disabledDelayedDataCheckConfig()} for creating a config for disabling | ||
* delayed data checking. | ||
*/ | ||
public class DelayedDataCheckConfig implements ToXContentObject { | ||
|
||
public static final ParseField ENABLED = new ParseField("enabled"); | ||
public static final ParseField CHECK_WINDOW = new ParseField("check_window"); | ||
|
||
// These parsers follow the pattern that metadata is parsed leniently (to allow for enhancements), whilst config is parsed strictly | ||
public static final ConstructingObjectParser<DelayedDataCheckConfig, Void> PARSER = new ConstructingObjectParser<>( | ||
"delayed_data_check_config", true, a -> new DelayedDataCheckConfig((Boolean) a[0], (TimeValue) a[1])); | ||
static { | ||
PARSER.declareBoolean(ConstructingObjectParser.constructorArg(), ENABLED); | ||
PARSER.declareField(ConstructingObjectParser.optionalConstructorArg(), p -> { | ||
if (p.currentToken() == XContentParser.Token.VALUE_STRING) { | ||
return TimeValue.parseTimeValue(p.text(), CHECK_WINDOW.getPreferredName()); | ||
} | ||
throw new IllegalArgumentException("Unsupported token [" + p.currentToken() + "]"); | ||
}, CHECK_WINDOW, ObjectParser.ValueType.STRING); | ||
} | ||
|
||
/** | ||
* This creates a new DelayedDataCheckConfig that has a check_window of the passed `timeValue` | ||
* | ||
* 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 timeValue The time length in the past from the latest finalized bucket to look for latent data. | ||
* If `null` is provided, the appropriate window is calculated when it is used | ||
**/ | ||
public static DelayedDataCheckConfig enabledDelayedDataCheckConfig(TimeValue timeValue) { | ||
return new DelayedDataCheckConfig(true, timeValue); | ||
} | ||
|
||
/** | ||
* This creates a new DelayedDataCheckConfig that disables the data check. | ||
*/ | ||
public static DelayedDataCheckConfig disabledDelayedDataCheckConfig() { | ||
return new DelayedDataCheckConfig(false, null); | ||
} | ||
|
||
private final boolean enabled; | ||
private final TimeValue checkWindow; | ||
|
||
DelayedDataCheckConfig(Boolean enabled, TimeValue checkWindow) { | ||
this.enabled = enabled; | ||
this.checkWindow = checkWindow; | ||
} | ||
|
||
public boolean isEnabled() { | ||
return enabled; | ||
} | ||
|
||
@Nullable | ||
public TimeValue getCheckWindow() { | ||
return checkWindow; | ||
} | ||
|
||
@Override | ||
public XContentBuilder toXContent(XContentBuilder builder, Params params) throws IOException { | ||
builder.startObject(); | ||
builder.field(ENABLED.getPreferredName(), enabled); | ||
if (checkWindow != null) { | ||
builder.field(CHECK_WINDOW.getPreferredName(), checkWindow.getStringRep()); | ||
} | ||
builder.endObject(); | ||
return builder; | ||
} | ||
|
||
@Override | ||
public int hashCode() { | ||
return Objects.hash(enabled, checkWindow); | ||
} | ||
|
||
@Override | ||
public boolean equals(Object obj) { | ||
if (this == obj) { | ||
return true; | ||
} | ||
if (obj == null || getClass() != obj.getClass()) { | ||
return false; | ||
} | ||
|
||
DelayedDataCheckConfig other = (DelayedDataCheckConfig) obj; | ||
return Objects.equals(this.enabled, other.enabled) && Objects.equals(this.checkWindow, other.checkWindow); | ||
} | ||
|
||
} |
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.