@Test public void exceptionThrownIfControllerRejects() throws Exception { try { when(guardRail.acquirePermits(eq(1L), anyLong())).thenThrow(new RejectedException(Rejected .MAX_CONCURRENCY_LEVEL_EXCEEDED)); service.submit(TestCallable.success(), Long.MAX_VALUE); fail(); } catch (RejectedException e) { assertEquals(Rejected.MAX_CONCURRENCY_LEVEL_EXCEEDED, e.reason); } try { when(guardRail.acquirePermits(eq(1L), anyLong())).thenThrow(new RejectedException(Rejected.CIRCUIT_OPEN)); service.submit(TestCallable.success(), Long.MAX_VALUE); fail(); } catch (RejectedException e) { assertEquals(Rejected.CIRCUIT_OPEN, e.reason); } }
public <T> PrecipiceFuture<TimeoutableResult, T> submit(Callable<T> callable) { PrecipicePromise<TimeoutableResult, T> promise = Asynchronous.acquirePermitsAndPromise(guardRail, 1L); internalComplete(callable, promise); return promise.future(); }
ThreadPoolService implements Precipice<TimeoutableResult, Rejected> { public <T> PrecipiceFuture<TimeoutableResult, T> submit(Callable<T> callable) { PrecipicePromise<TimeoutableResult, T> promise = Asynchronous.acquirePermitsAndPromise(guardRail, 1L); internalComplete(callable, promise); return promise.future(); } }
ThreadPoolService implements Precipice<TimeoutableResult, Rejected> { public <T> PrecipiceFuture<TimeoutableResult, T> submit(Callable<T> callable) { PrecipicePromise<TimeoutableResult, T> promise = Asynchronous.acquirePermitsAndPromise(guardRail, 1L); internalComplete(callable, promise); return promise.future(); } ThreadPoolService(int poolSize, int queueSize, GuardRail<TimeoutableResult, Rejected> guardRail);  ThreadPoolService(ExecutorService executorService, GuardRail<TimeoutableResult, Rejected> guardRail); }
ThreadPoolService implements Precipice<TimeoutableResult, Rejected> { public <T> PrecipiceFuture<TimeoutableResult, T> submit(Callable<T> callable) { PrecipicePromise<TimeoutableResult, T> promise = Asynchronous.acquirePermitsAndPromise(guardRail, 1L); internalComplete(callable, promise); return promise.future(); } ThreadPoolService(int poolSize, int queueSize, GuardRail<TimeoutableResult, Rejected> guardRail);  ThreadPoolService(ExecutorService executorService, GuardRail<TimeoutableResult, Rejected> guardRail); @Override GuardRail<TimeoutableResult, Rejected> guardRail(); PrecipiceFuture<TimeoutableResult, T> submit(Callable<T> callable); PrecipiceFuture<TimeoutableResult, T> submit(Callable<T> callable, long millisTimeout); void complete(Callable<T> callable, PrecipicePromise<TimeoutableResult, T> promise); void complete(Callable<T> callable, PrecipicePromise<TimeoutableResult, T> promise, long millisTimeout); ExecutorService getExecutor(); DelayQueueTimeoutService getTimeoutService(); void shutdown(); }
ThreadPoolService implements Precipice<TimeoutableResult, Rejected> { public <T> PrecipiceFuture<TimeoutableResult, T> submit(Callable<T> callable) { PrecipicePromise<TimeoutableResult, T> promise = Asynchronous.acquirePermitsAndPromise(guardRail, 1L); internalComplete(callable, promise); return promise.future(); } ThreadPoolService(int poolSize, int queueSize, GuardRail<TimeoutableResult, Rejected> guardRail);  ThreadPoolService(ExecutorService executorService, GuardRail<TimeoutableResult, Rejected> guardRail); @Override GuardRail<TimeoutableResult, Rejected> guardRail(); PrecipiceFuture<TimeoutableResult, T> submit(Callable<T> callable); PrecipiceFuture<TimeoutableResult, T> submit(Callable<T> callable, long millisTimeout); void complete(Callable<T> callable, PrecipicePromise<TimeoutableResult, T> promise); void complete(Callable<T> callable, PrecipicePromise<TimeoutableResult, T> promise, long millisTimeout); ExecutorService getExecutor(); DelayQueueTimeoutService getTimeoutService(); void shutdown();  }