[ML] Delete and Update datafeed actions should use current cluster state (elastic/x-pack-elasticsearch#1254)

relates elastic/x-pack-elasticsearch#1253

Original commit: elastic/x-pack-elasticsearch@bdf695e694
This commit is contained in:
Dimitris Athanasiou 2017-04-28 17:53:59 +01:00 committed by GitHub
parent 435338e6b9
commit 5a70eac6e8
3 changed files with 5 additions and 6 deletions

View File

@ -169,12 +169,12 @@ public class DeleteDatafeedAction extends Action<DeleteDatafeedAction.Request, D
@Override
public ClusterState execute(ClusterState currentState) throws Exception {
MlMetadata currentMetadata = state.getMetaData().custom(MlMetadata.TYPE);
MlMetadata currentMetadata = currentState.getMetaData().custom(MlMetadata.TYPE);
PersistentTasksCustomMetaData persistentTasks =
state.getMetaData().custom(PersistentTasksCustomMetaData.TYPE);
currentState.getMetaData().custom(PersistentTasksCustomMetaData.TYPE);
MlMetadata newMetadata = new MlMetadata.Builder(currentMetadata)
.removeDatafeed(request.getDatafeedId(), persistentTasks).build();
return ClusterState.builder(state).metaData(
return ClusterState.builder(currentState).metaData(
MetaData.builder(currentState.getMetaData()).putCustom(MlMetadata.TYPE, newMetadata).build())
.build();
}

View File

@ -160,9 +160,9 @@ public class UpdateDatafeedAction extends Action<UpdateDatafeedAction.Request, P
@Override
public ClusterState execute(ClusterState currentState) throws Exception {
DatafeedUpdate update = request.getUpdate();
MlMetadata currentMetadata = state.getMetaData().custom(MlMetadata.TYPE);
MlMetadata currentMetadata = currentState.getMetaData().custom(MlMetadata.TYPE);
PersistentTasksCustomMetaData persistentTasks =
state.getMetaData().custom(PersistentTasksCustomMetaData.TYPE);
currentState.getMetaData().custom(PersistentTasksCustomMetaData.TYPE);
MlMetadata newMetadata = new MlMetadata.Builder(currentMetadata)
.updateDatafeed(update, persistentTasks).build();
updatedDatafeed = newMetadata.getDatafeed(update.getId());

View File

@ -33,7 +33,6 @@ import org.elasticsearch.xpack.ml.job.config.JobUpdate;
import org.elasticsearch.xpack.ml.job.messages.Messages;
import org.elasticsearch.xpack.ml.job.persistence.AnomalyDetectorsIndex;
import org.elasticsearch.xpack.ml.job.persistence.JobProvider;
import org.elasticsearch.xpack.ml.job.persistence.JobResultsPersister;
import org.elasticsearch.xpack.ml.job.persistence.JobStorageDeletionTask;
import org.elasticsearch.xpack.ml.job.process.autodetect.state.ModelSnapshot;
import org.elasticsearch.xpack.ml.notifications.Auditor;