[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:
parent
435338e6b9
commit
5a70eac6e8
|
@ -169,12 +169,12 @@ public class DeleteDatafeedAction extends Action<DeleteDatafeedAction.Request, D
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public ClusterState execute(ClusterState currentState) throws Exception {
|
public ClusterState execute(ClusterState currentState) throws Exception {
|
||||||
MlMetadata currentMetadata = state.getMetaData().custom(MlMetadata.TYPE);
|
MlMetadata currentMetadata = currentState.getMetaData().custom(MlMetadata.TYPE);
|
||||||
PersistentTasksCustomMetaData persistentTasks =
|
PersistentTasksCustomMetaData persistentTasks =
|
||||||
state.getMetaData().custom(PersistentTasksCustomMetaData.TYPE);
|
currentState.getMetaData().custom(PersistentTasksCustomMetaData.TYPE);
|
||||||
MlMetadata newMetadata = new MlMetadata.Builder(currentMetadata)
|
MlMetadata newMetadata = new MlMetadata.Builder(currentMetadata)
|
||||||
.removeDatafeed(request.getDatafeedId(), persistentTasks).build();
|
.removeDatafeed(request.getDatafeedId(), persistentTasks).build();
|
||||||
return ClusterState.builder(state).metaData(
|
return ClusterState.builder(currentState).metaData(
|
||||||
MetaData.builder(currentState.getMetaData()).putCustom(MlMetadata.TYPE, newMetadata).build())
|
MetaData.builder(currentState.getMetaData()).putCustom(MlMetadata.TYPE, newMetadata).build())
|
||||||
.build();
|
.build();
|
||||||
}
|
}
|
||||||
|
|
|
@ -160,9 +160,9 @@ public class UpdateDatafeedAction extends Action<UpdateDatafeedAction.Request, P
|
||||||
@Override
|
@Override
|
||||||
public ClusterState execute(ClusterState currentState) throws Exception {
|
public ClusterState execute(ClusterState currentState) throws Exception {
|
||||||
DatafeedUpdate update = request.getUpdate();
|
DatafeedUpdate update = request.getUpdate();
|
||||||
MlMetadata currentMetadata = state.getMetaData().custom(MlMetadata.TYPE);
|
MlMetadata currentMetadata = currentState.getMetaData().custom(MlMetadata.TYPE);
|
||||||
PersistentTasksCustomMetaData persistentTasks =
|
PersistentTasksCustomMetaData persistentTasks =
|
||||||
state.getMetaData().custom(PersistentTasksCustomMetaData.TYPE);
|
currentState.getMetaData().custom(PersistentTasksCustomMetaData.TYPE);
|
||||||
MlMetadata newMetadata = new MlMetadata.Builder(currentMetadata)
|
MlMetadata newMetadata = new MlMetadata.Builder(currentMetadata)
|
||||||
.updateDatafeed(update, persistentTasks).build();
|
.updateDatafeed(update, persistentTasks).build();
|
||||||
updatedDatafeed = newMetadata.getDatafeed(update.getId());
|
updatedDatafeed = newMetadata.getDatafeed(update.getId());
|
||||||
|
|
|
@ -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.messages.Messages;
|
||||||
import org.elasticsearch.xpack.ml.job.persistence.AnomalyDetectorsIndex;
|
import org.elasticsearch.xpack.ml.job.persistence.AnomalyDetectorsIndex;
|
||||||
import org.elasticsearch.xpack.ml.job.persistence.JobProvider;
|
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.persistence.JobStorageDeletionTask;
|
||||||
import org.elasticsearch.xpack.ml.job.process.autodetect.state.ModelSnapshot;
|
import org.elasticsearch.xpack.ml.job.process.autodetect.state.ModelSnapshot;
|
||||||
import org.elasticsearch.xpack.ml.notifications.Auditor;
|
import org.elasticsearch.xpack.ml.notifications.Auditor;
|
||||||
|
|
Loading…
Reference in New Issue