@Test public void init() throws InterruptedException { long period = 1; doNothing().when(asyncEvictionListener).drainQueue(); asyncEvictionListener.init(period, 3); Thread.sleep(period * 50); verify(asyncEvictionListener, atLeast(1)).drainQueue(); }
protected void init(final long period, final int queueSize) { cacheTasks = new ArrayBlockingQueue<>(queueSize); final ScheduledExecutorService drainerService = Executors.newSingleThreadScheduledExecutor( runnable -> ThreadUtils .createDaemonThread(runnable, "imcache:batchAsyncEvictionDrainer(thread=" + NO_OF_EVICTION_DRAINERS.incrementAndGet() + ")")); drainerService.scheduleAtFixedRate(new Runnable() { public void run() { drainQueue(); } }, period, period, TimeUnit.MILLISECONDS); }
ScheduledEvictionListener extends QueuingEvictionListener<K, V> { protected void init(final long period, final int queueSize) { cacheTasks = new ArrayBlockingQueue<>(queueSize); final ScheduledExecutorService drainerService = Executors.newSingleThreadScheduledExecutor( runnable -> ThreadUtils .createDaemonThread(runnable, "imcache:batchAsyncEvictionDrainer(thread=" + NO_OF_EVICTION_DRAINERS.incrementAndGet() + ")")); drainerService.scheduleAtFixedRate(new Runnable() { public void run() { drainQueue(); } }, period, period, TimeUnit.MILLISECONDS); } }
ScheduledEvictionListener extends QueuingEvictionListener<K, V> { protected void init(final long period, final int queueSize) { cacheTasks = new ArrayBlockingQueue<>(queueSize); final ScheduledExecutorService drainerService = Executors.newSingleThreadScheduledExecutor( runnable -> ThreadUtils .createDaemonThread(runnable, "imcache:batchAsyncEvictionDrainer(thread=" + NO_OF_EVICTION_DRAINERS.incrementAndGet() + ")")); drainerService.scheduleAtFixedRate(new Runnable() { public void run() { drainQueue(); } }, period, period, TimeUnit.MILLISECONDS); } ScheduledEvictionListener();  ScheduledEvictionListener(final int batchSize, final long period, final int queueSize); }
ScheduledEvictionListener extends QueuingEvictionListener<K, V> { protected void init(final long period, final int queueSize) { cacheTasks = new ArrayBlockingQueue<>(queueSize); final ScheduledExecutorService drainerService = Executors.newSingleThreadScheduledExecutor( runnable -> ThreadUtils .createDaemonThread(runnable, "imcache:batchAsyncEvictionDrainer(thread=" + NO_OF_EVICTION_DRAINERS.incrementAndGet() + ")")); drainerService.scheduleAtFixedRate(new Runnable() { public void run() { drainQueue(); } }, period, period, TimeUnit.MILLISECONDS); } ScheduledEvictionListener();  ScheduledEvictionListener(final int batchSize, final long period, final int queueSize);  }
ScheduledEvictionListener extends QueuingEvictionListener<K, V> { protected void init(final long period, final int queueSize) { cacheTasks = new ArrayBlockingQueue<>(queueSize); final ScheduledExecutorService drainerService = Executors.newSingleThreadScheduledExecutor( runnable -> ThreadUtils .createDaemonThread(runnable, "imcache:batchAsyncEvictionDrainer(thread=" + NO_OF_EVICTION_DRAINERS.incrementAndGet() + ")")); drainerService.scheduleAtFixedRate(new Runnable() { public void run() { drainQueue(); } }, period, period, TimeUnit.MILLISECONDS); } ScheduledEvictionListener();  ScheduledEvictionListener(final int batchSize, final long period, final int queueSize);  static final long DEFAULT_PERIOD; }