From eda2f15b44bf9ec6e29637210e514c9d29f8cb69 Mon Sep 17 00:00:00 2001 From: Dimitris Athanasiou Date: Wed, 22 Feb 2017 22:14:32 +0000 Subject: [PATCH] [ML] Remove deprecated use of TransportDeleteAction (elastic/x-pack-elasticsearch#628) Original commit: elastic/x-pack-elasticsearch@b5fdb32a0cfa22c5e4c419a7734f06a533961041 --- .../xpack/ml/action/DeleteFilterAction.java | 19 +++++++++++-------- 1 file changed, 11 insertions(+), 8 deletions(-) diff --git a/plugin/src/main/java/org/elasticsearch/xpack/ml/action/DeleteFilterAction.java b/plugin/src/main/java/org/elasticsearch/xpack/ml/action/DeleteFilterAction.java index 45962a26b91..60e175232ed 100644 --- a/plugin/src/main/java/org/elasticsearch/xpack/ml/action/DeleteFilterAction.java +++ b/plugin/src/main/java/org/elasticsearch/xpack/ml/action/DeleteFilterAction.java @@ -9,9 +9,10 @@ import org.elasticsearch.ResourceNotFoundException; import org.elasticsearch.action.Action; import org.elasticsearch.action.ActionListener; import org.elasticsearch.action.ActionRequestValidationException; +import org.elasticsearch.action.bulk.BulkRequest; +import org.elasticsearch.action.bulk.BulkResponse; +import org.elasticsearch.action.bulk.TransportBulkAction; import org.elasticsearch.action.delete.DeleteRequest; -import org.elasticsearch.action.delete.DeleteResponse; -import org.elasticsearch.action.delete.TransportDeleteAction; import org.elasticsearch.action.support.ActionFilters; import org.elasticsearch.action.support.master.AcknowledgedRequest; import org.elasticsearch.action.support.master.AcknowledgedResponse; @@ -31,9 +32,9 @@ import org.elasticsearch.common.settings.Settings; import org.elasticsearch.rest.RestStatus; import org.elasticsearch.threadpool.ThreadPool; import org.elasticsearch.transport.TransportService; +import org.elasticsearch.xpack.ml.MlMetadata; import org.elasticsearch.xpack.ml.job.config.Detector; import org.elasticsearch.xpack.ml.job.config.Job; -import org.elasticsearch.xpack.ml.MlMetadata; import org.elasticsearch.xpack.ml.job.config.MlFilter; import org.elasticsearch.xpack.ml.job.persistence.JobProvider; import org.elasticsearch.xpack.ml.utils.ExceptionsHelper; @@ -144,13 +145,13 @@ public class DeleteFilterAction extends Action { - private final TransportDeleteAction transportAction; + private final TransportBulkAction transportAction; @Inject public TransportAction(Settings settings, TransportService transportService, ClusterService clusterService, ThreadPool threadPool, ActionFilters actionFilters, IndexNameExpressionResolver indexNameExpressionResolver, - TransportDeleteAction transportAction) { + TransportBulkAction transportAction) { super(settings, DeleteFilterAction.NAME, transportService, clusterService, threadPool, actionFilters, indexNameExpressionResolver, Request::new); this.transportAction = transportAction; @@ -188,10 +189,12 @@ public class DeleteFilterAction extends Action() { + BulkRequest bulkRequest = new BulkRequest(); + bulkRequest.add(deleteRequest); + transportAction.execute(bulkRequest, new ActionListener() { @Override - public void onResponse(DeleteResponse deleteResponse) { - if (deleteResponse.status().equals(RestStatus.NOT_FOUND)) { + public void onResponse(BulkResponse bulkResponse) { + if (bulkResponse.getItems()[0].status() == RestStatus.NOT_FOUND) { listener.onFailure(new ResourceNotFoundException("Could not delete filter with ID [" + filterId + "] because it does not exist")); } else {