@Test public void testIsAlive() throws Exception { aliveCheck.updateLastRequestDate(); Assert.assertTrue(aliveCheck.isAlive()); }
@Override public boolean isAlive() { if(lastRequestMilliseconds != null) { long currentMilliseconds = System.currentTimeMillis(); long difference = (currentMilliseconds - lastRequestMilliseconds); boolean result = difference < notAliveThresholdMilliseconds; if(!result) logger.warn(String.format("Last request sent: %1$s ms ago. Threshold: %2$s", difference, notAliveThresholdMilliseconds)); return result; } return true; }
LastRequestAliveCheck implements AliveCheck { @Override public boolean isAlive() { if(lastRequestMilliseconds != null) { long currentMilliseconds = System.currentTimeMillis(); long difference = (currentMilliseconds - lastRequestMilliseconds); boolean result = difference < notAliveThresholdMilliseconds; if(!result) logger.warn(String.format("Last request sent: %1$s ms ago. Threshold: %2$s", difference, notAliveThresholdMilliseconds)); return result; } return true; } }
LastRequestAliveCheck implements AliveCheck { @Override public boolean isAlive() { if(lastRequestMilliseconds != null) { long currentMilliseconds = System.currentTimeMillis(); long difference = (currentMilliseconds - lastRequestMilliseconds); boolean result = difference < notAliveThresholdMilliseconds; if(!result) logger.warn(String.format("Last request sent: %1$s ms ago. Threshold: %2$s", difference, notAliveThresholdMilliseconds)); return result; } return true; }  }
LastRequestAliveCheck implements AliveCheck { @Override public boolean isAlive() { if(lastRequestMilliseconds != null) { long currentMilliseconds = System.currentTimeMillis(); long difference = (currentMilliseconds - lastRequestMilliseconds); boolean result = difference < notAliveThresholdMilliseconds; if(!result) logger.warn(String.format("Last request sent: %1$s ms ago. Threshold: %2$s", difference, notAliveThresholdMilliseconds)); return result; } return true; }  @Override boolean isAlive(); @Override String getNotAliveString(); void setNotAliveThresholdMilliseconds(Long notAliveThresholdMilliseconds); void updateLastRequestDate(); }
LastRequestAliveCheck implements AliveCheck { @Override public boolean isAlive() { if(lastRequestMilliseconds != null) { long currentMilliseconds = System.currentTimeMillis(); long difference = (currentMilliseconds - lastRequestMilliseconds); boolean result = difference < notAliveThresholdMilliseconds; if(!result) logger.warn(String.format("Last request sent: %1$s ms ago. Threshold: %2$s", difference, notAliveThresholdMilliseconds)); return result; } return true; }  @Override boolean isAlive(); @Override String getNotAliveString(); void setNotAliveThresholdMilliseconds(Long notAliveThresholdMilliseconds); void updateLastRequestDate(); static String LAST_REQUEST_THRESHOLD_PROPERTY; }