[ML] Remove dead delete job index code
Original commit: elastic/x-pack-elasticsearch@533b2a0207
This commit is contained in:
parent
72f7698647
commit
b06ce7e7c1
|
@ -13,7 +13,6 @@ import org.elasticsearch.ResourceAlreadyExistsException;
|
||||||
import org.elasticsearch.ResourceNotFoundException;
|
import org.elasticsearch.ResourceNotFoundException;
|
||||||
import org.elasticsearch.action.ActionListener;
|
import org.elasticsearch.action.ActionListener;
|
||||||
import org.elasticsearch.action.admin.indices.create.CreateIndexRequest;
|
import org.elasticsearch.action.admin.indices.create.CreateIndexRequest;
|
||||||
import org.elasticsearch.action.admin.indices.delete.DeleteIndexRequest;
|
|
||||||
import org.elasticsearch.action.admin.indices.mapping.put.PutMappingResponse;
|
import org.elasticsearch.action.admin.indices.mapping.put.PutMappingResponse;
|
||||||
import org.elasticsearch.action.get.GetRequest;
|
import org.elasticsearch.action.get.GetRequest;
|
||||||
import org.elasticsearch.action.get.GetResponse;
|
import org.elasticsearch.action.get.GetResponse;
|
||||||
|
@ -51,7 +50,6 @@ import org.elasticsearch.search.sort.FieldSortBuilder;
|
||||||
import org.elasticsearch.search.sort.SortBuilder;
|
import org.elasticsearch.search.sort.SortBuilder;
|
||||||
import org.elasticsearch.search.sort.SortBuilders;
|
import org.elasticsearch.search.sort.SortBuilders;
|
||||||
import org.elasticsearch.search.sort.SortOrder;
|
import org.elasticsearch.search.sort.SortOrder;
|
||||||
import org.elasticsearch.xpack.ml.action.DeleteJobAction;
|
|
||||||
import org.elasticsearch.xpack.ml.action.util.QueryPage;
|
import org.elasticsearch.xpack.ml.action.util.QueryPage;
|
||||||
import org.elasticsearch.xpack.ml.job.config.Job;
|
import org.elasticsearch.xpack.ml.job.config.Job;
|
||||||
import org.elasticsearch.xpack.ml.job.config.MlFilter;
|
import org.elasticsearch.xpack.ml.job.config.MlFilter;
|
||||||
|
@ -223,23 +221,6 @@ public class JobProvider {
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* Delete all the job related documents from the database.
|
|
||||||
*/
|
|
||||||
// TODO: should live together with createJobRelatedIndices (in case it moves)?
|
|
||||||
public void deleteJobRelatedIndices(String jobId, ActionListener<DeleteJobAction.Response> listener) {
|
|
||||||
String indexName = AnomalyDetectorsIndex.jobResultsAliasedName(jobId);
|
|
||||||
LOGGER.trace("ES API CALL: delete index {}", indexName);
|
|
||||||
|
|
||||||
try {
|
|
||||||
DeleteIndexRequest deleteIndexRequest = new DeleteIndexRequest(indexName);
|
|
||||||
client.admin().indices().delete(deleteIndexRequest,
|
|
||||||
ActionListener.wrap(r -> listener.onResponse(new DeleteJobAction.Response(r.isAcknowledged())), listener::onFailure));
|
|
||||||
} catch (Exception e) {
|
|
||||||
listener.onFailure(e);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get the job's data counts
|
* Get the job's data counts
|
||||||
*
|
*
|
||||||
|
|
|
@ -280,46 +280,6 @@ public class JobProviderTests extends ESTestCase {
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
public void testDeleteJobRelatedIndices() throws InterruptedException, ExecutionException, IOException {
|
|
||||||
@SuppressWarnings("unchecked")
|
|
||||||
ActionListener<DeleteJobAction.Response> actionListener = mock(ActionListener.class);
|
|
||||||
String jobId = "ThisIsMyJob";
|
|
||||||
MockClientBuilder clientBuilder = new MockClientBuilder(CLUSTER_NAME).addClusterStatusYellowResponse();
|
|
||||||
Client client = clientBuilder.build();
|
|
||||||
JobProvider provider = createProvider(client);
|
|
||||||
clientBuilder.resetIndices();
|
|
||||||
clientBuilder.addIndicesExistsResponse(AnomalyDetectorsIndex.jobResultsAliasedName(jobId), true)
|
|
||||||
.addIndicesDeleteResponse(AnomalyDetectorsIndex.jobResultsAliasedName(jobId), true,
|
|
||||||
false, actionListener);
|
|
||||||
clientBuilder.build();
|
|
||||||
|
|
||||||
provider.deleteJobRelatedIndices(jobId, actionListener);
|
|
||||||
|
|
||||||
ArgumentCaptor<DeleteJobAction.Response> responseCaptor = ArgumentCaptor.forClass(DeleteJobAction.Response.class);
|
|
||||||
verify(actionListener).onResponse(responseCaptor.capture());
|
|
||||||
assertTrue(responseCaptor.getValue().isAcknowledged());
|
|
||||||
}
|
|
||||||
|
|
||||||
public void testDeleteJobRelatedIndices_InvalidIndex() throws InterruptedException, ExecutionException, IOException {
|
|
||||||
@SuppressWarnings("unchecked")
|
|
||||||
ActionListener<DeleteJobAction.Response> actionListener = mock(ActionListener.class);
|
|
||||||
String jobId = "ThisIsMyJob";
|
|
||||||
MockClientBuilder clientBuilder = new MockClientBuilder(CLUSTER_NAME).addClusterStatusYellowResponse();
|
|
||||||
Client client = clientBuilder.build();
|
|
||||||
JobProvider provider = createProvider(client);
|
|
||||||
clientBuilder.resetIndices();
|
|
||||||
clientBuilder.addIndicesExistsResponse(AnomalyDetectorsIndex.jobResultsAliasedName(jobId), true)
|
|
||||||
.addIndicesDeleteResponse(AnomalyDetectorsIndex.jobResultsAliasedName(jobId), true,
|
|
||||||
true, actionListener);
|
|
||||||
clientBuilder.build();
|
|
||||||
|
|
||||||
provider.deleteJobRelatedIndices(jobId, actionListener);
|
|
||||||
|
|
||||||
ArgumentCaptor<Exception> exceptionCaptor = ArgumentCaptor.forClass(Exception.class);
|
|
||||||
verify(actionListener).onFailure(exceptionCaptor.capture());
|
|
||||||
assertThat(exceptionCaptor.getValue(), instanceOf(InterruptedException.class));
|
|
||||||
}
|
|
||||||
|
|
||||||
public void testBuckets_OneBucketNoInterim()
|
public void testBuckets_OneBucketNoInterim()
|
||||||
throws InterruptedException, ExecutionException, IOException {
|
throws InterruptedException, ExecutionException, IOException {
|
||||||
String jobId = "TestJobIdentification";
|
String jobId = "TestJobIdentification";
|
||||||
|
|
Loading…
Reference in New Issue