@Override public synchronized void deleteIndex(String index, String reason) throws ElasticSearchException {
deleteIndex(index, true, reason, null);
}
private void deleteIndex(String index, boolean delete, String reason, @Nullable Executor executor) throws ElasticSearchException {
Injector indexInjector;
IndexService indexService;
synchronized (this) {
indexInjector = indicesInjectors.remove(index);
if (indexInjector == null) {
if (!delete) {
return;
}
throw new IndexMissingException(new Index(index));
}
if (delete) {
logger.debug("deleting Index [{}]", index);
}
Map<String, IndexService> tmpMap = newHashMap(indices);
indexService = tmpMap.remove(index);
indices = ImmutableMap.copyOf(tmpMap);
}
indicesLifecycle.beforeIndexClosed(indexService, delete);
for (Class<? extends CloseableIndexComponent> closeable : pluginsService.indexServices()) {
indexInjector.getInstance(closeable).close(delete);
}
((InternalIndexService) indexService).close(delete, reason, executor);
indexInjector.getInstance(PercolatorService.class).close();
indexInjector.getInstance(IndexCache.class).close();
indexInjector.getInstance(AnalysisService.class).close();
indexInjector.getInstance(IndexEngine.class).close();
indexInjector.getInstance(IndexServiceManagement.class).close();
indexInjector.getInstance(IndexGateway.class).close(delete);
indexInjector.getInstance(MapperService.class).close();
indexInjector.getInstance(IndexQueryParserService.class).close();
Injectors.close(injector);
indicesLifecycle.afterIndexClosed(indexService.index(), delete);