@Test(dataProvider = "getSubmitParams") public void testSubmit(int poolSize, int poolBufferSize, int extra) throws Exception { final TaskCommandExecutorService service = new TaskCommandExecutorService( poolSize, poolSize, 0L, TimeUnit.MILLISECONDS, new ArrayBlockingQueue<Runnable>(poolBufferSize), new ThreadFactoryBuilder().setNameFormat("BackendWorker" + "-%d").build() ); CountDownLatch countDownLatch = new CountDownLatch(1); TestTaskCommand[] commands = startCommands(service, poolSize + poolBufferSize, countDownLatch); TestTaskCommand[] extraCommands = startCommands(service, extra, null); countDownLatch.countDown(); assertThat(getFailureCount(commands), is(0)); assertThat(getFailureCount(extraCommands), is(extra)); }
public Future<?> submit(TaskCommand task) throws ExternalException { try { return super.submit(task); } catch (RejectedExecutionException e) { logger.error("Fail to acquire ThreadPool worker", e); OutOfThreadPoolWorkerException ex = new OutOfThreadPoolWorkerException(); task.markAllStepsAsFailed(ex); throw ex; } }
TaskCommandExecutorService extends ThreadPoolExecutor { public Future<?> submit(TaskCommand task) throws ExternalException { try { return super.submit(task); } catch (RejectedExecutionException e) { logger.error("Fail to acquire ThreadPool worker", e); OutOfThreadPoolWorkerException ex = new OutOfThreadPoolWorkerException(); task.markAllStepsAsFailed(ex); throw ex; } } }
TaskCommandExecutorService extends ThreadPoolExecutor { public Future<?> submit(TaskCommand task) throws ExternalException { try { return super.submit(task); } catch (RejectedExecutionException e) { logger.error("Fail to acquire ThreadPool worker", e); OutOfThreadPoolWorkerException ex = new OutOfThreadPoolWorkerException(); task.markAllStepsAsFailed(ex); throw ex; } } TaskCommandExecutorService(int corePoolSize,
                                    int maximumPoolSize,
                                    long keepAliveTime,
                                    TimeUnit unit,
                                    BlockingQueue<Runnable> workQueue,
                                    ThreadFactory threadFactory); }
TaskCommandExecutorService extends ThreadPoolExecutor { public Future<?> submit(TaskCommand task) throws ExternalException { try { return super.submit(task); } catch (RejectedExecutionException e) { logger.error("Fail to acquire ThreadPool worker", e); OutOfThreadPoolWorkerException ex = new OutOfThreadPoolWorkerException(); task.markAllStepsAsFailed(ex); throw ex; } } TaskCommandExecutorService(int corePoolSize,
                                    int maximumPoolSize,
                                    long keepAliveTime,
                                    TimeUnit unit,
                                    BlockingQueue<Runnable> workQueue,
                                    ThreadFactory threadFactory); Future<?> submit(TaskCommand task); }
TaskCommandExecutorService extends ThreadPoolExecutor { public Future<?> submit(TaskCommand task) throws ExternalException { try { return super.submit(task); } catch (RejectedExecutionException e) { logger.error("Fail to acquire ThreadPool worker", e); OutOfThreadPoolWorkerException ex = new OutOfThreadPoolWorkerException(); task.markAllStepsAsFailed(ex); throw ex; } } TaskCommandExecutorService(int corePoolSize,
                                    int maximumPoolSize,
                                    long keepAliveTime,
                                    TimeUnit unit,
                                    BlockingQueue<Runnable> workQueue,
                                    ThreadFactory threadFactory); Future<?> submit(TaskCommand task);  }