From 27a90f4f0d662d163ced8d9a29ddec9edb4ff41c Mon Sep 17 00:00:00 2001
From: David Kyle
Date: Tue, 14 Feb 2017 09:43:25 +0000
Subject: [PATCH] Remove the job ignore_downtime option
(elastic/x-pack-elasticsearch#550)
Original commit: elastic/x-pack-elasticsearch@5a7c4fdfea0911e533837fea2f39a6dda9e31ad3
---
.../xpack/ml/action/OpenJobAction.java | 2 +-
.../xpack/ml/job/JobManager.java | 7 ---
.../xpack/ml/job/config/IgnoreDowntime.java | 56 -------------------
.../xpack/ml/job/config/Job.java | 33 ++---------
.../xpack/ml/job/process/ProcessCtrl.java | 5 --
.../ml/action/GetJobsActionResponseTests.java | 4 +-
.../ml/action/PutJobActionResponseTests.java | 2 -
.../ml/job/config/IgnoreDowntimeTests.java | 56 -------------------
.../xpack/ml/job/config/JobTests.java | 22 --------
.../ml/job/process/ProcessCtrlTests.java | 5 +-
10 files changed, 9 insertions(+), 183 deletions(-)
delete mode 100644 plugin/src/main/java/org/elasticsearch/xpack/ml/job/config/IgnoreDowntime.java
delete mode 100644 plugin/src/test/java/org/elasticsearch/xpack/ml/job/config/IgnoreDowntimeTests.java
diff --git a/plugin/src/main/java/org/elasticsearch/xpack/ml/action/OpenJobAction.java b/plugin/src/main/java/org/elasticsearch/xpack/ml/action/OpenJobAction.java
index fa9626790ed..7d95d217c95 100644
--- a/plugin/src/main/java/org/elasticsearch/xpack/ml/action/OpenJobAction.java
+++ b/plugin/src/main/java/org/elasticsearch/xpack/ml/action/OpenJobAction.java
@@ -94,7 +94,7 @@ public class OpenJobAction extends Action
- * Parses a string and returns the corresponding enum value.
- *
- *
- * The method differs from {@link #valueOf(String)} by being
- * able to handle leading/trailing whitespace and being case
- * insensitive.
- *
- *
- * If there is no match {@link IllegalArgumentException} is thrown.
- *
- *
- * @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);
- }
-}
diff --git a/plugin/src/main/java/org/elasticsearch/xpack/ml/job/config/Job.java b/plugin/src/main/java/org/elasticsearch/xpack/ml/job/config/Job.java
index ff851267796..bf57c8a256f 100644
--- a/plugin/src/main/java/org/elasticsearch/xpack/ml/job/config/Job.java
+++ b/plugin/src/main/java/org/elasticsearch/xpack/ml/job/config/Job.java
@@ -52,7 +52,6 @@ public class Job extends AbstractDiffable implements Writeable, ToXContent
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 IGNORE_DOWNTIME = new ParseField("ignore_downtime");
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 RENORMALIZATION_WINDOW_DAYS = new ParseField("renormalization_window_days");
@@ -106,7 +105,6 @@ public class Job extends AbstractDiffable implements Writeable, ToXContent
PARSER.declareObject(Builder::setAnalysisLimits, AnalysisLimits.PARSER, ANALYSIS_LIMITS);
PARSER.declareObject(Builder::setDataDescription, DataDescription.PARSER, DATA_DESCRIPTION);
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::setBackgroundPersistInterval, BACKGROUND_PERSIST_INTERVAL);
PARSER.declareLong(Builder::setResultsRetentionDays, RESULTS_RETENTION_DAYS);
@@ -127,7 +125,6 @@ public class Job extends AbstractDiffable implements Writeable, ToXContent
private final AnalysisLimits analysisLimits;
private final DataDescription dataDescription;
private final ModelDebugConfig modelDebugConfig;
- private final IgnoreDowntime ignoreDowntime;
private final Long renormalizationWindowDays;
private final Long backgroundPersistInterval;
private final Long modelSnapshotRetentionDays;
@@ -139,9 +136,9 @@ public class Job extends AbstractDiffable implements Writeable, ToXContent
public Job(String jobId, String description, Date createTime, Date finishedTime, Date lastDataTime,
AnalysisConfig analysisConfig, AnalysisLimits analysisLimits, DataDescription dataDescription,
- ModelDebugConfig modelDebugConfig, IgnoreDowntime ignoreDowntime,
- Long renormalizationWindowDays, Long backgroundPersistInterval, Long modelSnapshotRetentionDays, Long resultsRetentionDays,
- Map customSettings, String modelSnapshotId, String indexName, boolean deleted) {
+ ModelDebugConfig modelDebugConfig, Long renormalizationWindowDays, Long backgroundPersistInterval,
+ Long modelSnapshotRetentionDays, Long resultsRetentionDays, Map customSettings,
+ String modelSnapshotId, String indexName, boolean deleted) {
if (analysisConfig == null) {
throw new IllegalArgumentException(Messages.getMessage(Messages.JOB_CONFIG_MISSING_ANALYSISCONFIG));
}
@@ -173,7 +170,6 @@ public class Job extends AbstractDiffable implements Writeable, ToXContent
this.analysisLimits = analysisLimits;
this.dataDescription = dataDescription;
this.modelDebugConfig = modelDebugConfig;
- this.ignoreDowntime = ignoreDowntime;
this.renormalizationWindowDays = renormalizationWindowDays;
this.backgroundPersistInterval = backgroundPersistInterval;
this.modelSnapshotRetentionDays = modelSnapshotRetentionDays;
@@ -194,7 +190,6 @@ public class Job extends AbstractDiffable implements Writeable, ToXContent
analysisLimits = in.readOptionalWriteable(AnalysisLimits::new);
dataDescription = in.readOptionalWriteable(DataDescription::new);
modelDebugConfig = in.readOptionalWriteable(ModelDebugConfig::new);
- ignoreDowntime = in.readOptionalWriteable(IgnoreDowntime::fromStream);
renormalizationWindowDays = in.readOptionalLong();
backgroundPersistInterval = in.readOptionalLong();
modelSnapshotRetentionDays = in.readOptionalLong();
@@ -289,10 +284,6 @@ public class Job extends AbstractDiffable implements Writeable, ToXContent
return analysisLimits;
}
- public IgnoreDowntime getIgnoreDowntime() {
- return ignoreDowntime;
- }
-
public ModelDebugConfig getModelDebugConfig() {
return modelDebugConfig;
}
@@ -395,7 +386,6 @@ public class Job extends AbstractDiffable implements Writeable, ToXContent
out.writeOptionalWriteable(analysisLimits);
out.writeOptionalWriteable(dataDescription);
out.writeOptionalWriteable(modelDebugConfig);
- out.writeOptionalWriteable(ignoreDowntime);
out.writeOptionalLong(renormalizationWindowDays);
out.writeOptionalLong(backgroundPersistInterval);
out.writeOptionalLong(modelSnapshotRetentionDays);
@@ -440,9 +430,6 @@ public class Job extends AbstractDiffable implements Writeable, ToXContent
if (modelDebugConfig != null) {
builder.field(MODEL_DEBUG_CONFIG.getPreferredName(), modelDebugConfig, params);
}
- if (ignoreDowntime != null) {
- builder.field(IGNORE_DOWNTIME.getPreferredName(), ignoreDowntime);
- }
if (renormalizationWindowDays != null) {
builder.field(RENORMALIZATION_WINDOW_DAYS.getPreferredName(), renormalizationWindowDays);
}
@@ -486,7 +473,6 @@ public class Job extends AbstractDiffable implements Writeable, ToXContent
&& Objects.equals(this.analysisConfig, that.analysisConfig)
&& Objects.equals(this.analysisLimits, that.analysisLimits) && Objects.equals(this.dataDescription, that.dataDescription)
&& Objects.equals(this.modelDebugConfig, that.modelDebugConfig)
- && Objects.equals(this.ignoreDowntime, that.ignoreDowntime)
&& Objects.equals(this.renormalizationWindowDays, that.renormalizationWindowDays)
&& Objects.equals(this.backgroundPersistInterval, that.backgroundPersistInterval)
&& Objects.equals(this.modelSnapshotRetentionDays, that.modelSnapshotRetentionDays)
@@ -501,7 +487,7 @@ public class Job extends AbstractDiffable implements Writeable, ToXContent
public int hashCode() {
return Objects.hash(jobId, description, createTime, finishedTime, lastDataTime, analysisConfig,
analysisLimits, dataDescription, modelDebugConfig, renormalizationWindowDays,
- backgroundPersistInterval, modelSnapshotRetentionDays, resultsRetentionDays, ignoreDowntime, customSettings,
+ backgroundPersistInterval, modelSnapshotRetentionDays, resultsRetentionDays, customSettings,
modelSnapshotId, indexName, deleted);
}
@@ -533,7 +519,6 @@ public class Job extends AbstractDiffable implements Writeable, ToXContent
private Long backgroundPersistInterval;
private Long modelSnapshotRetentionDays;
private Long resultsRetentionDays;
- private IgnoreDowntime ignoreDowntime;
private Map customSettings;
private String modelSnapshotId;
private String indexName;
@@ -558,7 +543,6 @@ public class Job extends AbstractDiffable implements Writeable, ToXContent
this.renormalizationWindowDays = job.getRenormalizationWindowDays();
this.backgroundPersistInterval = job.getBackgroundPersistInterval();
this.resultsRetentionDays = job.getResultsRetentionDays();
- this.ignoreDowntime = job.getIgnoreDowntime();
this.customSettings = job.getCustomSettings();
this.modelSnapshotId = job.getModelSnapshotId();
}
@@ -636,10 +620,6 @@ public class Job extends AbstractDiffable implements Writeable, ToXContent
this.resultsRetentionDays = resultsRetentionDays;
}
- public void setIgnoreDowntime(IgnoreDowntime ignoreDowntime) {
- this.ignoreDowntime = ignoreDowntime;
- }
-
public void setModelSnapshotId(String modelSnapshotId) {
this.modelSnapshotId = modelSnapshotId;
}
@@ -681,9 +661,8 @@ public class Job extends AbstractDiffable implements Writeable, ToXContent
return new Job(
id, description, createTime, finishedTime, lastDataTime, analysisConfig, analysisLimits,
- dataDescription, modelDebugConfig, ignoreDowntime, renormalizationWindowDays,
- backgroundPersistInterval, modelSnapshotRetentionDays, resultsRetentionDays, customSettings, modelSnapshotId,
- indexName, deleted);
+ dataDescription, modelDebugConfig, renormalizationWindowDays, backgroundPersistInterval,
+ modelSnapshotRetentionDays, resultsRetentionDays, customSettings, modelSnapshotId, indexName, deleted);
}
}
}
diff --git a/plugin/src/main/java/org/elasticsearch/xpack/ml/job/process/ProcessCtrl.java b/plugin/src/main/java/org/elasticsearch/xpack/ml/job/process/ProcessCtrl.java
index 9b819ffa3e6..255e4a7fd48 100644
--- a/plugin/src/main/java/org/elasticsearch/xpack/ml/job/process/ProcessCtrl.java
+++ b/plugin/src/main/java/org/elasticsearch/xpack/ml/job/process/ProcessCtrl.java
@@ -15,7 +15,6 @@ import org.elasticsearch.env.Environment;
import org.elasticsearch.xpack.XPackPlugin;
import org.elasticsearch.xpack.ml.job.config.AnalysisConfig;
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 java.io.BufferedWriter;
@@ -216,10 +215,6 @@ public class ProcessCtrl {
int maxQuantileInterval = BASE_MAX_QUANTILE_INTERVAL + intervalStagger;
command.add(MAX_QUANTILE_INTERVAL_ARG + maxQuantileInterval);
- ignoreDowntime = ignoreDowntime
- || job.getIgnoreDowntime() == IgnoreDowntime.ONCE
- || job.getIgnoreDowntime() == IgnoreDowntime.ALWAYS;
-
if (ignoreDowntime) {
command.add(IGNORE_DOWNTIME_ARG);
}
diff --git a/plugin/src/test/java/org/elasticsearch/xpack/ml/action/GetJobsActionResponseTests.java b/plugin/src/test/java/org/elasticsearch/xpack/ml/action/GetJobsActionResponseTests.java
index fa26665c7b0..dbbbe428e0f 100644
--- a/plugin/src/test/java/org/elasticsearch/xpack/ml/action/GetJobsActionResponseTests.java
+++ b/plugin/src/test/java/org/elasticsearch/xpack/ml/action/GetJobsActionResponseTests.java
@@ -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.DataDescription;
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.ModelDebugConfig;
import org.elasticsearch.xpack.ml.support.AbstractStreamableTestCase;
@@ -42,7 +41,6 @@ public class GetJobsActionResponseTests extends AbstractStreamableTestCase IgnoreDowntime.fromString("nope"));
- }
-}
diff --git a/plugin/src/test/java/org/elasticsearch/xpack/ml/job/config/JobTests.java b/plugin/src/test/java/org/elasticsearch/xpack/ml/job/config/JobTests.java
index 794531cfc99..5cf3f378688 100644
--- a/plugin/src/test/java/org/elasticsearch/xpack/ml/job/config/JobTests.java
+++ b/plugin/src/test/java/org/elasticsearch/xpack/ml/job/config/JobTests.java
@@ -48,7 +48,6 @@ public class JobTests extends AbstractSerializingTestCase {
assertNotNull(job.getDataDescription());
assertNull(job.getDescription());
assertNull(job.getFinishedTime());
- assertNull(job.getIgnoreDowntime());
assertNull(job.getLastDataTime());
assertNull(job.getModelDebugConfig());
assertNull(job.getRenormalizationWindowDays());
@@ -59,16 +58,6 @@ public class JobTests extends AbstractSerializingTestCase {
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() {
expectThrows(IllegalArgumentException.class, () -> buildJobBuilder("").build(true, ""));
}
@@ -145,16 +134,6 @@ public class JobTests extends AbstractSerializingTestCase {
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() {
Job.Builder builder = new Job.Builder();
builder.setAnalysisLimits(new AnalysisLimits(42L, null));
@@ -402,7 +381,6 @@ public class JobTests extends AbstractSerializingTestCase {
if (randomBoolean()) {
builder.setModelDebugConfig(new ModelDebugConfig(randomDouble(), randomAsciiOfLength(10)));
}
- builder.setIgnoreDowntime(randomFrom(IgnoreDowntime.values()));
if (randomBoolean()) {
builder.setRenormalizationWindowDays(randomNonNegativeLong());
}
diff --git a/plugin/src/test/java/org/elasticsearch/xpack/ml/job/process/ProcessCtrlTests.java b/plugin/src/test/java/org/elasticsearch/xpack/ml/job/process/ProcessCtrlTests.java
index 6cd54c824be..c8924df5b2d 100644
--- a/plugin/src/test/java/org/elasticsearch/xpack/ml/job/process/ProcessCtrlTests.java
+++ b/plugin/src/test/java/org/elasticsearch/xpack/ml/job/process/ProcessCtrlTests.java
@@ -12,7 +12,6 @@ import org.elasticsearch.test.ESTestCase;
import org.elasticsearch.xpack.ml.job.config.AnalysisConfig;
import org.elasticsearch.xpack.ml.job.config.DataDescription;
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.mockito.Mockito;
import java.io.IOException;
@@ -51,9 +50,7 @@ public class ProcessCtrlTests extends ESTestCase {
dd.setTimeField("tf");
job.setDataDescription(dd);
- job.setIgnoreDowntime(IgnoreDowntime.ONCE);
-
- List command = ProcessCtrl.buildAutodetectCommand(env, settings, job.build(), logger, false, pid);
+ List command = ProcessCtrl.buildAutodetectCommand(env, settings, job.build(), logger, true, pid);
assertEquals(17, command.size());
assertTrue(command.contains(ProcessCtrl.AUTODETECT_PATH));
assertTrue(command.contains(ProcessCtrl.BATCH_SPAN_ARG + "100"));