JVMStatistics { public void delayStart(int seconds) { executor.schedule(this::start, seconds, TimeUnit.SECONDS); } JVMStatistics(Conf<?, ?, ?> conf); static void registerStatisticCollector(String name, Class<?> clazz); static void registerGCNotifications(String name, Class<?> clazz); void start(); void delayStart(int seconds); void stop(); static void main(String[] args); static final String DEFAULT_SINK_TYPE; }
@Test public void delayStart() throws InterruptedException { Conf<String, String, String> conf = new Conf<>(); conf.setInterval(Duration.ofSeconds(1)); conf.setLogJVMStats(this::assertJVMStatsLog); JVMStatistics jvmStatistics = new JVMStatistics(conf); long start = System.currentTimeMillis(); jvmStatistics.delayStart(1); Assert.assertTrue("timeout", latch.await(10, TimeUnit.SECONDS)); long stop = System.currentTimeMillis(); long delay = stop - start; Assert.assertTrue(String.format("delay: %d", delay),delay >= TimeUnit.SECONDS.toMillis(1)); Assert.assertTrue(isMatches.get()); }