@Override public void close() throws IOException { logger.debug("Closing Elasticsearch client manager"); if (bulkProcessor != null) { try { bulkProcessor.awaitClose(30, TimeUnit.SECONDS); } catch (InterruptedException e) { logger.warn("Did not succeed in closing the bulk processor for documents", e); throw new IOException(e); } } if (threadPool != null) { threadPool.shutdownNow(); } if (lowLevelClient != null) { lowLevelClient.close(); } }
/** * Returns <code>true</code> if the given pool was terminated successfully. If the termination timed out, * the service is <code>null</code> this method will return <code>false</code>. */ public static boolean terminate(ThreadPool pool, long timeout, TimeUnit timeUnit) { if (pool != null) { try { pool.shutdown(); if (awaitTermination(pool, timeout, timeUnit)) { return true; } // last resort pool.shutdownNow(); return awaitTermination(pool, timeout, timeUnit); } finally { IOUtils.closeWhileHandlingException(pool); } } return false; }
toClose.add(() -> injector.getInstance(ThreadPool.class).shutdownNow()); toClose.add(() -> stopWatch.stop());
@Override public void close() throws IOException { logger.debug("Closing Elasticsearch client manager"); if (bulkProcessor != null) { try { bulkProcessor.awaitClose(30, TimeUnit.SECONDS); } catch (InterruptedException e) { logger.warn("Did not succeed in closing the bulk processor for documents", e); throw new IOException(e); } } if (threadPool != null) { threadPool.shutdownNow(); } if (lowLevelClient != null) { lowLevelClient.close(); } }
/** * Returns <code>true</code> if the given pool was terminated successfully. If the termination timed out, * the service is <code>null</code> this method will return <code>false</code>. */ public static boolean terminate(ThreadPool pool, long timeout, TimeUnit timeUnit) { if (pool != null) { pool.shutdown(); try { if (pool.awaitTermination(timeout, timeUnit)) { return true; } } catch (InterruptedException e) { Thread.currentThread().interrupt(); } // last resort pool.shutdownNow(); } return false; }
/** * Returns <code>true</code> if the given pool was terminated successfully. If the termination timed out, * the service is <code>null</code> this method will return <code>false</code>. */ public static boolean terminate(ThreadPool pool, long timeout, TimeUnit timeUnit) { if (pool != null) { try { pool.shutdown(); if (awaitTermination(pool, timeout, timeUnit)) return true; // last resort pool.shutdownNow(); return awaitTermination(pool, timeout, timeUnit); } finally { IOUtils.closeWhileHandlingException(pool); } } return false; }
/** * Returns <code>true</code> if the given pool was terminated successfully. If the termination timed out, * the service is <code>null</code> this method will return <code>false</code>. */ public static boolean terminate(ThreadPool pool, long timeout, TimeUnit timeUnit) { if (pool != null) { try { pool.shutdown(); if (awaitTermination(pool, timeout, timeUnit)) { return true; } // last resort pool.shutdownNow(); return awaitTermination(pool, timeout, timeUnit); } finally { IOUtils.closeWhileHandlingException(pool); } } return false; }
/** * Returns <code>true</code> if the given pool was terminated successfully. If the termination timed out, * the service is <code>null</code> this method will return <code>false</code>. */ public static boolean terminate(ThreadPool pool, long timeout, TimeUnit timeUnit) { if (pool != null) { try { pool.shutdown(); if (awaitTermination(pool, timeout, timeUnit)) { return true; } // last resort pool.shutdownNow(); return awaitTermination(pool, timeout, timeUnit); } finally { IOUtils.closeWhileHandlingException(pool); } } return false; }
toClose.add(() -> injector.getInstance(ThreadPool.class).shutdownNow()); toClose.add(() -> stopWatch.stop());
toClose.add(() -> injector.getInstance(ThreadPool.class).shutdownNow()); toClose.add(() -> stopWatch.stop());
toClose.add(() -> injector.getInstance(ThreadPool.class).shutdownNow()); toClose.add(() -> stopWatch.stop());
injector.getInstance(ThreadPool.class).shutdownNow(); } catch (Exception e) {
injector.getInstance(ThreadPool.class).shutdownNow(); } catch (Exception e) {
injector.getInstance(ThreadPool.class).shutdownNow(); } catch (Exception e) {