diff --git a/plugin/src/main/java/org/elasticsearch/xpack/ml/MachineLearning.java b/plugin/src/main/java/org/elasticsearch/xpack/ml/MachineLearning.java index 9e2e2413886..362b3afdf5f 100644 --- a/plugin/src/main/java/org/elasticsearch/xpack/ml/MachineLearning.java +++ b/plugin/src/main/java/org/elasticsearch/xpack/ml/MachineLearning.java @@ -155,8 +155,9 @@ public class MachineLearning implements ActionPlugin { public static final Setting AUTODETECT_PROCESS = Setting.boolSetting("xpack.ml.autodetect_process", true, Property.NodeScope); public static final Setting ML_ENABLED = - Setting.boolSetting("node.ml", XPackSettings.MACHINE_LEARNING_ENABLED, Setting.Property.NodeScope); + Setting.boolSetting("node.ml", XPackSettings.MACHINE_LEARNING_ENABLED, Property.NodeScope); public static final String ML_ENABLED_NODE_ATTR = "ml.enabled"; + public static final String MAX_OPEN_JOBS_NODE_ATTR = "ml.max_open_jobs"; public static final Setting CONCURRENT_JOB_ALLOCATIONS = Setting.intSetting("xpack.ml.node_concurrent_job_allocations", 2, 0, Property.Dynamic, Property.NodeScope); @@ -200,7 +201,10 @@ public class MachineLearning implements ActionPlugin { Settings.Builder additionalSettings = Settings.builder(); Boolean allocationEnabled = ML_ENABLED.get(settings); if (allocationEnabled != null && allocationEnabled) { + // TODO: the simple true/false flag will not be required once all supported versions have the number - consider removing in 7.0 additionalSettings.put("node.attr." + ML_ENABLED_NODE_ATTR, "true"); + additionalSettings.put("node.attr." + MAX_OPEN_JOBS_NODE_ATTR, + AutodetectProcessManager.MAX_RUNNING_JOBS_PER_NODE.get(settings)); } return additionalSettings.build(); } 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 369f77319bd..6427de84d55 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 @@ -42,7 +42,6 @@ import org.elasticsearch.common.io.stream.StreamOutput; import org.elasticsearch.common.settings.Settings; import org.elasticsearch.common.unit.TimeValue; import org.elasticsearch.common.xcontent.ObjectParser; -import org.elasticsearch.common.xcontent.ToXContent; import org.elasticsearch.common.xcontent.ToXContentObject; import org.elasticsearch.common.xcontent.XContentBuilder; import org.elasticsearch.common.xcontent.XContentParser; @@ -566,14 +565,20 @@ public class OpenJobAction extends Action unavailableIndices = verifyIndicesPrimaryShardsAreActive(jobId, clusterState); if (unavailableIndices.size() != 0) { String reason = "Not opening job [" + jobId + "], because not all primary shards are active for the following indices [" + @@ -716,6 +722,20 @@ public class OpenJobAction extends Action expectedNodeAttr = new HashMap<>(); expectedNodeAttr.put(MachineLearning.ML_ENABLED_NODE_ATTR, "true"); + expectedNodeAttr.put(MachineLearning.MAX_OPEN_JOBS_NODE_ATTR, "10"); assertEquals(expectedNodeAttr, node.getAttributes()); JobTaskStatus jobTaskStatus = (JobTaskStatus) task.getStatus(); assertNotNull(jobTaskStatus); @@ -402,6 +403,7 @@ public class BasicDistributedJobsIT extends BaseMlIntegTestCase { DiscoveryNode node = clusterState.nodes().resolveNode(task.getExecutorNode()); Map expectedNodeAttr = new HashMap<>(); expectedNodeAttr.put(MachineLearning.ML_ENABLED_NODE_ATTR, "true"); + expectedNodeAttr.put(MachineLearning.MAX_OPEN_JOBS_NODE_ATTR, "10"); assertEquals(expectedNodeAttr, node.getAttributes()); JobTaskStatus jobTaskStatus = (JobTaskStatus) task.getStatus();