@Override public void shutdown() { if (_luceneIndexThreadPoolExecutor != null) { _luceneIndexThreadPoolExecutor.shutdownNow(); try { _luceneIndexThreadPoolExecutor.awaitTermination(60, TimeUnit.SECONDS); } catch (InterruptedException ie) { _log.error("Lucene indexer shutdown interrupted", ie); } } if (isLoadIndexFromClusterEnabled()) { ClusterExecutorUtil.removeClusterEventListener(_loadIndexClusterEventListener); } MessageBus messageBus = MessageBusUtil.getMessageBus(); for (String searchEngineId : SearchEngineUtil.getSearchEngineIds()) { String searchWriterDestinationName = SearchEngineUtil.getSearchWriterDestinationName(searchEngineId); Destination searchWriteDestination = messageBus.getDestination(searchWriterDestinationName); if (searchWriteDestination != null) { ThreadPoolExecutor threadPoolExecutor = PortalExecutorManagerUtil.getPortalExecutor(searchWriterDestinationName); int maxPoolSize = threadPoolExecutor.getMaxPoolSize(); CountDownLatch countDownLatch = new CountDownLatch(maxPoolSize); ShutdownSyncJob shutdownSyncJob = new ShutdownSyncJob(countDownLatch); for (int i = 0; i < maxPoolSize; i++) { threadPoolExecutor.submit(shutdownSyncJob); } try { countDownLatch.await(); } catch (InterruptedException ie) { _log.error("Shutdown waiting interrupted", ie); } List<Runnable> runnables = threadPoolExecutor.shutdownNow(); if (_log.isDebugEnabled()) { _log.debug("Cancelled appending indexing jobs: " + runnables); } searchWriteDestination.close(true); } } for (IndexAccessor indexAccessor : _indexAccessors.values()) { indexAccessor.close(); } }