@Test(groups = "Integration") // Because slow public void testRecoversThenDownUpResetsStabilisationCount() throws Exception { final long stabilisationDelay = 1000; e1.enrichers() .add( EnricherSpec.create(ServiceFailureDetector.class) .configure( ServiceFailureDetector.ENTITY_RECOVERED_STABILIZATION_DELAY, Duration.of(stabilisationDelay))); e1.sensors().set(TestEntity.SERVICE_UP, false); assertHasEventEventually(HASensors.ENTITY_FAILED, Predicates.<Object>equalTo(e1), null); events.clear(); e1.sensors().set(TestEntity.SERVICE_UP, true); assertNoEventsContinually(Duration.of(stabilisationDelay - OVERHEAD)); e1.sensors().set(TestEntity.SERVICE_UP, false); Thread.sleep(OVERHEAD); e1.sensors().set(TestEntity.SERVICE_UP, true); assertNoEventsContinually(Duration.of(stabilisationDelay - OVERHEAD)); assertHasEventEventually(HASensors.ENTITY_RECOVERED, Predicates.<Object>equalTo(e1), null); }
@Test(groups = "Integration") // Because slow public void testNotifiedOfFailureAfterStabilisationDelay() throws Exception { final int stabilisationDelay = 1000; e1.enrichers() .add( EnricherSpec.create(ServiceFailureDetector.class) .configure( ServiceFailureDetector.ENTITY_FAILED_STABILIZATION_DELAY, Duration.of(stabilisationDelay))); e1.sensors().set(TestEntity.SERVICE_UP, false); assertNoEventsContinually(Duration.of(stabilisationDelay - OVERHEAD)); assertHasEventEventually(HASensors.ENTITY_FAILED, Predicates.<Object>equalTo(e1), null); }
/** @deprecated since 0.7.0; use {@link #setPeriodicPersistPeriod(Duration)} */ public void setPeriodicPersistPeriod(long periodMillis) { setPeriodicPersistPeriod(Duration.of(periodMillis, TimeUnit.MILLISECONDS)); }