this.maxIdleMs = maxIdleMs; this.callbackTimer = (callbackTimeoutMs > 0) ? Executors.newSingleThreadScheduledExecutor() : null; this.callbackExecutor = new ThrottlingScheduler(maxThrottlingDelayMs); this.coordinatorRequests = new CoordinatorRequests(taskInstances.keySet()); this.latch = new Object();
this.maxIdleMs = maxIdleMs; this.callbackTimer = (callbackTimeoutMs > 0) ? Executors.newSingleThreadScheduledExecutor() : null; this.callbackExecutor = new ThrottlingScheduler(maxThrottlingDelayMs); this.coordinatorRequests = new CoordinatorRequests(taskInstances.keySet()); this.latch = new Object();
this.maxIdleMs = maxIdleMs; this.callbackTimer = (callbackTimeoutMs > 0) ? Executors.newSingleThreadScheduledExecutor() : null; this.callbackExecutor = new ThrottlingScheduler(maxThrottlingDelayMs); this.coordinatorRequests = new CoordinatorRequests(taskInstances.keySet()); this.latch = new Object();
this.maxIdleMs = maxIdleMs; this.callbackTimer = (callbackTimeoutMs > 0) ? Executors.newSingleThreadScheduledExecutor() : null; this.callbackExecutor = new ThrottlingScheduler(maxThrottlingDelayMs); this.coordinatorRequests = new CoordinatorRequests(taskInstances.keySet()); this.latch = new Object();
this.maxIdleMs = maxIdleMs; this.callbackTimer = (callbackTimeoutMs > 0) ? Executors.newSingleThreadScheduledExecutor() : null; this.callbackExecutor = new ThrottlingScheduler(maxThrottlingDelayMs); this.coordinatorRequests = new CoordinatorRequests(taskInstances.keySet()); this.latch = new Object();
@Before public void setUp() { clock = Mockito.mock(HighResolutionClock.class); scheduledExecutorService = Mockito.mock(ScheduledExecutorService.class); throttler = new ThrottlingScheduler(MAX_NANOS, scheduledExecutorService, clock); }
@Test public void testClampDelayMillis() throws InterruptedException { final long maxDelayMillis = 10; final long maxDelayNanos = TimeUnit.MILLISECONDS.toNanos(maxDelayMillis); ThrottlingScheduler throttler = new ThrottlingScheduler(maxDelayMillis, scheduledExecutorService, clock); throttler.setWorkFactor(0.5); setActualDelay(maxDelayNanos); // Note work time exceeds maxDelayMillis throttler.schedule(NO_OP, TimeUnit.MILLISECONDS.toNanos(100)); verifyRequestedDelay(maxDelayNanos); assertEquals(0L, throttler.getPendingNanos()); }