/** {@inheritDoc} */ @Override public String getRejectedExecutionHandlerClass() { if (!(exec instanceof ThreadPoolExecutor)) return ""; RejectedExecutionHandler hnd = ((ThreadPoolExecutor)exec).getRejectedExecutionHandler(); return hnd == null ? "" : hnd.getClass().getName(); }
public JBossThreadPoolExecutor(int corePoolSize, int maximumPoolSize, long keepAliveTime, TimeUnit unit, BlockingQueue<Runnable> workQueue, ThreadFactory threadFactory) { super(corePoolSize, maximumPoolSize, keepAliveTime, unit, workQueue, threadFactory); setRejectedExecutionHandler(super.getRejectedExecutionHandler()); }
public JBossThreadPoolExecutor(int corePoolSize, int maximumPoolSize, long keepAliveTime, TimeUnit unit, BlockingQueue<Runnable> workQueue) { super(corePoolSize, maximumPoolSize, keepAliveTime, unit, workQueue); setRejectedExecutionHandler(super.getRejectedExecutionHandler()); }
public RejectedExecutionHandler getRejectedExecutionHandler() { return ((CountingRejectHandler)super.getRejectedExecutionHandler()).getDelegate(); }
protected ThreadPoolExecutor createThreadPool() { ThreadPoolExecutor threadPool=new ThreadPoolExecutor(0, max_pool, pool_thread_keep_alive, TimeUnit.MILLISECONDS, new SynchronousQueue<>()); ThreadFactory factory=new ThreadFactory() { private final AtomicInteger thread_id=new AtomicInteger(1); public Thread newThread(final Runnable command) { return getThreadFactory().newThread(command, "StreamingStateTransfer-sender-" + thread_id.getAndIncrement()); } }; threadPool.setRejectedExecutionHandler(new ShutdownRejectedExecutionHandler(threadPool.getRejectedExecutionHandler())); threadPool.setThreadFactory(factory); return threadPool; }
void setRejectedExecutionHandler( ThreadPoolExecutor p, RejectedExecutionHandler handler) { p.setRejectedExecutionHandler(handler); assertSame(handler, p.getRejectedExecutionHandler()); }
void assertTaskSubmissionsAreRejected(ThreadPoolExecutor p) { final RejectedExecutionHandler savedHandler = p.getRejectedExecutionHandler(); final long savedTaskCount = p.getTaskCount(); final long savedCompletedTaskCount = p.getCompletedTaskCount();
public ThreadPoolStats stats() { List<ThreadPoolStats.Stats> stats = new ArrayList<>(); for (ExecutorHolder holder : executors.values()) { final String name = holder.info.getName(); // no need to have info on "same" thread pool if ("same".equals(name)) { continue; } int threads = -1; int queue = -1; int active = -1; long rejected = -1; int largest = -1; long completed = -1; if (holder.executor() instanceof ThreadPoolExecutor) { ThreadPoolExecutor threadPoolExecutor = (ThreadPoolExecutor) holder.executor(); threads = threadPoolExecutor.getPoolSize(); queue = threadPoolExecutor.getQueue().size(); active = threadPoolExecutor.getActiveCount(); largest = threadPoolExecutor.getLargestPoolSize(); completed = threadPoolExecutor.getCompletedTaskCount(); RejectedExecutionHandler rejectedExecutionHandler = threadPoolExecutor.getRejectedExecutionHandler(); if (rejectedExecutionHandler instanceof XRejectedExecutionHandler) { rejected = ((XRejectedExecutionHandler) rejectedExecutionHandler).rejected(); } } stats.add(new ThreadPoolStats.Stats(name, threads, queue, active, rejected, largest, completed)); } return new ThreadPoolStats(stats); }
/** {@inheritDoc} */ @Override public String getRejectedExecutionHandlerClass() { if (!(exec instanceof ThreadPoolExecutor)) return ""; RejectedExecutionHandler hnd = ((ThreadPoolExecutor)exec).getRejectedExecutionHandler(); return hnd == null ? "" : hnd.getClass().getName(); }
/** {@inheritDoc} */ @Override public String getRejectedExecutionHandlerClass() { assert exec != null; if (!(exec instanceof ThreadPoolExecutor)) return ""; RejectedExecutionHandler hnd = ((ThreadPoolExecutor)exec).getRejectedExecutionHandler(); return hnd == null ? "" : hnd.getClass().getName(); }
private static void logExecutors(String name, ThreadPoolExecutor executor) { System.err.println(String.format("Pool name: %s", name)); System.err.println(String.format(" Core pool size: %d", executor.getCorePoolSize())); System.err.println(String.format(" Maximum pool size: %d", executor.getMaximumPoolSize())); System.err.println(String.format(" Queue size: %d", executor.getQueue().remainingCapacity())); System.err.println(String.format(" Rejection policy: %s", executor.getRejectedExecutionHandler().getClass().getSimpleName())); }
private static void logExecutors(String name, ThreadPoolExecutor executor) { System.err.println(String.format("Pool name: %s", name)); System.err.println(String.format(" Core pool size: %d", executor.getCorePoolSize())); System.err.println(String.format(" Maximum pool size: %d", executor.getMaximumPoolSize())); System.err.println(String.format(" Queue size: %d", executor.getQueue().remainingCapacity())); System.err.println(String.format(" Rejection policy: %s", executor.getRejectedExecutionHandler().getClass().getSimpleName())); }
@Managed public String getRejectedExecutionHandler() { return threadPoolExecutor.getRejectedExecutionHandler().getClass().getName(); }
@Managed public String getRejectedExecutionHandler() { return threadPoolExecutor.getRejectedExecutionHandler().getClass().getName(); }
@Override public String getRejectedExecutionHandler() { final ThreadPoolExecutor executor = getMonitored(); if (executor == null) return null; return executor.getRejectedExecutionHandler().toString(); }
@Managed public String getRejectedExecutionHandler() { return threadPoolExecutor.getRejectedExecutionHandler().getClass().getName(); }
@Override public Long getRejectedTaskCount() { RejectedExecutionHandler rejectedHandler = executor.getRejectedExecutionHandler(); if(rejectedHandler instanceof CountingRejectedExecutionHandler) { return Long.valueOf(((CountingRejectedExecutionHandler)rejectedHandler) .getRejectedTaskCount()); } return null; }
protected ThreadPoolExecutor createThreadPool() { ThreadPoolExecutor threadPool=new ThreadPoolExecutor(0, max_pool, pool_thread_keep_alive, TimeUnit.MILLISECONDS, new SynchronousQueue<Runnable>()); ThreadFactory factory=new ThreadFactory() { private final AtomicInteger thread_id=new AtomicInteger(1); public Thread newThread(final Runnable command) { return getThreadFactory().newThread(command, "StreamingStateTransfer-sender-" + thread_id.getAndIncrement()); } }; threadPool.setRejectedExecutionHandler(new ShutdownRejectedExecutionHandler(threadPool.getRejectedExecutionHandler())); threadPool.setThreadFactory(factory); return threadPool; }
private void addFuture(ManagedFutureTask<?> future) { futures.put(future, Boolean.TRUE); // If already shutdown, reject this task. if (isShutdown()) { service.getRejectedExecutionHandler().rejectedExecution(future, service); } }
/** * @see Scheduler.ShutdownHandler */ @Override protected void setDefaultShutdownHandler( Scheduler.ShutdownHandler handler ) { if ( threadPool instanceof ThreadPoolExecutor ) { ThreadPoolExecutor pool = (ThreadPoolExecutor) threadPool; handler.setRejectedExecutionHandler( pool.getRejectedExecutionHandler() ); pool.setRejectedExecutionHandler( handler ); } }