[ML] Remove unused last_data_time member from Job (#34262)
This commit is contained in:
parent
dc2cf28fde
commit
ef5007b6d8
|
@ -57,7 +57,6 @@ public class Job implements ToXContentObject {
|
|||
public static final ParseField DATA_DESCRIPTION = new ParseField("data_description");
|
||||
public static final ParseField DESCRIPTION = new ParseField("description");
|
||||
public static final ParseField FINISHED_TIME = new ParseField("finished_time");
|
||||
public static final ParseField LAST_DATA_TIME = new ParseField("last_data_time");
|
||||
public static final ParseField ESTABLISHED_MODEL_MEMORY = new ParseField("established_model_memory");
|
||||
public static final ParseField MODEL_PLOT_CONFIG = new ParseField("model_plot_config");
|
||||
public static final ParseField RENORMALIZATION_WINDOW_DAYS = new ParseField("renormalization_window_days");
|
||||
|
@ -82,10 +81,6 @@ public class Job implements ToXContentObject {
|
|||
(p) -> TimeUtil.parseTimeField(p, FINISHED_TIME.getPreferredName()),
|
||||
FINISHED_TIME,
|
||||
ValueType.VALUE);
|
||||
PARSER.declareField(Builder::setLastDataTime,
|
||||
(p) -> TimeUtil.parseTimeField(p, LAST_DATA_TIME.getPreferredName()),
|
||||
LAST_DATA_TIME,
|
||||
ValueType.VALUE);
|
||||
PARSER.declareLong(Builder::setEstablishedModelMemory, ESTABLISHED_MODEL_MEMORY);
|
||||
PARSER.declareObject(Builder::setAnalysisConfig, AnalysisConfig.PARSER, ANALYSIS_CONFIG);
|
||||
PARSER.declareObject(Builder::setAnalysisLimits, AnalysisLimits.PARSER, ANALYSIS_LIMITS);
|
||||
|
@ -108,7 +103,6 @@ public class Job implements ToXContentObject {
|
|||
private final String description;
|
||||
private final Date createTime;
|
||||
private final Date finishedTime;
|
||||
private final Date lastDataTime;
|
||||
private final Long establishedModelMemory;
|
||||
private final AnalysisConfig analysisConfig;
|
||||
private final AnalysisLimits analysisLimits;
|
||||
|
@ -122,8 +116,8 @@ public class Job implements ToXContentObject {
|
|||
private final String modelSnapshotId;
|
||||
private final String resultsIndexName;
|
||||
|
||||
private Job(String jobId, String jobType, List<String> groups, String description, Date createTime,
|
||||
Date finishedTime, Date lastDataTime, Long establishedModelMemory,
|
||||
private Job(String jobId, String jobType, List<String> groups, String description,
|
||||
Date createTime, Date finishedTime, Long establishedModelMemory,
|
||||
AnalysisConfig analysisConfig, AnalysisLimits analysisLimits, DataDescription dataDescription,
|
||||
ModelPlotConfig modelPlotConfig, Long renormalizationWindowDays, TimeValue backgroundPersistInterval,
|
||||
Long modelSnapshotRetentionDays, Long resultsRetentionDays, Map<String, Object> customSettings,
|
||||
|
@ -135,7 +129,6 @@ public class Job implements ToXContentObject {
|
|||
this.description = description;
|
||||
this.createTime = createTime;
|
||||
this.finishedTime = finishedTime;
|
||||
this.lastDataTime = lastDataTime;
|
||||
this.establishedModelMemory = establishedModelMemory;
|
||||
this.analysisConfig = analysisConfig;
|
||||
this.analysisLimits = analysisLimits;
|
||||
|
@ -205,16 +198,6 @@ public class Job implements ToXContentObject {
|
|||
return finishedTime;
|
||||
}
|
||||
|
||||
/**
|
||||
* The last time data was uploaded to the job or <code>null</code> if no
|
||||
* data has been seen.
|
||||
*
|
||||
* @return The date at which the last data was processed
|
||||
*/
|
||||
public Date getLastDataTime() {
|
||||
return lastDataTime;
|
||||
}
|
||||
|
||||
/**
|
||||
* The established model memory of the job, or <code>null</code> if model
|
||||
* memory has not reached equilibrium yet.
|
||||
|
@ -313,10 +296,6 @@ public class Job implements ToXContentObject {
|
|||
builder.timeField(FINISHED_TIME.getPreferredName(), FINISHED_TIME.getPreferredName() + humanReadableSuffix,
|
||||
finishedTime.getTime());
|
||||
}
|
||||
if (lastDataTime != null) {
|
||||
builder.timeField(LAST_DATA_TIME.getPreferredName(), LAST_DATA_TIME.getPreferredName() + humanReadableSuffix,
|
||||
lastDataTime.getTime());
|
||||
}
|
||||
if (establishedModelMemory != null) {
|
||||
builder.field(ESTABLISHED_MODEL_MEMORY.getPreferredName(), establishedModelMemory);
|
||||
}
|
||||
|
@ -372,7 +351,6 @@ public class Job implements ToXContentObject {
|
|||
&& Objects.equals(this.description, that.description)
|
||||
&& Objects.equals(this.createTime, that.createTime)
|
||||
&& Objects.equals(this.finishedTime, that.finishedTime)
|
||||
&& Objects.equals(this.lastDataTime, that.lastDataTime)
|
||||
&& Objects.equals(this.establishedModelMemory, that.establishedModelMemory)
|
||||
&& Objects.equals(this.analysisConfig, that.analysisConfig)
|
||||
&& Objects.equals(this.analysisLimits, that.analysisLimits)
|
||||
|
@ -389,7 +367,7 @@ public class Job implements ToXContentObject {
|
|||
|
||||
@Override
|
||||
public int hashCode() {
|
||||
return Objects.hash(jobId, jobType, groups, description, createTime, finishedTime, lastDataTime, establishedModelMemory,
|
||||
return Objects.hash(jobId, jobType, groups, description, createTime, finishedTime, establishedModelMemory,
|
||||
analysisConfig, analysisLimits, dataDescription, modelPlotConfig, renormalizationWindowDays,
|
||||
backgroundPersistInterval, modelSnapshotRetentionDays, resultsRetentionDays, customSettings,
|
||||
modelSnapshotId, resultsIndexName);
|
||||
|
@ -415,7 +393,6 @@ public class Job implements ToXContentObject {
|
|||
private DataDescription dataDescription;
|
||||
private Date createTime;
|
||||
private Date finishedTime;
|
||||
private Date lastDataTime;
|
||||
private Long establishedModelMemory;
|
||||
private ModelPlotConfig modelPlotConfig;
|
||||
private Long renormalizationWindowDays;
|
||||
|
@ -443,7 +420,6 @@ public class Job implements ToXContentObject {
|
|||
this.dataDescription = job.getDataDescription();
|
||||
this.createTime = job.getCreateTime();
|
||||
this.finishedTime = job.getFinishedTime();
|
||||
this.lastDataTime = job.getLastDataTime();
|
||||
this.establishedModelMemory = job.getEstablishedModelMemory();
|
||||
this.modelPlotConfig = job.getModelPlotConfig();
|
||||
this.renormalizationWindowDays = job.getRenormalizationWindowDays();
|
||||
|
@ -504,16 +480,6 @@ public class Job implements ToXContentObject {
|
|||
return this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set the wall clock time of the last data upload
|
||||
*
|
||||
* @param lastDataTime Wall clock time
|
||||
*/
|
||||
public Builder setLastDataTime(Date lastDataTime) {
|
||||
this.lastDataTime = lastDataTime;
|
||||
return this;
|
||||
}
|
||||
|
||||
public Builder setEstablishedModelMemory(Long establishedModelMemory) {
|
||||
this.establishedModelMemory = establishedModelMemory;
|
||||
return this;
|
||||
|
@ -568,7 +534,7 @@ public class Job implements ToXContentObject {
|
|||
Objects.requireNonNull(id, "[" + ID.getPreferredName() + "] must not be null");
|
||||
Objects.requireNonNull(jobType, "[" + JOB_TYPE.getPreferredName() + "] must not be null");
|
||||
return new Job(
|
||||
id, jobType, groups, description, createTime, finishedTime, lastDataTime, establishedModelMemory,
|
||||
id, jobType, groups, description, createTime, finishedTime, establishedModelMemory,
|
||||
analysisConfig, analysisLimits, dataDescription, modelPlotConfig, renormalizationWindowDays,
|
||||
backgroundPersistInterval, modelSnapshotRetentionDays, resultsRetentionDays, customSettings,
|
||||
modelSnapshotId, resultsIndexName);
|
||||
|
|
|
@ -228,9 +228,6 @@ public class JobTests extends AbstractXContentTestCase<Job> {
|
|||
if (randomBoolean()) {
|
||||
builder.setFinishedTime(new Date(randomNonNegativeLong()));
|
||||
}
|
||||
if (randomBoolean()) {
|
||||
builder.setLastDataTime(new Date(randomNonNegativeLong()));
|
||||
}
|
||||
if (randomBoolean()) {
|
||||
builder.setEstablishedModelMemory(randomNonNegativeLong());
|
||||
}
|
||||
|
|
|
@ -20,7 +20,6 @@ import org.elasticsearch.common.xcontent.ObjectParser;
|
|||
import org.elasticsearch.common.xcontent.ObjectParser.ValueType;
|
||||
import org.elasticsearch.common.xcontent.ToXContentObject;
|
||||
import org.elasticsearch.common.xcontent.XContentBuilder;
|
||||
import org.elasticsearch.common.xcontent.XContentParser.Token;
|
||||
import org.elasticsearch.xpack.core.ml.job.messages.Messages;
|
||||
import org.elasticsearch.xpack.core.ml.job.persistence.AnomalyDetectorsIndexFields;
|
||||
import org.elasticsearch.xpack.core.ml.job.process.autodetect.state.DataCounts;
|
||||
|
@ -67,7 +66,6 @@ public class Job extends AbstractDiffable<Job> implements Writeable, ToXContentO
|
|||
public static final ParseField DATA_DESCRIPTION = new ParseField("data_description");
|
||||
public static final ParseField DESCRIPTION = new ParseField("description");
|
||||
public static final ParseField FINISHED_TIME = new ParseField("finished_time");
|
||||
public static final ParseField LAST_DATA_TIME = new ParseField("last_data_time");
|
||||
public static final ParseField ESTABLISHED_MODEL_MEMORY = new ParseField("established_model_memory");
|
||||
public static final ParseField MODEL_PLOT_CONFIG = new ParseField("model_plot_config");
|
||||
public static final ParseField RENORMALIZATION_WINDOW_DAYS = new ParseField("renormalization_window_days");
|
||||
|
@ -99,33 +97,10 @@ public class Job extends AbstractDiffable<Job> implements Writeable, ToXContentO
|
|||
parser.declareString(Builder::setJobVersion, JOB_VERSION);
|
||||
parser.declareStringArray(Builder::setGroups, GROUPS);
|
||||
parser.declareStringOrNull(Builder::setDescription, DESCRIPTION);
|
||||
parser.declareField(Builder::setCreateTime, p -> {
|
||||
if (p.currentToken() == Token.VALUE_NUMBER) {
|
||||
return new Date(p.longValue());
|
||||
} else if (p.currentToken() == Token.VALUE_STRING) {
|
||||
return new Date(TimeUtils.dateStringToEpoch(p.text()));
|
||||
}
|
||||
throw new IllegalArgumentException("unexpected token [" + p.currentToken() +
|
||||
"] for [" + CREATE_TIME.getPreferredName() + "]");
|
||||
}, CREATE_TIME, ValueType.VALUE);
|
||||
parser.declareField(Builder::setFinishedTime, p -> {
|
||||
if (p.currentToken() == Token.VALUE_NUMBER) {
|
||||
return new Date(p.longValue());
|
||||
} else if (p.currentToken() == Token.VALUE_STRING) {
|
||||
return new Date(TimeUtils.dateStringToEpoch(p.text()));
|
||||
}
|
||||
throw new IllegalArgumentException(
|
||||
"unexpected token [" + p.currentToken() + "] for [" + FINISHED_TIME.getPreferredName() + "]");
|
||||
}, FINISHED_TIME, ValueType.VALUE);
|
||||
parser.declareField(Builder::setLastDataTime, p -> {
|
||||
if (p.currentToken() == Token.VALUE_NUMBER) {
|
||||
return new Date(p.longValue());
|
||||
} else if (p.currentToken() == Token.VALUE_STRING) {
|
||||
return new Date(TimeUtils.dateStringToEpoch(p.text()));
|
||||
}
|
||||
throw new IllegalArgumentException(
|
||||
"unexpected token [" + p.currentToken() + "] for [" + LAST_DATA_TIME.getPreferredName() + "]");
|
||||
}, LAST_DATA_TIME, ValueType.VALUE);
|
||||
parser.declareField(Builder::setCreateTime,
|
||||
p -> TimeUtils.parseTimeField(p, CREATE_TIME.getPreferredName()), CREATE_TIME, ValueType.VALUE);
|
||||
parser.declareField(Builder::setFinishedTime,
|
||||
p -> TimeUtils.parseTimeField(p, FINISHED_TIME.getPreferredName()), FINISHED_TIME, ValueType.VALUE);
|
||||
parser.declareLong(Builder::setEstablishedModelMemory, ESTABLISHED_MODEL_MEMORY);
|
||||
parser.declareObject(Builder::setAnalysisConfig, ignoreUnknownFields ? AnalysisConfig.LENIENT_PARSER : AnalysisConfig.STRICT_PARSER,
|
||||
ANALYSIS_CONFIG);
|
||||
|
@ -164,7 +139,6 @@ public class Job extends AbstractDiffable<Job> implements Writeable, ToXContentO
|
|||
// TODO: Use java.time for the Dates here: x-pack-elasticsearch#829
|
||||
private final Date createTime;
|
||||
private final Date finishedTime;
|
||||
private final Date lastDataTime;
|
||||
private final Long establishedModelMemory;
|
||||
private final AnalysisConfig analysisConfig;
|
||||
private final AnalysisLimits analysisLimits;
|
||||
|
@ -180,8 +154,8 @@ public class Job extends AbstractDiffable<Job> implements Writeable, ToXContentO
|
|||
private final String resultsIndexName;
|
||||
private final boolean deleted;
|
||||
|
||||
private Job(String jobId, String jobType, Version jobVersion, List<String> groups, String description, Date createTime,
|
||||
Date finishedTime, Date lastDataTime, Long establishedModelMemory,
|
||||
private Job(String jobId, String jobType, Version jobVersion, List<String> groups, String description,
|
||||
Date createTime, Date finishedTime, Long establishedModelMemory,
|
||||
AnalysisConfig analysisConfig, AnalysisLimits analysisLimits, DataDescription dataDescription,
|
||||
ModelPlotConfig modelPlotConfig, Long renormalizationWindowDays, TimeValue backgroundPersistInterval,
|
||||
Long modelSnapshotRetentionDays, Long resultsRetentionDays, Map<String, Object> customSettings,
|
||||
|
@ -194,7 +168,6 @@ public class Job extends AbstractDiffable<Job> implements Writeable, ToXContentO
|
|||
this.description = description;
|
||||
this.createTime = createTime;
|
||||
this.finishedTime = finishedTime;
|
||||
this.lastDataTime = lastDataTime;
|
||||
this.establishedModelMemory = establishedModelMemory;
|
||||
this.analysisConfig = analysisConfig;
|
||||
this.analysisLimits = analysisLimits;
|
||||
|
@ -223,7 +196,12 @@ public class Job extends AbstractDiffable<Job> implements Writeable, ToXContentO
|
|||
description = in.readOptionalString();
|
||||
createTime = new Date(in.readVLong());
|
||||
finishedTime = in.readBoolean() ? new Date(in.readVLong()) : null;
|
||||
lastDataTime = in.readBoolean() ? new Date(in.readVLong()) : null;
|
||||
// for removed last_data_time field
|
||||
if (in.getVersion().before(Version.V_7_0_0_alpha1)) {
|
||||
if (in.readBoolean()) {
|
||||
in.readVLong();
|
||||
}
|
||||
}
|
||||
if (in.getVersion().onOrAfter(Version.V_6_1_0)) {
|
||||
establishedModelMemory = in.readOptionalLong();
|
||||
} else {
|
||||
|
@ -316,16 +294,6 @@ public class Job extends AbstractDiffable<Job> implements Writeable, ToXContentO
|
|||
return finishedTime;
|
||||
}
|
||||
|
||||
/**
|
||||
* The last time data was uploaded to the job or <code>null</code> if no
|
||||
* data has been seen.
|
||||
*
|
||||
* @return The date at which the last data was processed
|
||||
*/
|
||||
public Date getLastDataTime() {
|
||||
return lastDataTime;
|
||||
}
|
||||
|
||||
/**
|
||||
* The established model memory of the job, or <code>null</code> if model
|
||||
* memory has not reached equilibrium yet.
|
||||
|
@ -495,10 +463,8 @@ public class Job extends AbstractDiffable<Job> implements Writeable, ToXContentO
|
|||
} else {
|
||||
out.writeBoolean(false);
|
||||
}
|
||||
if (lastDataTime != null) {
|
||||
out.writeBoolean(true);
|
||||
out.writeVLong(lastDataTime.getTime());
|
||||
} else {
|
||||
// for removed last_data_time field
|
||||
if (out.getVersion().before(Version.V_7_0_0_alpha1)) {
|
||||
out.writeBoolean(false);
|
||||
}
|
||||
if (out.getVersion().onOrAfter(Version.V_6_1_0)) {
|
||||
|
@ -553,10 +519,6 @@ public class Job extends AbstractDiffable<Job> implements Writeable, ToXContentO
|
|||
builder.timeField(FINISHED_TIME.getPreferredName(), FINISHED_TIME.getPreferredName() + humanReadableSuffix,
|
||||
finishedTime.getTime());
|
||||
}
|
||||
if (lastDataTime != null) {
|
||||
builder.timeField(LAST_DATA_TIME.getPreferredName(), LAST_DATA_TIME.getPreferredName() + humanReadableSuffix,
|
||||
lastDataTime.getTime());
|
||||
}
|
||||
if (establishedModelMemory != null) {
|
||||
builder.field(ESTABLISHED_MODEL_MEMORY.getPreferredName(), establishedModelMemory);
|
||||
}
|
||||
|
@ -616,7 +578,6 @@ public class Job extends AbstractDiffable<Job> implements Writeable, ToXContentO
|
|||
&& Objects.equals(this.description, that.description)
|
||||
&& Objects.equals(this.createTime, that.createTime)
|
||||
&& Objects.equals(this.finishedTime, that.finishedTime)
|
||||
&& Objects.equals(this.lastDataTime, that.lastDataTime)
|
||||
&& Objects.equals(this.establishedModelMemory, that.establishedModelMemory)
|
||||
&& Objects.equals(this.analysisConfig, that.analysisConfig)
|
||||
&& Objects.equals(this.analysisLimits, that.analysisLimits)
|
||||
|
@ -635,7 +596,7 @@ public class Job extends AbstractDiffable<Job> implements Writeable, ToXContentO
|
|||
|
||||
@Override
|
||||
public int hashCode() {
|
||||
return Objects.hash(jobId, jobType, jobVersion, groups, description, createTime, finishedTime, lastDataTime, establishedModelMemory,
|
||||
return Objects.hash(jobId, jobType, jobVersion, groups, description, createTime, finishedTime, establishedModelMemory,
|
||||
analysisConfig, analysisLimits, dataDescription, modelPlotConfig, renormalizationWindowDays,
|
||||
backgroundPersistInterval, modelSnapshotRetentionDays, resultsRetentionDays, customSettings,
|
||||
modelSnapshotId, modelSnapshotMinVersion, resultsIndexName, deleted);
|
||||
|
@ -676,7 +637,6 @@ public class Job extends AbstractDiffable<Job> implements Writeable, ToXContentO
|
|||
private DataDescription dataDescription;
|
||||
private Date createTime;
|
||||
private Date finishedTime;
|
||||
private Date lastDataTime;
|
||||
private Long establishedModelMemory;
|
||||
private ModelPlotConfig modelPlotConfig;
|
||||
private Long renormalizationWindowDays;
|
||||
|
@ -707,7 +667,6 @@ public class Job extends AbstractDiffable<Job> implements Writeable, ToXContentO
|
|||
this.dataDescription = job.getDataDescription();
|
||||
this.createTime = job.getCreateTime();
|
||||
this.finishedTime = job.getFinishedTime();
|
||||
this.lastDataTime = job.getLastDataTime();
|
||||
this.establishedModelMemory = job.getEstablishedModelMemory();
|
||||
this.modelPlotConfig = job.getModelPlotConfig();
|
||||
this.renormalizationWindowDays = job.getRenormalizationWindowDays();
|
||||
|
@ -733,7 +692,12 @@ public class Job extends AbstractDiffable<Job> implements Writeable, ToXContentO
|
|||
description = in.readOptionalString();
|
||||
createTime = in.readBoolean() ? new Date(in.readVLong()) : null;
|
||||
finishedTime = in.readBoolean() ? new Date(in.readVLong()) : null;
|
||||
lastDataTime = in.readBoolean() ? new Date(in.readVLong()) : null;
|
||||
// for removed last_data_time field
|
||||
if (in.getVersion().before(Version.V_7_0_0_alpha1)) {
|
||||
if (in.readBoolean()) {
|
||||
in.readVLong();
|
||||
}
|
||||
}
|
||||
if (in.getVersion().onOrAfter(Version.V_6_1_0)) {
|
||||
establishedModelMemory = in.readOptionalLong();
|
||||
}
|
||||
|
@ -815,15 +779,6 @@ public class Job extends AbstractDiffable<Job> implements Writeable, ToXContentO
|
|||
return this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set the wall clock time of the last data upload
|
||||
* @param lastDataTime Wall clock time
|
||||
*/
|
||||
public Builder setLastDataTime(Date lastDataTime) {
|
||||
this.lastDataTime = lastDataTime;
|
||||
return this;
|
||||
}
|
||||
|
||||
public Builder setEstablishedModelMemory(Long establishedModelMemory) {
|
||||
this.establishedModelMemory = establishedModelMemory;
|
||||
return this;
|
||||
|
@ -895,9 +850,6 @@ public class Job extends AbstractDiffable<Job> implements Writeable, ToXContentO
|
|||
if (modelSnapshotId != null) {
|
||||
invalidCreateValues.add(MODEL_SNAPSHOT_ID.getPreferredName());
|
||||
}
|
||||
if (lastDataTime != null) {
|
||||
invalidCreateValues.add(LAST_DATA_TIME.getPreferredName());
|
||||
}
|
||||
if (finishedTime != null) {
|
||||
invalidCreateValues.add(FINISHED_TIME.getPreferredName());
|
||||
}
|
||||
|
@ -933,10 +885,8 @@ public class Job extends AbstractDiffable<Job> implements Writeable, ToXContentO
|
|||
} else {
|
||||
out.writeBoolean(false);
|
||||
}
|
||||
if (lastDataTime != null) {
|
||||
out.writeBoolean(true);
|
||||
out.writeVLong(lastDataTime.getTime());
|
||||
} else {
|
||||
// for removed last_data_time field
|
||||
if (out.getVersion().before(Version.V_7_0_0_alpha1)) {
|
||||
out.writeBoolean(false);
|
||||
}
|
||||
if (out.getVersion().onOrAfter(Version.V_6_1_0)) {
|
||||
|
@ -983,9 +933,6 @@ public class Job extends AbstractDiffable<Job> implements Writeable, ToXContentO
|
|||
if (finishedTime != null) {
|
||||
builder.field(FINISHED_TIME.getPreferredName(), finishedTime.getTime());
|
||||
}
|
||||
if (lastDataTime != null) {
|
||||
builder.field(LAST_DATA_TIME.getPreferredName(), lastDataTime.getTime());
|
||||
}
|
||||
if (establishedModelMemory != null) {
|
||||
builder.field(ESTABLISHED_MODEL_MEMORY.getPreferredName(), establishedModelMemory);
|
||||
}
|
||||
|
@ -1049,7 +996,6 @@ public class Job extends AbstractDiffable<Job> implements Writeable, ToXContentO
|
|||
&& Objects.equals(this.dataDescription, that.dataDescription)
|
||||
&& Objects.equals(this.createTime, that.createTime)
|
||||
&& Objects.equals(this.finishedTime, that.finishedTime)
|
||||
&& Objects.equals(this.lastDataTime, that.lastDataTime)
|
||||
&& Objects.equals(this.establishedModelMemory, that.establishedModelMemory)
|
||||
&& Objects.equals(this.modelPlotConfig, that.modelPlotConfig)
|
||||
&& Objects.equals(this.renormalizationWindowDays, that.renormalizationWindowDays)
|
||||
|
@ -1065,8 +1011,8 @@ public class Job extends AbstractDiffable<Job> implements Writeable, ToXContentO
|
|||
|
||||
@Override
|
||||
public int hashCode() {
|
||||
return Objects.hash(id, jobType, jobVersion, groups, description, analysisConfig, analysisLimits, dataDescription, createTime,
|
||||
finishedTime, lastDataTime, establishedModelMemory, modelPlotConfig, renormalizationWindowDays,
|
||||
return Objects.hash(id, jobType, jobVersion, groups, description, analysisConfig, analysisLimits, dataDescription,
|
||||
createTime, finishedTime, establishedModelMemory, modelPlotConfig, renormalizationWindowDays,
|
||||
backgroundPersistInterval, modelSnapshotRetentionDays, resultsRetentionDays, customSettings, modelSnapshotId,
|
||||
modelSnapshotMinVersion, resultsIndexName, deleted);
|
||||
}
|
||||
|
@ -1178,7 +1124,7 @@ public class Job extends AbstractDiffable<Job> implements Writeable, ToXContentO
|
|||
}
|
||||
|
||||
return new Job(
|
||||
id, jobType, jobVersion, groups, description, createTime, finishedTime, lastDataTime, establishedModelMemory,
|
||||
id, jobType, jobVersion, groups, description, createTime, finishedTime, establishedModelMemory,
|
||||
analysisConfig, analysisLimits, dataDescription, modelPlotConfig, renormalizationWindowDays,
|
||||
backgroundPersistInterval, modelSnapshotRetentionDays, resultsRetentionDays, customSettings,
|
||||
modelSnapshotId, modelSnapshotMinVersion, resultsIndexName, deleted);
|
||||
|
|
|
@ -13,7 +13,6 @@ 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 org.elasticsearch.xpack.core.ml.utils.time.TimeUtils;
|
||||
|
||||
import java.io.IOException;
|
||||
|
@ -36,15 +35,9 @@ public class FlushAcknowledgement implements ToXContentObject, Writeable {
|
|||
|
||||
static {
|
||||
PARSER.declareString(ConstructingObjectParser.constructorArg(), ID);
|
||||
PARSER.declareField(ConstructingObjectParser.optionalConstructorArg(), p -> {
|
||||
if (p.currentToken() == XContentParser.Token.VALUE_NUMBER) {
|
||||
return new Date(p.longValue());
|
||||
} else if (p.currentToken() == XContentParser.Token.VALUE_STRING) {
|
||||
return new Date(TimeUtils.dateStringToEpoch(p.text()));
|
||||
}
|
||||
throw new IllegalArgumentException(
|
||||
"unexpected token [" + p.currentToken() + "] for [" + LAST_FINALIZED_BUCKET_END.getPreferredName() + "]");
|
||||
}, LAST_FINALIZED_BUCKET_END, ObjectParser.ValueType.VALUE);
|
||||
PARSER.declareField(ConstructingObjectParser.optionalConstructorArg(),
|
||||
p -> TimeUtils.parseTimeField(p, LAST_FINALIZED_BUCKET_END.getPreferredName()),
|
||||
LAST_FINALIZED_BUCKET_END, ObjectParser.ValueType.VALUE);
|
||||
}
|
||||
|
||||
private String id;
|
||||
|
|
|
@ -13,7 +13,6 @@ import org.elasticsearch.common.xcontent.ConstructingObjectParser;
|
|||
import org.elasticsearch.common.xcontent.ObjectParser.ValueType;
|
||||
import org.elasticsearch.common.xcontent.ToXContentObject;
|
||||
import org.elasticsearch.common.xcontent.XContentBuilder;
|
||||
import org.elasticsearch.common.xcontent.XContentParser.Token;
|
||||
import org.elasticsearch.xpack.core.ml.job.config.Job;
|
||||
import org.elasticsearch.xpack.core.ml.utils.time.TimeUtils;
|
||||
|
||||
|
@ -90,51 +89,16 @@ public class DataCounts implements ToXContentObject, Writeable {
|
|||
PARSER.declareLong(ConstructingObjectParser.constructorArg(), EMPTY_BUCKET_COUNT);
|
||||
PARSER.declareLong(ConstructingObjectParser.constructorArg(), SPARSE_BUCKET_COUNT);
|
||||
PARSER.declareLong(ConstructingObjectParser.constructorArg(), BUCKET_COUNT);
|
||||
PARSER.declareField(ConstructingObjectParser.optionalConstructorArg(), p -> {
|
||||
if (p.currentToken() == Token.VALUE_NUMBER) {
|
||||
return new Date(p.longValue());
|
||||
} else if (p.currentToken() == Token.VALUE_STRING) {
|
||||
return new Date(TimeUtils.dateStringToEpoch(p.text()));
|
||||
}
|
||||
throw new IllegalArgumentException(
|
||||
"unexpected token [" + p.currentToken() + "] for [" + EARLIEST_RECORD_TIME.getPreferredName() + "]");
|
||||
}, EARLIEST_RECORD_TIME, ValueType.VALUE);
|
||||
PARSER.declareField(ConstructingObjectParser.optionalConstructorArg(), p -> {
|
||||
if (p.currentToken() == Token.VALUE_NUMBER) {
|
||||
return new Date(p.longValue());
|
||||
} else if (p.currentToken() == Token.VALUE_STRING) {
|
||||
return new Date(TimeUtils.dateStringToEpoch(p.text()));
|
||||
}
|
||||
throw new IllegalArgumentException(
|
||||
"unexpected token [" + p.currentToken() + "] for [" + LATEST_RECORD_TIME.getPreferredName() + "]");
|
||||
}, LATEST_RECORD_TIME, ValueType.VALUE);
|
||||
PARSER.declareField(ConstructingObjectParser.optionalConstructorArg(), p -> {
|
||||
if (p.currentToken() == Token.VALUE_NUMBER) {
|
||||
return new Date(p.longValue());
|
||||
} else if (p.currentToken() == Token.VALUE_STRING) {
|
||||
return new Date(TimeUtils.dateStringToEpoch(p.text()));
|
||||
}
|
||||
throw new IllegalArgumentException(
|
||||
"unexpected token [" + p.currentToken() + "] for [" + LAST_DATA_TIME.getPreferredName() + "]");
|
||||
}, LAST_DATA_TIME, ValueType.VALUE);
|
||||
PARSER.declareField(ConstructingObjectParser.optionalConstructorArg(), p -> {
|
||||
if (p.currentToken() == Token.VALUE_NUMBER) {
|
||||
return new Date(p.longValue());
|
||||
} else if (p.currentToken() == Token.VALUE_STRING) {
|
||||
return new Date(TimeUtils.dateStringToEpoch(p.text()));
|
||||
}
|
||||
throw new IllegalArgumentException(
|
||||
"unexpected token [" + p.currentToken() + "] for [" + LATEST_EMPTY_BUCKET_TIME.getPreferredName() + "]");
|
||||
}, LATEST_EMPTY_BUCKET_TIME, ValueType.VALUE);
|
||||
PARSER.declareField(ConstructingObjectParser.optionalConstructorArg(), p -> {
|
||||
if (p.currentToken() == Token.VALUE_NUMBER) {
|
||||
return new Date(p.longValue());
|
||||
} else if (p.currentToken() == Token.VALUE_STRING) {
|
||||
return new Date(TimeUtils.dateStringToEpoch(p.text()));
|
||||
}
|
||||
throw new IllegalArgumentException(
|
||||
"unexpected token [" + p.currentToken() + "] for [" + LATEST_SPARSE_BUCKET_TIME.getPreferredName() + "]");
|
||||
}, LATEST_SPARSE_BUCKET_TIME, ValueType.VALUE);
|
||||
PARSER.declareField(ConstructingObjectParser.optionalConstructorArg(),
|
||||
p -> TimeUtils.parseTimeField(p, EARLIEST_RECORD_TIME.getPreferredName()), EARLIEST_RECORD_TIME, ValueType.VALUE);
|
||||
PARSER.declareField(ConstructingObjectParser.optionalConstructorArg(),
|
||||
p -> TimeUtils.parseTimeField(p, LATEST_RECORD_TIME.getPreferredName()), LATEST_RECORD_TIME, ValueType.VALUE);
|
||||
PARSER.declareField(ConstructingObjectParser.optionalConstructorArg(),
|
||||
p -> TimeUtils.parseTimeField(p, LAST_DATA_TIME.getPreferredName()), LAST_DATA_TIME, ValueType.VALUE);
|
||||
PARSER.declareField(ConstructingObjectParser.optionalConstructorArg(),
|
||||
p -> TimeUtils.parseTimeField(p, LATEST_EMPTY_BUCKET_TIME.getPreferredName()), LATEST_EMPTY_BUCKET_TIME, ValueType.VALUE);
|
||||
PARSER.declareField(ConstructingObjectParser.optionalConstructorArg(),
|
||||
p -> TimeUtils.parseTimeField(p, LATEST_SPARSE_BUCKET_TIME.getPreferredName()), LATEST_SPARSE_BUCKET_TIME, ValueType.VALUE);
|
||||
PARSER.declareLong((t, u) -> {;}, INPUT_RECORD_COUNT);
|
||||
}
|
||||
|
||||
|
|
|
@ -13,7 +13,6 @@ import org.elasticsearch.common.xcontent.ConstructingObjectParser;
|
|||
import org.elasticsearch.common.xcontent.ObjectParser.ValueType;
|
||||
import org.elasticsearch.common.xcontent.ToXContentObject;
|
||||
import org.elasticsearch.common.xcontent.XContentBuilder;
|
||||
import org.elasticsearch.common.xcontent.XContentParser.Token;
|
||||
import org.elasticsearch.xpack.core.ml.job.config.Job;
|
||||
import org.elasticsearch.xpack.core.ml.job.results.Result;
|
||||
import org.elasticsearch.xpack.core.ml.utils.time.TimeUtils;
|
||||
|
@ -22,6 +21,7 @@ import java.io.IOException;
|
|||
import java.util.Date;
|
||||
import java.util.Locale;
|
||||
import java.util.Objects;
|
||||
import java.util.function.BiConsumer;
|
||||
|
||||
/**
|
||||
* Provide access to the C++ model memory usage numbers for the Java process.
|
||||
|
@ -60,25 +60,12 @@ public class ModelSizeStats implements ToXContentObject, Writeable {
|
|||
parser.declareLong(Builder::setTotalByFieldCount, TOTAL_BY_FIELD_COUNT_FIELD);
|
||||
parser.declareLong(Builder::setTotalOverFieldCount, TOTAL_OVER_FIELD_COUNT_FIELD);
|
||||
parser.declareLong(Builder::setTotalPartitionFieldCount, TOTAL_PARTITION_FIELD_COUNT_FIELD);
|
||||
parser.declareField(Builder::setLogTime, p -> {
|
||||
if (p.currentToken() == Token.VALUE_NUMBER) {
|
||||
return new Date(p.longValue());
|
||||
} else if (p.currentToken() == Token.VALUE_STRING) {
|
||||
return new Date(TimeUtils.dateStringToEpoch(p.text()));
|
||||
}
|
||||
throw new IllegalArgumentException(
|
||||
"unexpected token [" + p.currentToken() + "] for [" + LOG_TIME_FIELD.getPreferredName() + "]");
|
||||
}, LOG_TIME_FIELD, ValueType.VALUE);
|
||||
parser.declareField(Builder::setTimestamp, p -> {
|
||||
if (p.currentToken() == Token.VALUE_NUMBER) {
|
||||
return new Date(p.longValue());
|
||||
} else if (p.currentToken() == Token.VALUE_STRING) {
|
||||
return new Date(TimeUtils.dateStringToEpoch(p.text()));
|
||||
}
|
||||
throw new IllegalArgumentException(
|
||||
"unexpected token [" + p.currentToken() + "] for [" + TIMESTAMP_FIELD.getPreferredName() + "]");
|
||||
}, TIMESTAMP_FIELD, ValueType.VALUE);
|
||||
parser.declareField(Builder::setMemoryStatus, p -> MemoryStatus.fromString(p.text()), MEMORY_STATUS_FIELD, ValueType.STRING);
|
||||
parser.declareField(Builder::setLogTime,
|
||||
p -> TimeUtils.parseTimeField(p, LOG_TIME_FIELD.getPreferredName()), LOG_TIME_FIELD, ValueType.VALUE);
|
||||
parser.declareField(Builder::setTimestamp,
|
||||
p -> TimeUtils.parseTimeField(p, TIMESTAMP_FIELD.getPreferredName()), TIMESTAMP_FIELD, ValueType.VALUE);
|
||||
BiConsumer<Builder, MemoryStatus> setMemoryStatus = Builder::setMemoryStatus;
|
||||
parser.declareField(setMemoryStatus, p -> MemoryStatus.fromString(p.text()), MEMORY_STATUS_FIELD, ValueType.STRING);
|
||||
|
||||
return parser;
|
||||
}
|
||||
|
|
|
@ -20,7 +20,6 @@ import org.elasticsearch.common.xcontent.ToXContentObject;
|
|||
import org.elasticsearch.common.xcontent.XContentBuilder;
|
||||
import org.elasticsearch.common.xcontent.XContentFactory;
|
||||
import org.elasticsearch.common.xcontent.XContentParser;
|
||||
import org.elasticsearch.common.xcontent.XContentParser.Token;
|
||||
import org.elasticsearch.common.xcontent.XContentType;
|
||||
import org.elasticsearch.xpack.core.ml.job.config.Job;
|
||||
import org.elasticsearch.xpack.core.ml.utils.time.TimeUtils;
|
||||
|
@ -64,38 +63,17 @@ public class ModelSnapshot implements ToXContentObject, Writeable {
|
|||
|
||||
parser.declareString(Builder::setJobId, Job.ID);
|
||||
parser.declareString(Builder::setMinVersion, MIN_VERSION);
|
||||
parser.declareField(Builder::setTimestamp, p -> {
|
||||
if (p.currentToken() == Token.VALUE_NUMBER) {
|
||||
return new Date(p.longValue());
|
||||
} else if (p.currentToken() == Token.VALUE_STRING) {
|
||||
return new Date(TimeUtils.dateStringToEpoch(p.text()));
|
||||
}
|
||||
throw new IllegalArgumentException("unexpected token [" + p.currentToken() + "] for ["
|
||||
+ TIMESTAMP.getPreferredName() + "]");
|
||||
}, TIMESTAMP, ValueType.VALUE);
|
||||
parser.declareField(Builder::setTimestamp,
|
||||
p -> TimeUtils.parseTimeField(p, TIMESTAMP.getPreferredName()), TIMESTAMP, ValueType.VALUE);
|
||||
parser.declareString(Builder::setDescription, DESCRIPTION);
|
||||
parser.declareString(Builder::setSnapshotId, ModelSnapshotField.SNAPSHOT_ID);
|
||||
parser.declareInt(Builder::setSnapshotDocCount, SNAPSHOT_DOC_COUNT);
|
||||
parser.declareObject(Builder::setModelSizeStats, ignoreUnknownFields ? ModelSizeStats.LENIENT_PARSER : ModelSizeStats.STRICT_PARSER,
|
||||
ModelSizeStats.RESULT_TYPE_FIELD);
|
||||
parser.declareField(Builder::setLatestRecordTimeStamp, p -> {
|
||||
if (p.currentToken() == Token.VALUE_NUMBER) {
|
||||
return new Date(p.longValue());
|
||||
} else if (p.currentToken() == Token.VALUE_STRING) {
|
||||
return new Date(TimeUtils.dateStringToEpoch(p.text()));
|
||||
}
|
||||
throw new IllegalArgumentException(
|
||||
"unexpected token [" + p.currentToken() + "] for [" + LATEST_RECORD_TIME.getPreferredName() + "]");
|
||||
}, LATEST_RECORD_TIME, ValueType.VALUE);
|
||||
parser.declareField(Builder::setLatestResultTimeStamp, p -> {
|
||||
if (p.currentToken() == Token.VALUE_NUMBER) {
|
||||
return new Date(p.longValue());
|
||||
} else if (p.currentToken() == Token.VALUE_STRING) {
|
||||
return new Date(TimeUtils.dateStringToEpoch(p.text()));
|
||||
}
|
||||
throw new IllegalArgumentException(
|
||||
"unexpected token [" + p.currentToken() + "] for [" + LATEST_RESULT_TIME.getPreferredName() + "]");
|
||||
}, LATEST_RESULT_TIME, ValueType.VALUE);
|
||||
parser.declareField(Builder::setLatestRecordTimeStamp,
|
||||
p -> TimeUtils.parseTimeField(p, LATEST_RECORD_TIME.getPreferredName()), LATEST_RECORD_TIME, ValueType.VALUE);
|
||||
parser.declareField(Builder::setLatestResultTimeStamp,
|
||||
p -> TimeUtils.parseTimeField(p, LATEST_RESULT_TIME.getPreferredName()), LATEST_RESULT_TIME, ValueType.VALUE);
|
||||
parser.declareObject(Builder::setQuantiles, ignoreUnknownFields ? Quantiles.LENIENT_PARSER : Quantiles.STRICT_PARSER, QUANTILES);
|
||||
parser.declareBoolean(Builder::setRetain, RETAIN);
|
||||
|
||||
|
|
|
@ -14,7 +14,6 @@ import org.elasticsearch.common.xcontent.ConstructingObjectParser;
|
|||
import org.elasticsearch.common.xcontent.ObjectParser.ValueType;
|
||||
import org.elasticsearch.common.xcontent.ToXContentObject;
|
||||
import org.elasticsearch.common.xcontent.XContentBuilder;
|
||||
import org.elasticsearch.common.xcontent.XContentParser.Token;
|
||||
import org.elasticsearch.xpack.core.ml.job.config.Detector;
|
||||
import org.elasticsearch.xpack.core.ml.job.config.Job;
|
||||
import org.elasticsearch.xpack.core.ml.utils.ExceptionsHelper;
|
||||
|
@ -90,15 +89,8 @@ public class AnomalyRecord implements ToXContentObject, Writeable {
|
|||
a -> new AnomalyRecord((String) a[0], (Date) a[1], (long) a[2]));
|
||||
|
||||
parser.declareString(ConstructingObjectParser.constructorArg(), Job.ID);
|
||||
parser.declareField(ConstructingObjectParser.constructorArg(), p -> {
|
||||
if (p.currentToken() == Token.VALUE_NUMBER) {
|
||||
return new Date(p.longValue());
|
||||
} else if (p.currentToken() == Token.VALUE_STRING) {
|
||||
return new Date(TimeUtils.dateStringToEpoch(p.text()));
|
||||
}
|
||||
throw new IllegalArgumentException("unexpected token [" + p.currentToken() + "] for ["
|
||||
+ Result.TIMESTAMP.getPreferredName() + "]");
|
||||
}, Result.TIMESTAMP, ValueType.VALUE);
|
||||
parser.declareField(ConstructingObjectParser.constructorArg(),
|
||||
p -> TimeUtils.parseTimeField(p, Result.TIMESTAMP.getPreferredName()), Result.TIMESTAMP, ValueType.VALUE);
|
||||
parser.declareLong(ConstructingObjectParser.constructorArg(), BUCKET_SPAN);
|
||||
parser.declareString((anomalyRecord, s) -> {}, Result.RESULT_TYPE);
|
||||
parser.declareDouble(AnomalyRecord::setProbability, PROBABILITY);
|
||||
|
|
|
@ -14,7 +14,6 @@ import org.elasticsearch.common.xcontent.ConstructingObjectParser;
|
|||
import org.elasticsearch.common.xcontent.ObjectParser.ValueType;
|
||||
import org.elasticsearch.common.xcontent.ToXContentObject;
|
||||
import org.elasticsearch.common.xcontent.XContentBuilder;
|
||||
import org.elasticsearch.common.xcontent.XContentParser.Token;
|
||||
import org.elasticsearch.xpack.core.ml.job.config.Job;
|
||||
import org.elasticsearch.xpack.core.ml.utils.ExceptionsHelper;
|
||||
import org.elasticsearch.xpack.core.ml.utils.time.TimeUtils;
|
||||
|
@ -74,15 +73,8 @@ public class Bucket implements ToXContentObject, Writeable {
|
|||
a -> new Bucket((String) a[0], (Date) a[1], (long) a[2]));
|
||||
|
||||
parser.declareString(ConstructingObjectParser.constructorArg(), JOB_ID);
|
||||
parser.declareField(ConstructingObjectParser.constructorArg(), p -> {
|
||||
if (p.currentToken() == Token.VALUE_NUMBER) {
|
||||
return new Date(p.longValue());
|
||||
} else if (p.currentToken() == Token.VALUE_STRING) {
|
||||
return new Date(TimeUtils.dateStringToEpoch(p.text()));
|
||||
}
|
||||
throw new IllegalArgumentException("unexpected token [" + p.currentToken() + "] for ["
|
||||
+ Result.TIMESTAMP.getPreferredName() + "]");
|
||||
}, Result.TIMESTAMP, ValueType.VALUE);
|
||||
parser.declareField(ConstructingObjectParser.constructorArg(),
|
||||
p -> TimeUtils.parseTimeField(p, Result.TIMESTAMP.getPreferredName()), Result.TIMESTAMP, ValueType.VALUE);
|
||||
parser.declareLong(ConstructingObjectParser.constructorArg(), BUCKET_SPAN);
|
||||
parser.declareDouble(Bucket::setAnomalyScore, ANOMALY_SCORE);
|
||||
parser.declareDouble(Bucket::setInitialAnomalyScore, INITIAL_ANOMALY_SCORE);
|
||||
|
|
|
@ -13,7 +13,6 @@ import org.elasticsearch.common.xcontent.ConstructingObjectParser;
|
|||
import org.elasticsearch.common.xcontent.ObjectParser.ValueType;
|
||||
import org.elasticsearch.common.xcontent.ToXContentObject;
|
||||
import org.elasticsearch.common.xcontent.XContentBuilder;
|
||||
import org.elasticsearch.common.xcontent.XContentParser.Token;
|
||||
import org.elasticsearch.xpack.core.ml.job.config.Job;
|
||||
import org.elasticsearch.xpack.core.ml.utils.ExceptionsHelper;
|
||||
import org.elasticsearch.xpack.core.ml.utils.time.TimeUtils;
|
||||
|
@ -52,15 +51,8 @@ public class BucketInfluencer implements ToXContentObject, Writeable {
|
|||
ignoreUnknownFields, a -> new BucketInfluencer((String) a[0], (Date) a[1], (long) a[2]));
|
||||
|
||||
parser.declareString(ConstructingObjectParser.constructorArg(), Job.ID);
|
||||
parser.declareField(ConstructingObjectParser.constructorArg(), p -> {
|
||||
if (p.currentToken() == Token.VALUE_NUMBER) {
|
||||
return new Date(p.longValue());
|
||||
} else if (p.currentToken() == Token.VALUE_STRING) {
|
||||
return new Date(TimeUtils.dateStringToEpoch(p.text()));
|
||||
}
|
||||
throw new IllegalArgumentException("unexpected token [" + p.currentToken() + "] for ["
|
||||
+ Result.TIMESTAMP.getPreferredName() + "]");
|
||||
}, Result.TIMESTAMP, ValueType.VALUE);
|
||||
parser.declareField(ConstructingObjectParser.constructorArg(),
|
||||
p -> TimeUtils.parseTimeField(p, Result.TIMESTAMP.getPreferredName()), Result.TIMESTAMP, ValueType.VALUE);
|
||||
parser.declareLong(ConstructingObjectParser.constructorArg(), BUCKET_SPAN);
|
||||
parser.declareString((bucketInfluencer, s) -> {}, Result.RESULT_TYPE);
|
||||
parser.declareString(BucketInfluencer::setInfluencerFieldName, INFLUENCER_FIELD_NAME);
|
||||
|
|
|
@ -13,7 +13,6 @@ import org.elasticsearch.common.xcontent.ConstructingObjectParser;
|
|||
import org.elasticsearch.common.xcontent.ObjectParser.ValueType;
|
||||
import org.elasticsearch.common.xcontent.ToXContentObject;
|
||||
import org.elasticsearch.common.xcontent.XContentBuilder;
|
||||
import org.elasticsearch.common.xcontent.XContentParser.Token;
|
||||
import org.elasticsearch.xpack.core.ml.job.config.Job;
|
||||
import org.elasticsearch.xpack.core.ml.utils.time.TimeUtils;
|
||||
|
||||
|
@ -51,15 +50,8 @@ public class Forecast implements ToXContentObject, Writeable {
|
|||
|
||||
parser.declareString(ConstructingObjectParser.constructorArg(), Job.ID);
|
||||
parser.declareString(ConstructingObjectParser.constructorArg(), FORECAST_ID);
|
||||
parser.declareField(ConstructingObjectParser.constructorArg(), p -> {
|
||||
if (p.currentToken() == Token.VALUE_NUMBER) {
|
||||
return new Date(p.longValue());
|
||||
} else if (p.currentToken() == Token.VALUE_STRING) {
|
||||
return new Date(TimeUtils.dateStringToEpoch(p.text()));
|
||||
}
|
||||
throw new IllegalArgumentException("unexpected token [" + p.currentToken() + "] for ["
|
||||
+ Result.TIMESTAMP.getPreferredName() + "]");
|
||||
}, Result.TIMESTAMP, ValueType.VALUE);
|
||||
parser.declareField(ConstructingObjectParser.constructorArg(),
|
||||
p -> TimeUtils.parseTimeField(p, Result.TIMESTAMP.getPreferredName()), Result.TIMESTAMP, ValueType.VALUE);
|
||||
parser.declareLong(ConstructingObjectParser.constructorArg(), BUCKET_SPAN);
|
||||
parser.declareInt(ConstructingObjectParser.constructorArg(), DETECTOR_INDEX);
|
||||
parser.declareString((modelForecast, s) -> {}, Result.RESULT_TYPE);
|
||||
|
|
|
@ -13,7 +13,6 @@ import org.elasticsearch.common.xcontent.ConstructingObjectParser;
|
|||
import org.elasticsearch.common.xcontent.ObjectParser.ValueType;
|
||||
import org.elasticsearch.common.xcontent.ToXContentObject;
|
||||
import org.elasticsearch.common.xcontent.XContentBuilder;
|
||||
import org.elasticsearch.common.xcontent.XContentParser.Token;
|
||||
import org.elasticsearch.xpack.core.ml.job.config.Job;
|
||||
import org.elasticsearch.xpack.core.ml.utils.ExceptionsHelper;
|
||||
import org.elasticsearch.xpack.core.ml.utils.time.TimeUtils;
|
||||
|
@ -51,15 +50,8 @@ public class Influencer implements ToXContentObject, Writeable {
|
|||
LENIENT_PARSER.declareString(ConstructingObjectParser.constructorArg(), Job.ID);
|
||||
LENIENT_PARSER.declareString(ConstructingObjectParser.constructorArg(), INFLUENCER_FIELD_NAME);
|
||||
LENIENT_PARSER.declareString(ConstructingObjectParser.constructorArg(), INFLUENCER_FIELD_VALUE);
|
||||
LENIENT_PARSER.declareField(ConstructingObjectParser.constructorArg(), p -> {
|
||||
if (p.currentToken() == Token.VALUE_NUMBER) {
|
||||
return new Date(p.longValue());
|
||||
} else if (p.currentToken() == Token.VALUE_STRING) {
|
||||
return new Date(TimeUtils.dateStringToEpoch(p.text()));
|
||||
}
|
||||
throw new IllegalArgumentException("unexpected token [" + p.currentToken() + "] for ["
|
||||
+ Result.TIMESTAMP.getPreferredName() + "]");
|
||||
}, Result.TIMESTAMP, ValueType.VALUE);
|
||||
LENIENT_PARSER.declareField(ConstructingObjectParser.constructorArg(),
|
||||
p -> TimeUtils.parseTimeField(p, Result.TIMESTAMP.getPreferredName()), Result.TIMESTAMP, ValueType.VALUE);
|
||||
LENIENT_PARSER.declareLong(ConstructingObjectParser.constructorArg(), BUCKET_SPAN);
|
||||
LENIENT_PARSER.declareString((influencer, s) -> {}, Result.RESULT_TYPE);
|
||||
LENIENT_PARSER.declareDouble(Influencer::setProbability, PROBABILITY);
|
||||
|
|
|
@ -14,7 +14,6 @@ import org.elasticsearch.common.xcontent.ConstructingObjectParser;
|
|||
import org.elasticsearch.common.xcontent.ObjectParser.ValueType;
|
||||
import org.elasticsearch.common.xcontent.ToXContentObject;
|
||||
import org.elasticsearch.common.xcontent.XContentBuilder;
|
||||
import org.elasticsearch.common.xcontent.XContentParser.Token;
|
||||
import org.elasticsearch.xpack.core.ml.job.config.Job;
|
||||
import org.elasticsearch.xpack.core.ml.utils.time.TimeUtils;
|
||||
|
||||
|
@ -54,15 +53,8 @@ public class ModelPlot implements ToXContentObject, Writeable {
|
|||
a -> new ModelPlot((String) a[0], (Date) a[1], (long) a[2], (int) a[3]));
|
||||
|
||||
parser.declareString(ConstructingObjectParser.constructorArg(), Job.ID);
|
||||
parser.declareField(ConstructingObjectParser.constructorArg(), p -> {
|
||||
if (p.currentToken() == Token.VALUE_NUMBER) {
|
||||
return new Date(p.longValue());
|
||||
} else if (p.currentToken() == Token.VALUE_STRING) {
|
||||
return new Date(TimeUtils.dateStringToEpoch(p.text()));
|
||||
}
|
||||
throw new IllegalArgumentException("unexpected token [" + p.currentToken() + "] for ["
|
||||
+ Result.TIMESTAMP.getPreferredName() + "]");
|
||||
}, Result.TIMESTAMP, ValueType.VALUE);
|
||||
parser.declareField(ConstructingObjectParser.constructorArg(),
|
||||
p -> TimeUtils.parseTimeField(p, Result.TIMESTAMP.getPreferredName()), Result.TIMESTAMP, ValueType.VALUE);
|
||||
parser.declareLong(ConstructingObjectParser.constructorArg(), BUCKET_SPAN);
|
||||
parser.declareInt(ConstructingObjectParser.constructorArg(), DETECTOR_INDEX);
|
||||
parser.declareString((modelPlot, s) -> {}, Result.RESULT_TYPE);
|
||||
|
|
|
@ -14,7 +14,6 @@ import org.elasticsearch.common.xcontent.ObjectParser.ValueType;
|
|||
import org.elasticsearch.common.xcontent.ToXContentObject;
|
||||
import org.elasticsearch.common.xcontent.XContentBuilder;
|
||||
import org.elasticsearch.common.xcontent.XContentParser;
|
||||
import org.elasticsearch.common.xcontent.XContentParser.Token;
|
||||
import org.elasticsearch.xpack.core.ml.job.config.Job;
|
||||
import org.elasticsearch.xpack.core.ml.utils.time.TimeUtils;
|
||||
|
||||
|
@ -41,14 +40,8 @@ public class AuditMessage implements ToXContentObject, Writeable {
|
|||
}
|
||||
throw new IllegalArgumentException("Unsupported token [" + p.currentToken() + "]");
|
||||
}, LEVEL, ValueType.STRING);
|
||||
PARSER.declareField(AuditMessage::setTimestamp, p -> {
|
||||
if (p.currentToken() == Token.VALUE_NUMBER) {
|
||||
return new Date(p.longValue());
|
||||
} else if (p.currentToken() == Token.VALUE_STRING) {
|
||||
return new Date(TimeUtils.dateStringToEpoch(p.text()));
|
||||
}
|
||||
throw new IllegalArgumentException("unexpected token [" + p.currentToken() + "] for [" + TIMESTAMP.getPreferredName() + "]");
|
||||
}, TIMESTAMP, ValueType.VALUE);
|
||||
PARSER.declareField(AuditMessage::setTimestamp,
|
||||
p -> TimeUtils.parseTimeField(p, TIMESTAMP.getPreferredName()), TIMESTAMP, ValueType.VALUE);
|
||||
PARSER.declareString(AuditMessage::setNodeName, NODE_NAME);
|
||||
}
|
||||
|
||||
|
|
|
@ -7,8 +7,11 @@ package org.elasticsearch.xpack.core.ml.utils.time;
|
|||
|
||||
import org.elasticsearch.common.ParseField;
|
||||
import org.elasticsearch.common.unit.TimeValue;
|
||||
import org.elasticsearch.common.xcontent.XContentParser;
|
||||
import org.elasticsearch.index.mapper.DateFieldMapper;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.util.Date;
|
||||
import java.util.concurrent.TimeUnit;
|
||||
|
||||
public final class TimeUtils {
|
||||
|
@ -16,6 +19,16 @@ public final class TimeUtils {
|
|||
// Do nothing
|
||||
}
|
||||
|
||||
public static Date parseTimeField(XContentParser parser, String fieldName) throws IOException {
|
||||
if (parser.currentToken() == XContentParser.Token.VALUE_NUMBER) {
|
||||
return new Date(parser.longValue());
|
||||
} else if (parser.currentToken() == XContentParser.Token.VALUE_STRING) {
|
||||
return new Date(TimeUtils.dateStringToEpoch(parser.text()));
|
||||
}
|
||||
throw new IllegalArgumentException(
|
||||
"unexpected token [" + parser.currentToken() + "] for [" + fieldName + "]");
|
||||
}
|
||||
|
||||
/**
|
||||
* First tries to parse the date first as a Long and convert that to an
|
||||
* epoch time. If the long number has more than 10 digits it is considered a
|
||||
|
|
|
@ -46,7 +46,7 @@ public class PutJobActionRequestTests extends AbstractStreamableXContentTestCase
|
|||
|
||||
public void testParseRequest_InvalidCreateSetting() throws IOException {
|
||||
Job.Builder jobConfiguration = buildJobBuilder(jobId, null);
|
||||
jobConfiguration.setLastDataTime(new Date());
|
||||
jobConfiguration.setFinishedTime(new Date());
|
||||
BytesReference bytes = XContentHelper.toXContent(jobConfiguration, XContentType.JSON, false);
|
||||
XContentParser parser = createParser(XContentType.JSON.xContent(), bytes);
|
||||
expectThrows(IllegalArgumentException.class, () -> Request.parseRequest(jobId, parser));
|
||||
|
|
|
@ -38,7 +38,7 @@ public class ValidateJobConfigActionRequestTests extends AbstractStreamableTestC
|
|||
public void testParseRequest_InvalidCreateSetting() throws IOException {
|
||||
String jobId = randomValidJobId();
|
||||
Job.Builder jobConfiguration = buildJobBuilder(jobId, null);
|
||||
jobConfiguration.setLastDataTime(new Date());
|
||||
jobConfiguration.setFinishedTime(new Date());
|
||||
|
||||
XContentBuilder builder = XContentFactory.contentBuilder(XContentType.JSON);
|
||||
XContentBuilder xContentBuilder = jobConfiguration.toXContent(builder, ToXContent.EMPTY_PARAMS);
|
||||
|
|
|
@ -101,7 +101,6 @@ public class JobTests extends AbstractSerializingTestCase<Job> {
|
|||
assertNotNull(job.getDataDescription());
|
||||
assertNull(job.getDescription());
|
||||
assertNull(job.getFinishedTime());
|
||||
assertNull(job.getLastDataTime());
|
||||
assertNull(job.getModelPlotConfig());
|
||||
assertNull(job.getRenormalizationWindowDays());
|
||||
assertNull(job.getBackgroundPersistInterval());
|
||||
|
@ -484,12 +483,10 @@ public class JobTests extends AbstractSerializingTestCase<Job> {
|
|||
|
||||
builder.setCreateTime(new Date());
|
||||
builder.setFinishedTime(new Date());
|
||||
builder.setLastDataTime(new Date());
|
||||
|
||||
Set<String> expected = new HashSet<>();
|
||||
expected.add(Job.CREATE_TIME.getPreferredName());
|
||||
expected.add(Job.FINISHED_TIME.getPreferredName());
|
||||
expected.add(Job.LAST_DATA_TIME.getPreferredName());
|
||||
expected.add(Job.MODEL_SNAPSHOT_ID.getPreferredName());
|
||||
|
||||
assertEquals(expected, new HashSet<>(builder.invalidCreateTimeSettings()));
|
||||
|
@ -613,9 +610,6 @@ public class JobTests extends AbstractSerializingTestCase<Job> {
|
|||
if (randomBoolean()) {
|
||||
builder.setFinishedTime(new Date(randomNonNegativeLong()));
|
||||
}
|
||||
if (randomBoolean()) {
|
||||
builder.setLastDataTime(new Date(randomNonNegativeLong()));
|
||||
}
|
||||
if (randomBoolean()) {
|
||||
builder.setEstablishedModelMemory(randomNonNegativeLong());
|
||||
}
|
||||
|
|
|
@ -36,9 +36,6 @@ public class JobBuilderTests extends AbstractSerializingTestCase<Job.Builder> {
|
|||
if (randomBoolean()) {
|
||||
builder.setFinishedTime(new Date(randomNonNegativeLong()));
|
||||
}
|
||||
if (randomBoolean()) {
|
||||
builder.setLastDataTime(new Date(randomNonNegativeLong()));
|
||||
}
|
||||
if (randomBoolean()) {
|
||||
builder.setAnalysisConfig(AnalysisConfigTests.createRandomized());
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue