@Override public SubmitterScheduler makeSubmitterScheduler(int poolSize, boolean prestartIfAvailable) { /* we must honor pool size of one due to how scheduled tasks are handled. Since an extra * task is used for scheduled tasks, execution order may switch if there is more than one * thread. */ SubmitterScheduler scheduler = schedulerFactory.makeSubmitterScheduler(poolSize > 1 ? poolSize * 2 : 1, prestartIfAvailable); return new KeyedSubmitterSchedulerLimiter(scheduler, poolSize).getSubmitterSchedulerForKey("foo"); }
@Override protected SubmitterSchedulerLimiter makeLimiter(String limiterThreadName) { return new SubmitterSchedulerLimiter(StringUtils.isNullOrEmpty(limiterThreadName) ? scheduler : new ThreadRenamingSubmitterScheduler(scheduler, limiterThreadName, false), getMaxConcurrencyPerKey(), limitFutureListenersExecution); }
@Override protected AbstractKeyedLimiter<?> makeLimiter(int limit) { return new KeyedSubmitterSchedulerLimiter(scheduler, limit, null, true, true); }
@Override protected SubmitterSchedulerLimiter makeLimiter(String limiterThreadName) { return new SubmitterSchedulerLimiter(StringUtils.isNullOrEmpty(limiterThreadName) ? scheduler : new ThreadRenamingSubmitterScheduler(scheduler, limiterThreadName, false), getMaxConcurrencyPerKey(), limitFutureListenersExecution); }
@Test @SuppressWarnings("unused") public void constructorFail() { try { new KeyedSubmitterSchedulerLimiter(null, 10); fail("Exception should have thrown"); } catch (IllegalArgumentException e) { // expected } try { new KeyedSubmitterSchedulerLimiter(scheduler, 0); fail("Exception should have thrown"); } catch (IllegalArgumentException e) { // expected } } }