/** {@inheritDoc} */ @Override public boolean isTerminating() { return exec instanceof ThreadPoolExecutor && ((ThreadPoolExecutor) exec).isTerminating(); }
@Override public boolean isTerminating() { return executor.isTerminating(); }
@Override public void rejectedExecution(Runnable r, ThreadPoolExecutor e) { String msg = String.format("Thread pool is EXHAUSTED!" + " Thread Name: %s, Pool Size: %d (active: %d, core: %d, max: %d, largest: %d), Task: %d (completed: %d)," + " Executor status:(isShutdown:%s, isTerminated:%s, isTerminating:%s), in %s://%s:%d!", threadName, e.getPoolSize(), e.getActiveCount(), e.getCorePoolSize(), e.getMaximumPoolSize(), e.getLargestPoolSize(), e.getTaskCount(), e.getCompletedTaskCount(), e.isShutdown(), e.isTerminated(), e.isTerminating(), url.getProtocol(), url.getIp(), url.getPort()); logger.warn(msg); dumpJStack(); throw new RejectedExecutionException(msg); }
@Override public void rejectedExecution(Runnable r, ThreadPoolExecutor e) { String msg = String.format("Thread pool is EXHAUSTED!" + " Thread Name: %s, Pool Size: %d (active: %d, core: %d, max: %d, largest: %d), Task: %d (completed: %d)," + " Executor status:(isShutdown:%s, isTerminated:%s, isTerminating:%s), in %s://%s:%d!", threadName, e.getPoolSize(), e.getActiveCount(), e.getCorePoolSize(), e.getMaximumPoolSize(), e.getLargestPoolSize(), e.getTaskCount(), e.getCompletedTaskCount(), e.isShutdown(), e.isTerminated(), e.isTerminating(), url.getProtocol(), url.getIp(), url.getPort()); logger.warn(msg); dumpJStack(); throw new RejectedExecutionException(msg); }
@Override public void rejectedExecution(Runnable r, ThreadPoolExecutor e) { String msg = String.format( "Thread pool is EXHAUSTED!" + " Thread Name: %s, Pool Size: %d (active: %d, core: %d, max: %d, largest: %d), Task: %d (completed: %d)," + " Executor status:(isShutdown:%s, isTerminated:%s, isTerminating:%s)!", threadName, e.getPoolSize(), e.getActiveCount(), e.getCorePoolSize(), e.getMaximumPoolSize(), e.getLargestPoolSize(), e.getTaskCount(), e.getCompletedTaskCount(), e.isShutdown(), e.isTerminated(), e.isTerminating()); logger.warn(msg); dummper.tryThreadDump(null); throw new RejectedExecutionException(msg); }
@Override public void run() { try { decompiler.getArgs().setRootDir(dir); ThreadPoolExecutor ex = (ThreadPoolExecutor) decompiler.getSaveExecutor(); ex.shutdown(); while (ex.isTerminating()) { long total = ex.getTaskCount(); long done = ex.getCompletedTaskCount(); progressMonitor.setProgress((int) (done * 100.0 / (double) total)); Thread.sleep(500); } progressMonitor.close(); LOG.info("decompilation complete, freeing memory ..."); decompiler.getClasses().forEach(JavaClass::unload); LOG.info("done"); } catch (InterruptedException e) { LOG.error("Save interrupted", e); Thread.currentThread().interrupt(); } } };
if (connectionService.isTerminating()) { return;
static synchronized ThreadPoolExecutor getExecutor(ThreadPoolBuilder builder, Map<String, Object> poolCache) { ThreadPoolExecutor pool = (ThreadPoolExecutor) poolCache.get(builder.getName()); if (pool == null || pool.isTerminating() || pool.isShutdown()) { pool = getDefaultExecutor(builder); LOG.info("Creating new pool for " + builder.getName()); poolCache.put(builder.getName(), pool); } ((ShutdownOnUnusedThreadPoolExecutor) pool).addReference(); return pool; }
static synchronized ThreadPoolExecutor getExecutor(ThreadPoolBuilder builder, Map<String, Object> poolCache) { ThreadPoolExecutor pool = (ThreadPoolExecutor) poolCache.get(builder.getName()); if (pool == null || pool.isTerminating() || pool.isShutdown()) { pool = getDefaultExecutor(builder); LOG.info("Creating new pool for " + builder.getName()); poolCache.put(builder.getName(), pool); } ((ShutdownOnUnusedThreadPoolExecutor) pool).addReference(); return pool; }
@Override public void rejectedExecution(Runnable r, ThreadPoolExecutor e) { String msg = String.format("Thread pool is EXHAUSTED!" + " Thread Name: %s, Pool Size: %d (active: %d, core: %d, max: %d, largest: %d), Task: %d (completed: %d)," + " Executor status:(isShutdown:%s, isTerminated:%s, isTerminating:%s), in %s://%s:%d!", threadName, e.getPoolSize(), e.getActiveCount(), e.getCorePoolSize(), e.getMaximumPoolSize(), e.getLargestPoolSize(), e.getTaskCount(), e.getCompletedTaskCount(), e.isShutdown(), e.isTerminated(), e.isTerminating(), url.getProtocol(), url.getIp(), url.getPort()); logger.warn(msg); dumpJStack(); throw new RejectedExecutionException(msg); }
@Override public void run() { while (!executor.isTerminating()) { try { FileSystemManager vfs = AccumuloVFSClassLoader.generateVfs();
@Test public void testShutdownWithReferencesDoesNotStopExecutor() throws Exception { Map<String, Object> cache = new HashMap<String, Object>(); ThreadPoolBuilder builder = new ThreadPoolBuilder(name.getTableNameString(), new Configuration(false)); ThreadPoolExecutor exec = ThreadPoolManager.getExecutor(builder, cache); assertNotNull("Got a null exector from the pool!", exec); ThreadPoolExecutor exec2 = ThreadPoolManager.getExecutor(builder, cache); assertTrue("Should have gotten the same executor", exec2 == exec); exec.shutdown(); assertFalse("Executor is shutting down, even though we have a live reference!", exec.isShutdown() || exec.isTerminating()); exec2.shutdown(); // wait 5 minutes for thread pool to shutdown assertTrue("Executor is NOT shutting down, after releasing live reference!", exec.awaitTermination(300, TimeUnit.SECONDS)); }
@Test public void testShutdownWithReferencesDoesNotStopExecutor() throws Exception { Map<String, Object> cache = new HashMap<String, Object>(); ThreadPoolBuilder builder = new ThreadPoolBuilder(name.getTableNameString(), new Configuration(false)); ThreadPoolExecutor exec = ThreadPoolManager.getExecutor(builder, cache); assertNotNull("Got a null exector from the pool!", exec); ThreadPoolExecutor exec2 = ThreadPoolManager.getExecutor(builder, cache); assertTrue("Should have gotten the same executor", exec2 == exec); exec.shutdown(); assertFalse("Executor is shutting down, even though we have a live reference!", exec.isShutdown() || exec.isTerminating()); exec2.shutdown(); // wait 5 minutes for thread pool to shutdown assertTrue("Executor is NOT shutting down, after releasing live reference!", exec.awaitTermination(300, TimeUnit.SECONDS)); }
/** {@inheritDoc} */ @Override public boolean isTerminating() { assert exec != null; return exec instanceof ThreadPoolExecutor && ((ThreadPoolExecutor) exec).isTerminating(); }
public static QueueState get(final ThreadPoolExecutor executor) { if (executor.isShutdown()) { return QueueState.SHUTDOWN; } if (executor.isTerminating()) { return QueueState.TERMINATING; } if (executor.isShutdown()) { return QueueState.TERMINATED; } return QueueState.ACTIVE; }
if (_executor != null && !_executor.isTerminating() && !_executor.isShutdown()) _executor.shutdownNow();
@Override public void rejectedExecution(final Runnable r, final ThreadPoolExecutor tpe) { if (null == r || null == tpe || tpe.isShutdown() || tpe.isTerminated() || tpe.isTerminating()) { return; } try { tpe.getQueue().offer(r, 20, TimeUnit.SECONDS); } catch (InterruptedException e) { //Ignore } } });
public boolean isTerminating() throws NotFoundException { ThreadPoolExecutor executorService = getThreadPoolExecutor(getName(), ThreadPoolExecutor.class); return executorService.isTerminating(); }
@Override public void rejectedExecution(Runnable r, ThreadPoolExecutor e) { String msg = String.format("Thread pool is EXHAUSTED!" + " Thread Name: %s, Pool Size: %d (active: %d, core: %d, max: %d, largest: %d), Task: %d (completed: %d)," + " Executor status:(isShutdown:%s, isTerminated:%s, isTerminating:%s), in %s://%s:%d!" , threadName, e.getPoolSize(), e.getActiveCount(), e.getCorePoolSize(), e.getMaximumPoolSize(), e.getLargestPoolSize(), e.getTaskCount(), e.getCompletedTaskCount(), e.isShutdown(), e.isTerminated(), e.isTerminating(), url.getProtocol(), url.getIp(), url.getPort()); logger.warn(msg); throw new RejectedExecutionException(msg); }
@Override public void rejectedExecution(Runnable r, ThreadPoolExecutor e) { String msg = String.format("Thread pool is EXHAUSTED!" + " Thread Name: %s, Pool Size: %d (active: %d, core: %d, max: %d, largest: %d), Task: %d (completed: %d)," + " Executor status:(isShutdown:%s, isTerminated:%s, isTerminating:%s), in %s://%s:%d!", threadName, e.getPoolSize(), e.getActiveCount(), e.getCorePoolSize(), e.getMaximumPoolSize(), e.getLargestPoolSize(), e.getTaskCount(), e.getCompletedTaskCount(), e.isShutdown(), e.isTerminated(), e.isTerminating(), url.getProtocol(), url.getIp(), url.getPort()); logger.warn(msg); dumpJStack(); throw new RejectedExecutionException(msg); }