AbstractClusterShardPeriodicTask extends AbstractStartStoppable implements Releasable, Startable, Stoppable { @Override protected void doStop() throws Exception { if (future != null) { logger.info("[doStop]"); future.cancel(true); future = null; } } AbstractClusterShardPeriodicTask(String clusterId, String shardId, DcMetaCache dcMetaCache,
                                            CurrentMetaManager currentMetaManager, ScheduledExecutorService scheduled); @Override void release(); @Override String toString(); static final int DEFAULT_WORK_INTERVAL_SECONDS; }
@Test public void testDoStop() throws Exception { int startTimes = 10; try { for(int i = 0; i < startTimes; i++) { task.stop(); } } catch (Exception ignore) { } verify(task, times(0)).doStop(); Assert.assertEquals(0, counter.get()); task.start(); int stopTimes = 10; try { for(int i = 0; i < stopTimes; i++) { task.stop(); } } catch (Exception ignore) { } verify(task, times(1)).doStop(); Assert.assertEquals(1, counter.get()); }