Remove the job ignore_downtime option (elastic/x-pack-elasticsearch#550)

Original commit: elastic/x-pack-elasticsearch@5a7c4fdfea
This commit is contained in:
David Kyle 2017-02-14 09:43:25 +00:00 committed by GitHub
parent c4be485514
commit 27a90f4f0d
10 changed files with 9 additions and 183 deletions

View File

@ -94,7 +94,7 @@ public class OpenJobAction extends Action<OpenJobAction.Request, PersistentActio
} }
private String jobId; private String jobId;
private boolean ignoreDowntime; private boolean ignoreDowntime = true;
private TimeValue timeout = TimeValue.timeValueSeconds(20); private TimeValue timeout = TimeValue.timeValueSeconds(20);
public Request(String jobId) { public Request(String jobId) {

View File

@ -22,7 +22,6 @@ import org.elasticsearch.xpack.ml.action.DeleteJobAction;
import org.elasticsearch.xpack.ml.action.PutJobAction; import org.elasticsearch.xpack.ml.action.PutJobAction;
import org.elasticsearch.xpack.ml.action.RevertModelSnapshotAction; import org.elasticsearch.xpack.ml.action.RevertModelSnapshotAction;
import org.elasticsearch.xpack.ml.action.util.QueryPage; import org.elasticsearch.xpack.ml.action.util.QueryPage;
import org.elasticsearch.xpack.ml.job.config.IgnoreDowntime;
import org.elasticsearch.xpack.ml.job.config.Job; import org.elasticsearch.xpack.ml.job.config.Job;
import org.elasticsearch.xpack.ml.job.config.JobState; import org.elasticsearch.xpack.ml.job.config.JobState;
import org.elasticsearch.xpack.ml.job.config.JobUpdate; import org.elasticsearch.xpack.ml.job.config.JobUpdate;
@ -336,12 +335,6 @@ public class JobManager extends AbstractComponent {
Job job = getJobOrThrowIfUnknown(currentState, request.getJobId()); Job job = getJobOrThrowIfUnknown(currentState, request.getJobId());
Job.Builder builder = new Job.Builder(job); Job.Builder builder = new Job.Builder(job);
builder.setModelSnapshotId(modelSnapshot.getSnapshotId()); builder.setModelSnapshotId(modelSnapshot.getSnapshotId());
if (request.getDeleteInterveningResults()) {
builder.setIgnoreDowntime(IgnoreDowntime.NEVER);
} else {
builder.setIgnoreDowntime(IgnoreDowntime.ONCE);
}
return updateClusterState(builder.build(), true, currentState); return updateClusterState(builder.build(), true, currentState);
} }
}); });

View File

@ -1,56 +0,0 @@
/*
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one
* or more contributor license agreements. Licensed under the Elastic License;
* you may not use this file except in compliance with the Elastic License.
*/
package org.elasticsearch.xpack.ml.job.config;
import org.elasticsearch.common.io.stream.StreamInput;
import org.elasticsearch.common.io.stream.StreamOutput;
import org.elasticsearch.common.io.stream.Writeable;
import java.io.IOException;
import java.util.Locale;
public enum IgnoreDowntime implements Writeable {
NEVER, ONCE, ALWAYS;
/**
* <p>
* Parses a string and returns the corresponding enum value.
* </p>
* <p>
* The method differs from {@link #valueOf(String)} by being
* able to handle leading/trailing whitespace and being case
* insensitive.
* </p>
* <p>
* If there is no match {@link IllegalArgumentException} is thrown.
* </p>
*
* @param value A String that should match one of the enum values
* @return the matching enum value
*/
public static IgnoreDowntime fromString(String value) {
return valueOf(value.trim().toUpperCase(Locale.ROOT));
}
public static IgnoreDowntime fromStream(StreamInput in) throws IOException {
int ordinal = in.readVInt();
if (ordinal < 0 || ordinal >= values().length) {
throw new IOException("Unknown public enum IgnoreDowntime {\n ordinal [" + ordinal + "]");
}
return values()[ordinal];
}
@Override
public void writeTo(StreamOutput out) throws IOException {
out.writeVInt(ordinal());
}
@Override
public String toString() {
return name().toLowerCase(Locale.ROOT);
}
}

View File

@ -52,7 +52,6 @@ public class Job extends AbstractDiffable<Job> implements Writeable, ToXContent
public static final ParseField DATA_DESCRIPTION = new ParseField("data_description"); public static final ParseField DATA_DESCRIPTION = new ParseField("data_description");
public static final ParseField DESCRIPTION = new ParseField("description"); public static final ParseField DESCRIPTION = new ParseField("description");
public static final ParseField FINISHED_TIME = new ParseField("finished_time"); public static final ParseField FINISHED_TIME = new ParseField("finished_time");
public static final ParseField IGNORE_DOWNTIME = new ParseField("ignore_downtime");
public static final ParseField LAST_DATA_TIME = new ParseField("last_data_time"); public static final ParseField LAST_DATA_TIME = new ParseField("last_data_time");
public static final ParseField MODEL_DEBUG_CONFIG = new ParseField("model_debug_config"); public static final ParseField MODEL_DEBUG_CONFIG = new ParseField("model_debug_config");
public static final ParseField RENORMALIZATION_WINDOW_DAYS = new ParseField("renormalization_window_days"); public static final ParseField RENORMALIZATION_WINDOW_DAYS = new ParseField("renormalization_window_days");
@ -106,7 +105,6 @@ public class Job extends AbstractDiffable<Job> implements Writeable, ToXContent
PARSER.declareObject(Builder::setAnalysisLimits, AnalysisLimits.PARSER, ANALYSIS_LIMITS); PARSER.declareObject(Builder::setAnalysisLimits, AnalysisLimits.PARSER, ANALYSIS_LIMITS);
PARSER.declareObject(Builder::setDataDescription, DataDescription.PARSER, DATA_DESCRIPTION); PARSER.declareObject(Builder::setDataDescription, DataDescription.PARSER, DATA_DESCRIPTION);
PARSER.declareObject(Builder::setModelDebugConfig, ModelDebugConfig.PARSER, MODEL_DEBUG_CONFIG); PARSER.declareObject(Builder::setModelDebugConfig, ModelDebugConfig.PARSER, MODEL_DEBUG_CONFIG);
PARSER.declareField(Builder::setIgnoreDowntime, (p, c) -> IgnoreDowntime.fromString(p.text()), IGNORE_DOWNTIME, ValueType.STRING);
PARSER.declareLong(Builder::setRenormalizationWindowDays, RENORMALIZATION_WINDOW_DAYS); PARSER.declareLong(Builder::setRenormalizationWindowDays, RENORMALIZATION_WINDOW_DAYS);
PARSER.declareLong(Builder::setBackgroundPersistInterval, BACKGROUND_PERSIST_INTERVAL); PARSER.declareLong(Builder::setBackgroundPersistInterval, BACKGROUND_PERSIST_INTERVAL);
PARSER.declareLong(Builder::setResultsRetentionDays, RESULTS_RETENTION_DAYS); PARSER.declareLong(Builder::setResultsRetentionDays, RESULTS_RETENTION_DAYS);
@ -127,7 +125,6 @@ public class Job extends AbstractDiffable<Job> implements Writeable, ToXContent
private final AnalysisLimits analysisLimits; private final AnalysisLimits analysisLimits;
private final DataDescription dataDescription; private final DataDescription dataDescription;
private final ModelDebugConfig modelDebugConfig; private final ModelDebugConfig modelDebugConfig;
private final IgnoreDowntime ignoreDowntime;
private final Long renormalizationWindowDays; private final Long renormalizationWindowDays;
private final Long backgroundPersistInterval; private final Long backgroundPersistInterval;
private final Long modelSnapshotRetentionDays; private final Long modelSnapshotRetentionDays;
@ -139,9 +136,9 @@ public class Job extends AbstractDiffable<Job> implements Writeable, ToXContent
public Job(String jobId, String description, Date createTime, Date finishedTime, Date lastDataTime, public Job(String jobId, String description, Date createTime, Date finishedTime, Date lastDataTime,
AnalysisConfig analysisConfig, AnalysisLimits analysisLimits, DataDescription dataDescription, AnalysisConfig analysisConfig, AnalysisLimits analysisLimits, DataDescription dataDescription,
ModelDebugConfig modelDebugConfig, IgnoreDowntime ignoreDowntime, ModelDebugConfig modelDebugConfig, Long renormalizationWindowDays, Long backgroundPersistInterval,
Long renormalizationWindowDays, Long backgroundPersistInterval, Long modelSnapshotRetentionDays, Long resultsRetentionDays, Long modelSnapshotRetentionDays, Long resultsRetentionDays, Map<String, Object> customSettings,
Map<String, Object> customSettings, String modelSnapshotId, String indexName, boolean deleted) { String modelSnapshotId, String indexName, boolean deleted) {
if (analysisConfig == null) { if (analysisConfig == null) {
throw new IllegalArgumentException(Messages.getMessage(Messages.JOB_CONFIG_MISSING_ANALYSISCONFIG)); throw new IllegalArgumentException(Messages.getMessage(Messages.JOB_CONFIG_MISSING_ANALYSISCONFIG));
} }
@ -173,7 +170,6 @@ public class Job extends AbstractDiffable<Job> implements Writeable, ToXContent
this.analysisLimits = analysisLimits; this.analysisLimits = analysisLimits;
this.dataDescription = dataDescription; this.dataDescription = dataDescription;
this.modelDebugConfig = modelDebugConfig; this.modelDebugConfig = modelDebugConfig;
this.ignoreDowntime = ignoreDowntime;
this.renormalizationWindowDays = renormalizationWindowDays; this.renormalizationWindowDays = renormalizationWindowDays;
this.backgroundPersistInterval = backgroundPersistInterval; this.backgroundPersistInterval = backgroundPersistInterval;
this.modelSnapshotRetentionDays = modelSnapshotRetentionDays; this.modelSnapshotRetentionDays = modelSnapshotRetentionDays;
@ -194,7 +190,6 @@ public class Job extends AbstractDiffable<Job> implements Writeable, ToXContent
analysisLimits = in.readOptionalWriteable(AnalysisLimits::new); analysisLimits = in.readOptionalWriteable(AnalysisLimits::new);
dataDescription = in.readOptionalWriteable(DataDescription::new); dataDescription = in.readOptionalWriteable(DataDescription::new);
modelDebugConfig = in.readOptionalWriteable(ModelDebugConfig::new); modelDebugConfig = in.readOptionalWriteable(ModelDebugConfig::new);
ignoreDowntime = in.readOptionalWriteable(IgnoreDowntime::fromStream);
renormalizationWindowDays = in.readOptionalLong(); renormalizationWindowDays = in.readOptionalLong();
backgroundPersistInterval = in.readOptionalLong(); backgroundPersistInterval = in.readOptionalLong();
modelSnapshotRetentionDays = in.readOptionalLong(); modelSnapshotRetentionDays = in.readOptionalLong();
@ -289,10 +284,6 @@ public class Job extends AbstractDiffable<Job> implements Writeable, ToXContent
return analysisLimits; return analysisLimits;
} }
public IgnoreDowntime getIgnoreDowntime() {
return ignoreDowntime;
}
public ModelDebugConfig getModelDebugConfig() { public ModelDebugConfig getModelDebugConfig() {
return modelDebugConfig; return modelDebugConfig;
} }
@ -395,7 +386,6 @@ public class Job extends AbstractDiffable<Job> implements Writeable, ToXContent
out.writeOptionalWriteable(analysisLimits); out.writeOptionalWriteable(analysisLimits);
out.writeOptionalWriteable(dataDescription); out.writeOptionalWriteable(dataDescription);
out.writeOptionalWriteable(modelDebugConfig); out.writeOptionalWriteable(modelDebugConfig);
out.writeOptionalWriteable(ignoreDowntime);
out.writeOptionalLong(renormalizationWindowDays); out.writeOptionalLong(renormalizationWindowDays);
out.writeOptionalLong(backgroundPersistInterval); out.writeOptionalLong(backgroundPersistInterval);
out.writeOptionalLong(modelSnapshotRetentionDays); out.writeOptionalLong(modelSnapshotRetentionDays);
@ -440,9 +430,6 @@ public class Job extends AbstractDiffable<Job> implements Writeable, ToXContent
if (modelDebugConfig != null) { if (modelDebugConfig != null) {
builder.field(MODEL_DEBUG_CONFIG.getPreferredName(), modelDebugConfig, params); builder.field(MODEL_DEBUG_CONFIG.getPreferredName(), modelDebugConfig, params);
} }
if (ignoreDowntime != null) {
builder.field(IGNORE_DOWNTIME.getPreferredName(), ignoreDowntime);
}
if (renormalizationWindowDays != null) { if (renormalizationWindowDays != null) {
builder.field(RENORMALIZATION_WINDOW_DAYS.getPreferredName(), renormalizationWindowDays); builder.field(RENORMALIZATION_WINDOW_DAYS.getPreferredName(), renormalizationWindowDays);
} }
@ -486,7 +473,6 @@ public class Job extends AbstractDiffable<Job> implements Writeable, ToXContent
&& Objects.equals(this.analysisConfig, that.analysisConfig) && Objects.equals(this.analysisConfig, that.analysisConfig)
&& Objects.equals(this.analysisLimits, that.analysisLimits) && Objects.equals(this.dataDescription, that.dataDescription) && Objects.equals(this.analysisLimits, that.analysisLimits) && Objects.equals(this.dataDescription, that.dataDescription)
&& Objects.equals(this.modelDebugConfig, that.modelDebugConfig) && Objects.equals(this.modelDebugConfig, that.modelDebugConfig)
&& Objects.equals(this.ignoreDowntime, that.ignoreDowntime)
&& Objects.equals(this.renormalizationWindowDays, that.renormalizationWindowDays) && Objects.equals(this.renormalizationWindowDays, that.renormalizationWindowDays)
&& Objects.equals(this.backgroundPersistInterval, that.backgroundPersistInterval) && Objects.equals(this.backgroundPersistInterval, that.backgroundPersistInterval)
&& Objects.equals(this.modelSnapshotRetentionDays, that.modelSnapshotRetentionDays) && Objects.equals(this.modelSnapshotRetentionDays, that.modelSnapshotRetentionDays)
@ -501,7 +487,7 @@ public class Job extends AbstractDiffable<Job> implements Writeable, ToXContent
public int hashCode() { public int hashCode() {
return Objects.hash(jobId, description, createTime, finishedTime, lastDataTime, analysisConfig, return Objects.hash(jobId, description, createTime, finishedTime, lastDataTime, analysisConfig,
analysisLimits, dataDescription, modelDebugConfig, renormalizationWindowDays, analysisLimits, dataDescription, modelDebugConfig, renormalizationWindowDays,
backgroundPersistInterval, modelSnapshotRetentionDays, resultsRetentionDays, ignoreDowntime, customSettings, backgroundPersistInterval, modelSnapshotRetentionDays, resultsRetentionDays, customSettings,
modelSnapshotId, indexName, deleted); modelSnapshotId, indexName, deleted);
} }
@ -533,7 +519,6 @@ public class Job extends AbstractDiffable<Job> implements Writeable, ToXContent
private Long backgroundPersistInterval; private Long backgroundPersistInterval;
private Long modelSnapshotRetentionDays; private Long modelSnapshotRetentionDays;
private Long resultsRetentionDays; private Long resultsRetentionDays;
private IgnoreDowntime ignoreDowntime;
private Map<String, Object> customSettings; private Map<String, Object> customSettings;
private String modelSnapshotId; private String modelSnapshotId;
private String indexName; private String indexName;
@ -558,7 +543,6 @@ public class Job extends AbstractDiffable<Job> implements Writeable, ToXContent
this.renormalizationWindowDays = job.getRenormalizationWindowDays(); this.renormalizationWindowDays = job.getRenormalizationWindowDays();
this.backgroundPersistInterval = job.getBackgroundPersistInterval(); this.backgroundPersistInterval = job.getBackgroundPersistInterval();
this.resultsRetentionDays = job.getResultsRetentionDays(); this.resultsRetentionDays = job.getResultsRetentionDays();
this.ignoreDowntime = job.getIgnoreDowntime();
this.customSettings = job.getCustomSettings(); this.customSettings = job.getCustomSettings();
this.modelSnapshotId = job.getModelSnapshotId(); this.modelSnapshotId = job.getModelSnapshotId();
} }
@ -636,10 +620,6 @@ public class Job extends AbstractDiffable<Job> implements Writeable, ToXContent
this.resultsRetentionDays = resultsRetentionDays; this.resultsRetentionDays = resultsRetentionDays;
} }
public void setIgnoreDowntime(IgnoreDowntime ignoreDowntime) {
this.ignoreDowntime = ignoreDowntime;
}
public void setModelSnapshotId(String modelSnapshotId) { public void setModelSnapshotId(String modelSnapshotId) {
this.modelSnapshotId = modelSnapshotId; this.modelSnapshotId = modelSnapshotId;
} }
@ -681,9 +661,8 @@ public class Job extends AbstractDiffable<Job> implements Writeable, ToXContent
return new Job( return new Job(
id, description, createTime, finishedTime, lastDataTime, analysisConfig, analysisLimits, id, description, createTime, finishedTime, lastDataTime, analysisConfig, analysisLimits,
dataDescription, modelDebugConfig, ignoreDowntime, renormalizationWindowDays, dataDescription, modelDebugConfig, renormalizationWindowDays, backgroundPersistInterval,
backgroundPersistInterval, modelSnapshotRetentionDays, resultsRetentionDays, customSettings, modelSnapshotId, modelSnapshotRetentionDays, resultsRetentionDays, customSettings, modelSnapshotId, indexName, deleted);
indexName, deleted);
} }
} }
} }

View File

@ -15,7 +15,6 @@ import org.elasticsearch.env.Environment;
import org.elasticsearch.xpack.XPackPlugin; import org.elasticsearch.xpack.XPackPlugin;
import org.elasticsearch.xpack.ml.job.config.AnalysisConfig; import org.elasticsearch.xpack.ml.job.config.AnalysisConfig;
import org.elasticsearch.xpack.ml.job.config.DataDescription; import org.elasticsearch.xpack.ml.job.config.DataDescription;
import org.elasticsearch.xpack.ml.job.config.IgnoreDowntime;
import org.elasticsearch.xpack.ml.job.config.Job; import org.elasticsearch.xpack.ml.job.config.Job;
import java.io.BufferedWriter; import java.io.BufferedWriter;
@ -216,10 +215,6 @@ public class ProcessCtrl {
int maxQuantileInterval = BASE_MAX_QUANTILE_INTERVAL + intervalStagger; int maxQuantileInterval = BASE_MAX_QUANTILE_INTERVAL + intervalStagger;
command.add(MAX_QUANTILE_INTERVAL_ARG + maxQuantileInterval); command.add(MAX_QUANTILE_INTERVAL_ARG + maxQuantileInterval);
ignoreDowntime = ignoreDowntime
|| job.getIgnoreDowntime() == IgnoreDowntime.ONCE
|| job.getIgnoreDowntime() == IgnoreDowntime.ALWAYS;
if (ignoreDowntime) { if (ignoreDowntime) {
command.add(IGNORE_DOWNTIME_ARG); command.add(IGNORE_DOWNTIME_ARG);
} }

View File

@ -11,7 +11,6 @@ import org.elasticsearch.xpack.ml.job.config.AnalysisConfig;
import org.elasticsearch.xpack.ml.job.config.AnalysisLimits; import org.elasticsearch.xpack.ml.job.config.AnalysisLimits;
import org.elasticsearch.xpack.ml.job.config.DataDescription; import org.elasticsearch.xpack.ml.job.config.DataDescription;
import org.elasticsearch.xpack.ml.job.config.Detector; import org.elasticsearch.xpack.ml.job.config.Detector;
import org.elasticsearch.xpack.ml.job.config.IgnoreDowntime;
import org.elasticsearch.xpack.ml.job.config.Job; import org.elasticsearch.xpack.ml.job.config.Job;
import org.elasticsearch.xpack.ml.job.config.ModelDebugConfig; import org.elasticsearch.xpack.ml.job.config.ModelDebugConfig;
import org.elasticsearch.xpack.ml.support.AbstractStreamableTestCase; import org.elasticsearch.xpack.ml.support.AbstractStreamableTestCase;
@ -42,7 +41,6 @@ public class GetJobsActionResponseTests extends AbstractStreamableTestCase<GetJo
AnalysisLimits analysisLimits = new AnalysisLimits(randomNonNegativeLong(), randomNonNegativeLong()); AnalysisLimits analysisLimits = new AnalysisLimits(randomNonNegativeLong(), randomNonNegativeLong());
DataDescription dataDescription = randomBoolean() ? new DataDescription.Builder().build() : null; DataDescription dataDescription = randomBoolean() ? new DataDescription.Builder().build() : null;
ModelDebugConfig modelDebugConfig = randomBoolean() ? new ModelDebugConfig(randomDouble(), randomAsciiOfLength(10)) : null; ModelDebugConfig modelDebugConfig = randomBoolean() ? new ModelDebugConfig(randomDouble(), randomAsciiOfLength(10)) : null;
IgnoreDowntime ignoreDowntime = randomFrom(IgnoreDowntime.values());
Long normalizationWindowDays = randomBoolean() ? Long.valueOf(randomIntBetween(0, 365)) : null; Long normalizationWindowDays = randomBoolean() ? Long.valueOf(randomIntBetween(0, 365)) : null;
Long backgroundPersistInterval = randomBoolean() ? Long.valueOf(randomIntBetween(3600, 86400)) : null; Long backgroundPersistInterval = randomBoolean() ? Long.valueOf(randomIntBetween(3600, 86400)) : null;
Long modelSnapshotRetentionDays = randomBoolean() ? Long.valueOf(randomIntBetween(0, 365)) : null; Long modelSnapshotRetentionDays = randomBoolean() ? Long.valueOf(randomIntBetween(0, 365)) : null;
@ -53,7 +51,7 @@ public class GetJobsActionResponseTests extends AbstractStreamableTestCase<GetJo
String indexName = randomBoolean() ? "index" + j : null; String indexName = randomBoolean() ? "index" + j : null;
Job job = new Job(jobId, description, createTime, finishedTime, lastDataTime, Job job = new Job(jobId, description, createTime, finishedTime, lastDataTime,
analysisConfig, analysisLimits, dataDescription, analysisConfig, analysisLimits, dataDescription,
modelDebugConfig, ignoreDowntime, normalizationWindowDays, backgroundPersistInterval, modelDebugConfig, normalizationWindowDays, backgroundPersistInterval,
modelSnapshotRetentionDays, resultsRetentionDays, customConfig, modelSnapshotId, indexName, randomBoolean()); modelSnapshotRetentionDays, resultsRetentionDays, customConfig, modelSnapshotId, indexName, randomBoolean());
jobList.add(job); jobList.add(job);

View File

@ -6,7 +6,6 @@
package org.elasticsearch.xpack.ml.action; package org.elasticsearch.xpack.ml.action;
import org.elasticsearch.xpack.ml.action.PutJobAction.Response; import org.elasticsearch.xpack.ml.action.PutJobAction.Response;
import org.elasticsearch.xpack.ml.job.config.IgnoreDowntime;
import org.elasticsearch.xpack.ml.job.config.Job; import org.elasticsearch.xpack.ml.job.config.Job;
import org.elasticsearch.xpack.ml.support.AbstractStreamableTestCase; import org.elasticsearch.xpack.ml.support.AbstractStreamableTestCase;
@ -18,7 +17,6 @@ public class PutJobActionResponseTests extends AbstractStreamableTestCase<Respon
@Override @Override
protected Response createTestInstance() { protected Response createTestInstance() {
Job.Builder builder = buildJobBuilder(randomValidJobId()); Job.Builder builder = buildJobBuilder(randomValidJobId());
builder.setIgnoreDowntime(IgnoreDowntime.NEVER);
return new Response(randomBoolean(), builder.build()); return new Response(randomBoolean(), builder.build());
} }

View File

@ -1,56 +0,0 @@
/*
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one
* or more contributor license agreements. Licensed under the Elastic License;
* you may not use this file except in compliance with the Elastic License.
*/
package org.elasticsearch.xpack.ml.job.config;
import org.elasticsearch.test.ESTestCase;
public class IgnoreDowntimeTests extends ESTestCase {
public void testFromString() {
assertEquals(IgnoreDowntime.fromString("always"), IgnoreDowntime.ALWAYS);
assertEquals(IgnoreDowntime.fromString("never"), IgnoreDowntime.NEVER);
assertEquals(IgnoreDowntime.fromString("once"), IgnoreDowntime.ONCE);
}
public void testToString() {
assertEquals("always", IgnoreDowntime.ALWAYS.toString());
assertEquals("never", IgnoreDowntime.NEVER.toString());
assertEquals("once", IgnoreDowntime.ONCE.toString());
}
public void testValidOrdinals() {
assertEquals(0, IgnoreDowntime.NEVER.ordinal());
assertEquals(1, IgnoreDowntime.ONCE.ordinal());
assertEquals(2, IgnoreDowntime.ALWAYS.ordinal());
}
public void testFromString_GivenLeadingWhitespace() {
assertEquals(IgnoreDowntime.ALWAYS, IgnoreDowntime.fromString(" \t ALWAYS"));
}
public void testFromString_GivenTrailingWhitespace() {
assertEquals(IgnoreDowntime.NEVER, IgnoreDowntime.fromString("NEVER \t "));
}
public void testFromString_GivenExactMatches() {
assertEquals(IgnoreDowntime.NEVER, IgnoreDowntime.fromString("NEVER"));
assertEquals(IgnoreDowntime.ONCE, IgnoreDowntime.fromString("ONCE"));
assertEquals(IgnoreDowntime.ALWAYS, IgnoreDowntime.fromString("ALWAYS"));
}
public void testFromString_GivenMixedCaseCharacters() {
assertEquals(IgnoreDowntime.NEVER, IgnoreDowntime.fromString("nevEr"));
assertEquals(IgnoreDowntime.ONCE, IgnoreDowntime.fromString("oNce"));
assertEquals(IgnoreDowntime.ALWAYS, IgnoreDowntime.fromString("always"));
}
public void testFromString_GivenNonMatchingString() {
ESTestCase.expectThrows(IllegalArgumentException.class, () -> IgnoreDowntime.fromString("nope"));
}
}

View File

@ -48,7 +48,6 @@ public class JobTests extends AbstractSerializingTestCase<Job> {
assertNotNull(job.getDataDescription()); assertNotNull(job.getDataDescription());
assertNull(job.getDescription()); assertNull(job.getDescription());
assertNull(job.getFinishedTime()); assertNull(job.getFinishedTime());
assertNull(job.getIgnoreDowntime());
assertNull(job.getLastDataTime()); assertNull(job.getLastDataTime());
assertNull(job.getModelDebugConfig()); assertNull(job.getModelDebugConfig());
assertNull(job.getRenormalizationWindowDays()); assertNull(job.getRenormalizationWindowDays());
@ -59,16 +58,6 @@ public class JobTests extends AbstractSerializingTestCase<Job> {
assertFalse(job.allFields().isEmpty()); assertFalse(job.allFields().isEmpty());
} }
public void testConstructor_GivenJobConfigurationWithIgnoreDowntime() {
Job.Builder builder = new Job.Builder("foo");
builder.setIgnoreDowntime(IgnoreDowntime.ONCE);
builder.setAnalysisConfig(createAnalysisConfig());
Job job = builder.build();
assertEquals("foo", job.getId());
assertEquals(IgnoreDowntime.ONCE, job.getIgnoreDowntime());
}
public void testNoId() { public void testNoId() {
expectThrows(IllegalArgumentException.class, () -> buildJobBuilder("").build(true, "")); expectThrows(IllegalArgumentException.class, () -> buildJobBuilder("").build(true, ""));
} }
@ -145,16 +134,6 @@ public class JobTests extends AbstractSerializingTestCase<Job> {
assertFalse(jobDetails1.build().equals(jobDetails2.build())); assertFalse(jobDetails1.build().equals(jobDetails2.build()));
} }
public void testEquals_GivenDifferentIgnoreDowntime() {
Job.Builder job1 = new Job.Builder();
job1.setIgnoreDowntime(IgnoreDowntime.NEVER);
Job.Builder job2 = new Job.Builder();
job2.setIgnoreDowntime(IgnoreDowntime.ONCE);
assertFalse(job1.equals(job2));
assertFalse(job2.equals(job1));
}
public void testSetAnalysisLimits() { public void testSetAnalysisLimits() {
Job.Builder builder = new Job.Builder(); Job.Builder builder = new Job.Builder();
builder.setAnalysisLimits(new AnalysisLimits(42L, null)); builder.setAnalysisLimits(new AnalysisLimits(42L, null));
@ -402,7 +381,6 @@ public class JobTests extends AbstractSerializingTestCase<Job> {
if (randomBoolean()) { if (randomBoolean()) {
builder.setModelDebugConfig(new ModelDebugConfig(randomDouble(), randomAsciiOfLength(10))); builder.setModelDebugConfig(new ModelDebugConfig(randomDouble(), randomAsciiOfLength(10)));
} }
builder.setIgnoreDowntime(randomFrom(IgnoreDowntime.values()));
if (randomBoolean()) { if (randomBoolean()) {
builder.setRenormalizationWindowDays(randomNonNegativeLong()); builder.setRenormalizationWindowDays(randomNonNegativeLong());
} }

View File

@ -12,7 +12,6 @@ import org.elasticsearch.test.ESTestCase;
import org.elasticsearch.xpack.ml.job.config.AnalysisConfig; import org.elasticsearch.xpack.ml.job.config.AnalysisConfig;
import org.elasticsearch.xpack.ml.job.config.DataDescription; import org.elasticsearch.xpack.ml.job.config.DataDescription;
import org.elasticsearch.xpack.ml.job.config.Detector; import org.elasticsearch.xpack.ml.job.config.Detector;
import org.elasticsearch.xpack.ml.job.config.IgnoreDowntime;
import org.elasticsearch.xpack.ml.job.config.Job; import org.elasticsearch.xpack.ml.job.config.Job;
import org.mockito.Mockito; import org.mockito.Mockito;
import java.io.IOException; import java.io.IOException;
@ -51,9 +50,7 @@ public class ProcessCtrlTests extends ESTestCase {
dd.setTimeField("tf"); dd.setTimeField("tf");
job.setDataDescription(dd); job.setDataDescription(dd);
job.setIgnoreDowntime(IgnoreDowntime.ONCE); List<String> command = ProcessCtrl.buildAutodetectCommand(env, settings, job.build(), logger, true, pid);
List<String> command = ProcessCtrl.buildAutodetectCommand(env, settings, job.build(), logger, false, pid);
assertEquals(17, command.size()); assertEquals(17, command.size());
assertTrue(command.contains(ProcessCtrl.AUTODETECT_PATH)); assertTrue(command.contains(ProcessCtrl.AUTODETECT_PATH));
assertTrue(command.contains(ProcessCtrl.BATCH_SPAN_ARG + "100")); assertTrue(command.contains(ProcessCtrl.BATCH_SPAN_ARG + "100"));