diff --git a/plugin/src/main/java/org/elasticsearch/xpack/ml/action/TransportJobTaskAction.java b/plugin/src/main/java/org/elasticsearch/xpack/ml/action/TransportJobTaskAction.java index 92259fb9561..216c6e7faf0 100644 --- a/plugin/src/main/java/org/elasticsearch/xpack/ml/action/TransportJobTaskAction.java +++ b/plugin/src/main/java/org/elasticsearch/xpack/ml/action/TransportJobTaskAction.java @@ -61,14 +61,10 @@ public abstract class TransportJobTaskAction executorNodes = new HashSet<>(); - for (String resolvedJobId : request.getResolvedJobIds()) { JobManager.getJobOrThrowIfUnknown(state, resolvedJobId); - PersistentTasksCustomMetaData tasks = clusterService.state().getMetaData() - .custom(PersistentTasksCustomMetaData.TYPE); - PersistentTasksCustomMetaData.PersistentTask jobTask = MlMetadata - .getJobTask(resolvedJobId, tasks); - + PersistentTasksCustomMetaData tasks = state.metaData().custom(PersistentTasksCustomMetaData.TYPE); + PersistentTasksCustomMetaData.PersistentTask jobTask = MlMetadata.getJobTask(resolvedJobId, tasks); if (jobTask == null || jobTask.isAssigned() == false) { String message = "Cannot perform requested action because job [" + resolvedJobId + "] is not open";