From 9e8652edcf293ef543dda64d070910723787b767 Mon Sep 17 00:00:00 2001 From: Ed Savage Date: Mon, 11 Jan 2021 11:02:58 +0000 Subject: [PATCH] [ML] Remove the 'no.model.state.persist' setting Remove the undocumented and unneeded 'no.model.state.persist' setting. --- .../xpack/ml/MachineLearning.java | 1 - .../process/autodetect/AutodetectBuilder.java | 22 +++++-------------- .../NativeAutodetectProcessFactory.java | 3 +-- .../autodetect/AutodetectBuilderTests.java | 8 ++----- 4 files changed, 8 insertions(+), 26 deletions(-) diff --git a/x-pack/plugin/ml/src/main/java/org/elasticsearch/xpack/ml/MachineLearning.java b/x-pack/plugin/ml/src/main/java/org/elasticsearch/xpack/ml/MachineLearning.java index 70a4b6382d7e8..27df7b1778919 100644 --- a/x-pack/plugin/ml/src/main/java/org/elasticsearch/xpack/ml/MachineLearning.java +++ b/x-pack/plugin/ml/src/main/java/org/elasticsearch/xpack/ml/MachineLearning.java @@ -542,7 +542,6 @@ public List> getSettings() { MachineLearningField.MAX_MODEL_MEMORY_LIMIT, MAX_LAZY_ML_NODES, MAX_MACHINE_MEMORY_PERCENT, - AutodetectBuilder.DONT_PERSIST_MODEL_STATE_SETTING, AutodetectBuilder.MAX_ANOMALY_RECORDS_SETTING_DYNAMIC, MAX_OPEN_JOBS_PER_NODE, MIN_DISK_SPACE_OFF_HEAP, diff --git a/x-pack/plugin/ml/src/main/java/org/elasticsearch/xpack/ml/job/process/autodetect/AutodetectBuilder.java b/x-pack/plugin/ml/src/main/java/org/elasticsearch/xpack/ml/job/process/autodetect/AutodetectBuilder.java index 71938cdce8a0f..72fbcca98ee9f 100644 --- a/x-pack/plugin/ml/src/main/java/org/elasticsearch/xpack/ml/job/process/autodetect/AutodetectBuilder.java +++ b/x-pack/plugin/ml/src/main/java/org/elasticsearch/xpack/ml/job/process/autodetect/AutodetectBuilder.java @@ -96,12 +96,6 @@ public class AutodetectBuilder { public static final Setting MAX_ANOMALY_RECORDS_SETTING_DYNAMIC = Setting.intSetting("xpack.ml.max_anomaly_records", DEFAULT_MAX_NUM_RECORDS, Setting.Property.NodeScope, Setting.Property.Dynamic); - /** - * Config setting storing the flag that disables model persistence - */ - public static final Setting DONT_PERSIST_MODEL_STATE_SETTING = Setting.boolSetting("no.model.state.persist", false, - Setting.Property.NodeScope); - private static final int SECONDS_IN_HOUR = 3600; /** @@ -238,17 +232,11 @@ List buildAutodetectCommand() { int intervalStagger = calculateStaggeringInterval(job.getId()); logger.debug("[{}] Periodic operations staggered by {} seconds", job.getId(), intervalStagger); - // Supply a URL for persisting/restoring model state unless model - // persistence has been explicitly disabled. - if (DONT_PERSIST_MODEL_STATE_SETTING.get(settings)) { - logger.info("[{}] Will not persist model state - {} setting was set", job.getId(), DONT_PERSIST_MODEL_STATE_SETTING); - } else { - // Persist model state every few hours even if the job isn't closed - long persistInterval = (job.getBackgroundPersistInterval() == null) ? - (DEFAULT_BASE_PERSIST_INTERVAL + intervalStagger) : - job.getBackgroundPersistInterval().getSeconds(); - command.add(PERSIST_INTERVAL_ARG + persistInterval); - } + // Persist model state every few hours even if the job isn't closed + long persistInterval = (job.getBackgroundPersistInterval() == null) ? + (DEFAULT_BASE_PERSIST_INTERVAL + intervalStagger) : + job.getBackgroundPersistInterval().getSeconds(); + command.add(PERSIST_INTERVAL_ARG + persistInterval); int maxQuantileInterval = BASE_MAX_QUANTILE_INTERVAL + intervalStagger; command.add(MAX_QUANTILE_INTERVAL_ARG + maxQuantileInterval); diff --git a/x-pack/plugin/ml/src/main/java/org/elasticsearch/xpack/ml/job/process/autodetect/NativeAutodetectProcessFactory.java b/x-pack/plugin/ml/src/main/java/org/elasticsearch/xpack/ml/job/process/autodetect/NativeAutodetectProcessFactory.java index 2fb726f52bec7..c4a31158d8ea5 100644 --- a/x-pack/plugin/ml/src/main/java/org/elasticsearch/xpack/ml/job/process/autodetect/NativeAutodetectProcessFactory.java +++ b/x-pack/plugin/ml/src/main/java/org/elasticsearch/xpack/ml/job/process/autodetect/NativeAutodetectProcessFactory.java @@ -78,8 +78,7 @@ public AutodetectProcess createAutodetectProcess(String pipelineId, Consumer onProcessCrash) { List filesToDelete = new ArrayList<>(); ProcessPipes processPipes = new ProcessPipes(env, NAMED_PIPE_HELPER, processConnectTimeout, AutodetectBuilder.AUTODETECT, - pipelineId, null, false, true, true, params.modelSnapshot() != null, - AutodetectBuilder.DONT_PERSIST_MODEL_STATE_SETTING.get(settings) == false); + pipelineId, null, false, true, true, params.modelSnapshot() != null, true); createNativeProcess(job, params, processPipes, filesToDelete); boolean includeTokensField = MachineLearning.CATEGORIZATION_TOKENIZATION_IN_JAVA && job.getAnalysisConfig().getCategorizationFieldName() != null; diff --git a/x-pack/plugin/ml/src/test/java/org/elasticsearch/xpack/ml/job/process/autodetect/AutodetectBuilderTests.java b/x-pack/plugin/ml/src/test/java/org/elasticsearch/xpack/ml/job/process/autodetect/AutodetectBuilderTests.java index 87cd751e548a4..0c496d36d9e6e 100644 --- a/x-pack/plugin/ml/src/test/java/org/elasticsearch/xpack/ml/job/process/autodetect/AutodetectBuilderTests.java +++ b/x-pack/plugin/ml/src/test/java/org/elasticsearch/xpack/ml/job/process/autodetect/AutodetectBuilderTests.java @@ -117,19 +117,15 @@ public void testBuildAutodetectCommand_defaultTimeField() { } public void testBuildAutodetectCommand_givenPersistModelState() { - settings = Settings.builder().put(Environment.PATH_HOME_SETTING.getKey(), createTempDir().toString()) - .put(AutodetectBuilder.DONT_PERSIST_MODEL_STATE_SETTING.getKey(), true).build(); + Job.Builder job = buildJobBuilder("unit-test-job"); int expectedPersistInterval = 10800 + AutodetectBuilder.calculateStaggeringInterval(job.getId()); - List command = autodetectBuilder(job.build()).buildAutodetectCommand(); - assertFalse(command.contains(AutodetectBuilder.PERSIST_INTERVAL_ARG + expectedPersistInterval)); - settings = Settings.builder().put(Environment.PATH_HOME_SETTING.getKey(), createTempDir().toString()).build(); env = TestEnvironment.newEnvironment(settings); - command = autodetectBuilder(job.build()).buildAutodetectCommand(); + List command = autodetectBuilder(job.build()).buildAutodetectCommand(); assertTrue(command.contains(AutodetectBuilder.PERSIST_INTERVAL_ARG + expectedPersistInterval)); }