|
@@ -5,6 +5,7 @@
|
|
|
*/
|
|
|
package org.elasticsearch.xpack.core.ml.datafeed;
|
|
|
|
|
|
+import org.elasticsearch.Version;
|
|
|
import org.elasticsearch.common.ParseField;
|
|
|
import org.elasticsearch.common.Strings;
|
|
|
import org.elasticsearch.common.io.stream.StreamInput;
|
|
@@ -68,6 +69,9 @@ public class DatafeedUpdate implements Writeable, ToXContentObject {
|
|
|
}, DatafeedConfig.SCRIPT_FIELDS);
|
|
|
PARSER.declareInt(Builder::setScrollSize, DatafeedConfig.SCROLL_SIZE);
|
|
|
PARSER.declareObject(Builder::setChunkingConfig, ChunkingConfig.STRICT_PARSER, DatafeedConfig.CHUNKING_CONFIG);
|
|
|
+ PARSER.declareObject(Builder::setDelayedDataCheckConfig,
|
|
|
+ DelayedDataCheckConfig.STRICT_PARSER,
|
|
|
+ DatafeedConfig.DELAYED_DATA_CHECK_CONFIG);
|
|
|
}
|
|
|
|
|
|
private final String id;
|
|
@@ -81,10 +85,11 @@ public class DatafeedUpdate implements Writeable, ToXContentObject {
|
|
|
private final List<SearchSourceBuilder.ScriptField> scriptFields;
|
|
|
private final Integer scrollSize;
|
|
|
private final ChunkingConfig chunkingConfig;
|
|
|
+ private final DelayedDataCheckConfig delayedDataCheckConfig;
|
|
|
|
|
|
private DatafeedUpdate(String id, String jobId, TimeValue queryDelay, TimeValue frequency, List<String> indices, List<String> types,
|
|
|
QueryBuilder query, AggregatorFactories.Builder aggregations, List<SearchSourceBuilder.ScriptField> scriptFields,
|
|
|
- Integer scrollSize, ChunkingConfig chunkingConfig) {
|
|
|
+ Integer scrollSize, ChunkingConfig chunkingConfig, DelayedDataCheckConfig delayedDataCheckConfig) {
|
|
|
this.id = id;
|
|
|
this.jobId = jobId;
|
|
|
this.queryDelay = queryDelay;
|
|
@@ -96,6 +101,7 @@ public class DatafeedUpdate implements Writeable, ToXContentObject {
|
|
|
this.scriptFields = scriptFields;
|
|
|
this.scrollSize = scrollSize;
|
|
|
this.chunkingConfig = chunkingConfig;
|
|
|
+ this.delayedDataCheckConfig = delayedDataCheckConfig;
|
|
|
}
|
|
|
|
|
|
public DatafeedUpdate(StreamInput in) throws IOException {
|
|
@@ -122,6 +128,11 @@ public class DatafeedUpdate implements Writeable, ToXContentObject {
|
|
|
}
|
|
|
this.scrollSize = in.readOptionalVInt();
|
|
|
this.chunkingConfig = in.readOptionalWriteable(ChunkingConfig::new);
|
|
|
+ if (in.getVersion().onOrAfter(Version.CURRENT)) {
|
|
|
+ delayedDataCheckConfig = in.readOptionalWriteable(DelayedDataCheckConfig::new);
|
|
|
+ } else {
|
|
|
+ delayedDataCheckConfig = null;
|
|
|
+ }
|
|
|
}
|
|
|
|
|
|
/**
|
|
@@ -159,6 +170,9 @@ public class DatafeedUpdate implements Writeable, ToXContentObject {
|
|
|
}
|
|
|
out.writeOptionalVInt(scrollSize);
|
|
|
out.writeOptionalWriteable(chunkingConfig);
|
|
|
+ if (out.getVersion().onOrAfter(Version.CURRENT)) {
|
|
|
+ out.writeOptionalWriteable(delayedDataCheckConfig);
|
|
|
+ }
|
|
|
}
|
|
|
|
|
|
@Override
|
|
@@ -185,6 +199,7 @@ public class DatafeedUpdate implements Writeable, ToXContentObject {
|
|
|
}
|
|
|
addOptionalField(builder, DatafeedConfig.SCROLL_SIZE, scrollSize);
|
|
|
addOptionalField(builder, DatafeedConfig.CHUNKING_CONFIG, chunkingConfig);
|
|
|
+ addOptionalField(builder, DatafeedConfig.DELAYED_DATA_CHECK_CONFIG, delayedDataCheckConfig);
|
|
|
builder.endObject();
|
|
|
return builder;
|
|
|
}
|
|
@@ -250,6 +265,10 @@ public class DatafeedUpdate implements Writeable, ToXContentObject {
|
|
|
return chunkingConfig;
|
|
|
}
|
|
|
|
|
|
+ public DelayedDataCheckConfig getDelayedDataCheckConfig() {
|
|
|
+ return delayedDataCheckConfig;
|
|
|
+ }
|
|
|
+
|
|
|
/**
|
|
|
* Applies the update to the given {@link DatafeedConfig}
|
|
|
* @return a new {@link DatafeedConfig} that contains the update
|
|
@@ -290,6 +309,9 @@ public class DatafeedUpdate implements Writeable, ToXContentObject {
|
|
|
if (chunkingConfig != null) {
|
|
|
builder.setChunkingConfig(chunkingConfig);
|
|
|
}
|
|
|
+ if (delayedDataCheckConfig != null) {
|
|
|
+ builder.setDelayedDataCheckConfig(delayedDataCheckConfig);
|
|
|
+ }
|
|
|
|
|
|
if (headers.isEmpty() == false) {
|
|
|
// Adjust the request, adding security headers from the current thread context
|
|
@@ -328,6 +350,7 @@ public class DatafeedUpdate implements Writeable, ToXContentObject {
|
|
|
&& Objects.equals(this.query, that.query)
|
|
|
&& Objects.equals(this.scrollSize, that.scrollSize)
|
|
|
&& Objects.equals(this.aggregations, that.aggregations)
|
|
|
+ && Objects.equals(this.delayedDataCheckConfig, that.delayedDataCheckConfig)
|
|
|
&& Objects.equals(this.scriptFields, that.scriptFields)
|
|
|
&& Objects.equals(this.chunkingConfig, that.chunkingConfig);
|
|
|
}
|
|
@@ -335,7 +358,7 @@ public class DatafeedUpdate implements Writeable, ToXContentObject {
|
|
|
@Override
|
|
|
public int hashCode() {
|
|
|
return Objects.hash(id, jobId, frequency, queryDelay, indices, types, query, scrollSize, aggregations, scriptFields,
|
|
|
- chunkingConfig);
|
|
|
+ chunkingConfig, delayedDataCheckConfig);
|
|
|
}
|
|
|
|
|
|
@Override
|
|
@@ -352,6 +375,7 @@ public class DatafeedUpdate implements Writeable, ToXContentObject {
|
|
|
&& (scrollSize == null || Objects.equals(scrollSize, datafeed.getQueryDelay()))
|
|
|
&& (aggregations == null || Objects.equals(aggregations, datafeed.getAggregations()))
|
|
|
&& (scriptFields == null || Objects.equals(scriptFields, datafeed.getScriptFields()))
|
|
|
+ && (delayedDataCheckConfig == null || Objects.equals(delayedDataCheckConfig, datafeed.getDelayedDataCheckConfig()))
|
|
|
&& (chunkingConfig == null || Objects.equals(chunkingConfig, datafeed.getChunkingConfig()));
|
|
|
}
|
|
|
|
|
@@ -368,6 +392,7 @@ public class DatafeedUpdate implements Writeable, ToXContentObject {
|
|
|
private List<SearchSourceBuilder.ScriptField> scriptFields;
|
|
|
private Integer scrollSize;
|
|
|
private ChunkingConfig chunkingConfig;
|
|
|
+ private DelayedDataCheckConfig delayedDataCheckConfig;
|
|
|
|
|
|
public Builder() {
|
|
|
}
|
|
@@ -388,6 +413,7 @@ public class DatafeedUpdate implements Writeable, ToXContentObject {
|
|
|
this.scriptFields = config.scriptFields;
|
|
|
this.scrollSize = config.scrollSize;
|
|
|
this.chunkingConfig = config.chunkingConfig;
|
|
|
+ this.delayedDataCheckConfig = config.delayedDataCheckConfig;
|
|
|
}
|
|
|
|
|
|
public void setId(String datafeedId) {
|
|
@@ -428,6 +454,10 @@ public class DatafeedUpdate implements Writeable, ToXContentObject {
|
|
|
this.scriptFields = sorted;
|
|
|
}
|
|
|
|
|
|
+ public void setDelayedDataCheckConfig(DelayedDataCheckConfig delayedDataCheckConfig) {
|
|
|
+ this.delayedDataCheckConfig = delayedDataCheckConfig;
|
|
|
+ }
|
|
|
+
|
|
|
public void setScrollSize(int scrollSize) {
|
|
|
this.scrollSize = scrollSize;
|
|
|
}
|
|
@@ -438,7 +468,7 @@ public class DatafeedUpdate implements Writeable, ToXContentObject {
|
|
|
|
|
|
public DatafeedUpdate build() {
|
|
|
return new DatafeedUpdate(id, jobId, queryDelay, frequency, indices, types, query, aggregations, scriptFields, scrollSize,
|
|
|
- chunkingConfig);
|
|
|
+ chunkingConfig, delayedDataCheckConfig);
|
|
|
}
|
|
|
}
|
|
|
}
|