AbstractClusterShardPeriodicTask extends AbstractStartStoppable implements Releasable, Startable, Stoppable { @Override protected void doStart() throws Exception { future = scheduled.scheduleWithFixedDelay(new AbstractExceptionLogTask() { @Override protected void doRun() throws Exception { work(); } }, 0, getWorkIntervalSeconds(), TimeUnit.SECONDS); } 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 testDoStart() throws Exception { int startTimes = 10; try { for(int i = 0; i < startTimes; i++) { task.start(); } } catch (Exception ignore) { } verify(task, times(1)).doStart(); Assert.assertEquals(1, counter.get()); }