public synchronized void executePeriodically(final Runnable task, long period) {
        TimerTask existing = timerTasks.get(task);
        if (existing != null) {
            LOG.debug("Task {} already scheduled, cancelling and rescheduling", task);
            cancel(task);
        }
        TimerTask timerTask = new SchedulerTimerTask(task);
        timer.schedule(timerTask, period, period);
        timerTasks.put(task, timerTask);
    }
@Test
    public void testExecutePeriodically() throws Exception {
        final CountDownLatch latch = new CountDownLatch(1);
        scheduler.executePeriodically(new CountDownRunnable(latch), 10);
        assertTrue(latch.await(5000, TimeUnit.MILLISECONDS));
    }