@Override protected void doStop() { ExecutorService indicesStopExecutor = Executors.newFixedThreadPool(5, EsExecutors.daemonThreadFactory(settings, "indices_shutdown")); // Copy indices because we modify it asynchronously in the body of the loop final Set<Index> indices = this.indices.values().stream().map(s -> s.index()).collect(Collectors.toSet()); final CountDownLatch latch = new CountDownLatch(indices.size()); for (final Index index : indices) { indicesStopExecutor.execute(() -> { try { removeIndex(index, IndexRemovalReason.NO_LONGER_ASSIGNED, "shutdown"); } finally { latch.countDown(); } }); } try { if (latch.await(shardsClosedTimeout.seconds(), TimeUnit.SECONDS) == false) { logger.warn("Not all shards are closed yet, waited {}sec - stopping service", shardsClosedTimeout.seconds()); } } catch (InterruptedException e) { // ignore } finally { indicesStopExecutor.shutdown(); } }
indicesService.removeIndex(createdIndex, NO_LONGER_ASSIGNED, " created for parsing template mapping");
indicesService.removeIndex(index, NO_LONGER_ASSIGNED, "created for mapping processing");
/** * Deletes the given index. Persistent parts of the index * like the shards files, state and transaction logs are removed once all resources are released. * * Equivalent to {@link #removeIndex(String, String)} but fires * different lifecycle events to ensure pending resources of this index are immediately removed. * @param index the index to delete * @param reason the high level reason causing this delete */ public void deleteIndex(String index, String reason) throws IOException { removeIndex(index, reason, true); }
} finally { for (Index index : indicesToClose) { indicesService.removeIndex(index, NO_LONGER_ASSIGNED, "created for alias processing");
if (createdIndex != null) { indicesService.removeIndex(createdIndex, removalReason, removalExtraInfo);
private void removeIndex(String index, String reason) { try { indicesService.removeIndex(index, reason); } catch (Throwable e) { logger.warn("failed to clean index ({})", e, reason); } }
@Override protected void doStop() { ExecutorService indicesStopExecutor = Executors.newFixedThreadPool(5, EsExecutors.daemonThreadFactory(settings, "indices_shutdown")); // Copy indices because we modify it asynchronously in the body of the loop final Set<Index> indices = this.indices.values().stream().map(s -> s.index()).collect(Collectors.toSet()); final CountDownLatch latch = new CountDownLatch(indices.size()); for (final Index index : indices) { indicesStopExecutor.execute(() -> { try { removeIndex(index, IndexRemovalReason.NO_LONGER_ASSIGNED, "shutdown"); } finally { latch.countDown(); } }); } try { if (latch.await(shardsClosedTimeout.seconds(), TimeUnit.SECONDS) == false) { logger.warn("Not all shards are closed yet, waited {}sec - stopping service", shardsClosedTimeout.seconds()); } } catch (InterruptedException e) { // ignore } finally { indicesStopExecutor.shutdown(); } }
@Override protected void doStop() { ExecutorService indicesStopExecutor = Executors.newFixedThreadPool(5, EsExecutors.daemonThreadFactory(settings, "indices_shutdown")); // Copy indices because we modify it asynchronously in the body of the loop final Set<Index> indices = this.indices.values().stream().map(s -> s.index()).collect(Collectors.toSet()); final CountDownLatch latch = new CountDownLatch(indices.size()); for (final Index index : indices) { indicesStopExecutor.execute(() -> { try { removeIndex(index, IndexRemovalReason.NO_LONGER_ASSIGNED, "shutdown"); } finally { latch.countDown(); } }); } try { if (latch.await(shardsClosedTimeout.seconds(), TimeUnit.SECONDS) == false) { logger.warn("Not all shards are closed yet, waited {}sec - stopping service", shardsClosedTimeout.seconds()); } } catch (InterruptedException e) { // ignore } finally { indicesStopExecutor.shutdown(); } }
@Override protected void doStop() { ExecutorService indicesStopExecutor = Executors.newFixedThreadPool(5, EsExecutors.daemonThreadFactory("indices_shutdown")); // Copy indices because we modify it asynchronously in the body of the loop final Set<Index> indices = this.indices.values().stream().map(s -> s.index()).collect(Collectors.toSet()); final CountDownLatch latch = new CountDownLatch(indices.size()); for (final Index index : indices) { indicesStopExecutor.execute(() -> { try { removeIndex(index, IndexRemovalReason.NO_LONGER_ASSIGNED, "shutdown"); } finally { latch.countDown(); } }); } try { if (latch.await(shardsClosedTimeout.seconds(), TimeUnit.SECONDS) == false) { logger.warn("Not all shards are closed yet, waited {}sec - stopping service", shardsClosedTimeout.seconds()); } } catch (InterruptedException e) { // ignore } finally { indicesStopExecutor.shutdown(); } }
indicesService.removeIndex(temporaryIndexName, " created for parsing template mapping");
indicesService.removeIndex(createdIndex, NO_LONGER_ASSIGNED, " created for parsing template mapping");
indicesService.removeIndex(createdIndex, NO_LONGER_ASSIGNED, " created for parsing template mapping");
indicesService.removeIndex(createdIndex, NO_LONGER_ASSIGNED, " created for parsing template mapping");
indicesService.removeIndex(index, NO_LONGER_ASSIGNED, "created for mapping processing");
indicesService.removeIndex(index, NO_LONGER_ASSIGNED, "created for mapping processing");
indicesService.removeIndex(index, NO_LONGER_ASSIGNED, "created for mapping processing");
} finally { for (Index index : indicesToClose) { indicesService.removeIndex(index, NO_LONGER_ASSIGNED, "created for alias processing");
} finally { for (String index : indicesToClose) { indicesService.removeIndex(index, "created for mapping processing");
private void removeIndex(String index, String reason, boolean delete) { try { final IndexService indexService; final Injector indexInjector; synchronized (this) { if (indices.containsKey(index) == false) { return; } logger.debug("[{}] closing ... (reason [{}])", index, reason); Map<String, IndexServiceInjectorPair> tmpMap = newHashMap(indices); IndexServiceInjectorPair remove = tmpMap.remove(index); indexService = remove.getIndexService(); indexInjector = remove.getInjector(); indices = ImmutableMap.copyOf(tmpMap); } indicesLifecycle.beforeIndexClosed(indexService); if (delete) { indicesLifecycle.beforeIndexDeleted(indexService); } IOUtils.close(Iterables.transform(pluginsService.indexServices(), new Function<Class<? extends Closeable>, Closeable>() { @Override public Closeable apply(Class<? extends Closeable> input) { return indexInjector.getInstance(input); } })); logger.debug("[{}] closing index service (reason [{}])", index, reason); indexService.close(reason, delete);