@Test public void testHeartbeater() throws InterruptedException { try (TestableHeartbeater heartbeater = new TestableHeartbeater(config)) { heartbeater.start(); TimeUnit.SECONDS.sleep(1); heartbeater.close(); TimeUnit.MILLISECONDS.sleep(500); assertTrue(1 < heartbeater.pongedRecords.size() && heartbeater.pongedRecords.size() < 4); Tuple3<Long, String, Integer> firstPong = heartbeater.pongedRecords.get(0); Tuple3<Long, String, Integer> secondPong = heartbeater.pongedRecords.get(1); long diff = secondPong.getFirst() - firstPong.getFirst(); assertTrue(100 < diff && diff < 1000); for (Tuple3<Long, String, Integer> pongedRecord : heartbeater.pongedRecords) { assertEquals("dummy-hostname", pongedRecord.getSecond()); assertEquals((Integer) 123456, pongedRecord.getThird()); } } }
protected Heartbeater(Config config) { config.validateValues(); this.config = config; executorService = ExecutorServiceUtils.newScheduledDaemonThreadPool(1); }
Heartbeater implements Closeable { protected Heartbeater(Config config) { config.validateValues(); this.config = config; executorService = ExecutorServiceUtils.newScheduledDaemonThreadPool(1); } }
Heartbeater implements Closeable { protected Heartbeater(Config config) { config.validateValues(); this.config = config; executorService = ExecutorServiceUtils.newScheduledDaemonThreadPool(1); } protected  Heartbeater(Config config); }
Heartbeater implements Closeable { protected Heartbeater(Config config) { config.validateValues(); this.config = config; executorService = ExecutorServiceUtils.newScheduledDaemonThreadPool(1); } protected  Heartbeater(Config config); void start(); void setCallback(Callback callback); @Override void close(); String getHost(); int getPort(); int getIntervalMillis(); @Override String toString(); }
Heartbeater implements Closeable { protected Heartbeater(Config config) { config.validateValues(); this.config = config; executorService = ExecutorServiceUtils.newScheduledDaemonThreadPool(1); } protected  Heartbeater(Config config); void start(); void setCallback(Callback callback); @Override void close(); String getHost(); int getPort(); int getIntervalMillis(); @Override String toString();  }