From f8569ca3537522b00848356df9079af8eb1fe89e Mon Sep 17 00:00:00 2001 From: Martijn van Groningen Date: Tue, 22 Nov 2016 12:08:52 +0100 Subject: [PATCH] no need to check if an index exists (and then fail) prior to removing, the delete index api will return an index not found error if that index has already been removed Original commit: elastic/x-pack-elasticsearch@52000532bef0e99640b1757c9e5a127de3772623 --- .../job/persistence/ElasticsearchJobProvider.java | 15 --------------- 1 file changed, 15 deletions(-) diff --git a/elasticsearch/src/main/java/org/elasticsearch/xpack/prelert/job/persistence/ElasticsearchJobProvider.java b/elasticsearch/src/main/java/org/elasticsearch/xpack/prelert/job/persistence/ElasticsearchJobProvider.java index d89908cefe3..3971dec549f 100644 --- a/elasticsearch/src/main/java/org/elasticsearch/xpack/prelert/job/persistence/ElasticsearchJobProvider.java +++ b/elasticsearch/src/main/java/org/elasticsearch/xpack/prelert/job/persistence/ElasticsearchJobProvider.java @@ -18,7 +18,6 @@ import org.elasticsearch.action.admin.indices.create.CreateIndexResponse; import org.elasticsearch.action.admin.indices.delete.DeleteIndexRequest; import org.elasticsearch.action.admin.indices.delete.DeleteIndexResponse; import org.elasticsearch.action.admin.indices.exists.indices.IndicesExistsRequest; -import org.elasticsearch.action.admin.indices.exists.indices.IndicesExistsResponse; import org.elasticsearch.action.get.GetResponse; import org.elasticsearch.action.search.SearchRequestBuilder; import org.elasticsearch.action.search.SearchResponse; @@ -186,16 +185,6 @@ public class ElasticsearchJobProvider implements JobProvider } } - private boolean indexExists(String jobId) - { - String indexName = ElasticsearchPersister.getJobIndexName(jobId); - LOGGER.trace("ES API CALL: index exists? " + indexName); - IndicesExistsResponse res = - client.admin().indices().exists(new IndicesExistsRequest(indexName)).actionGet(); - - return res.isExists(); - } - /** * Build the Elasticsearch index settings that we want to apply to Prelert * indexes. It's better to do this in code rather than in elasticsearch.yml @@ -283,10 +272,6 @@ public class ElasticsearchJobProvider implements JobProvider @Override public void deleteJobRelatedIndices(String jobId, ActionListener listener) { - if (indexExists(jobId) == false) { - listener.onFailure(ExceptionsHelper.missingJobException(jobId)); - return; - } String indexName = ElasticsearchPersister.getJobIndexName(jobId); LOGGER.trace("ES API CALL: delete index " + indexName);