@Test public void testTransitionsToLowestStateOnFailure() { StatusTransitioner transitioner = new StatusTransitioner(LoggerFactory.getLogger(StatusTransitionerTest.class)); assertThat(transitioner.currentStatus(), CoreMatchers.is(Status.UNINITIALIZED)); transitioner.init().failed(new Throwable()); assertThat(transitioner.currentStatus(), is(Status.UNINITIALIZED)); transitioner.init().succeeded(); assertThat(transitioner.currentStatus(), is(Status.AVAILABLE)); transitioner.close().failed(new Throwable()); assertThat(transitioner.currentStatus(), is(Status.UNINITIALIZED)); }
@Override public void destroy() throws CachePersistenceException { StatusTransitioner.Transition st = statusTransitioner.maintenance(); try { startMaintainableServices(MaintainableService.MaintenanceScope.CACHE_MANAGER); st.succeeded(); } catch (Throwable t) { throw st.failed(t); } destroyInternal(); st = statusTransitioner.exitMaintenance(); try { stopMaintainableServices(); st.succeeded(); } catch (Throwable t) { throw st.failed(t); } LOGGER.info("All persistent data destroyed for {}", simpleName); }
/** * {@inheritDoc} */ @Override public void destroy() throws CachePersistenceException { StatusTransitioner.Transition st = statusTransitioner.maintenance(); try { st.succeeded(); } catch (Throwable t) { throw st.failed(t); } destroyInternal(); // Exit maintenance mode once #934 is solved // statusTransitioner.exitMaintenance().succeeded(); }
@Test public void testTransitionDuringFailures() { StatusTransitioner transitioner = new StatusTransitioner(LoggerFactory.getLogger(StatusTransitionerTest.class)); assertThat(transitioner.currentStatus(), CoreMatchers.is(Status.UNINITIALIZED)); StatusTransitioner.Transition st = transitioner.init(); st.failed(new Throwable()); assertThat(transitioner.currentStatus(), is(Status.UNINITIALIZED)); try { st.failed(new Throwable()); fail(); } catch (AssertionError err) { assertThat(err.getMessage(), is("Throwable cannot be thrown if Transition is done.")); } st.failed(null); assertThat(transitioner.currentStatus(), is(Status.UNINITIALIZED)); StatusTransitioner.Transition st1 = transitioner.init(); assertThat(transitioner.currentStatus(), is(Status.AVAILABLE)); st1.failed(null); assertThat(transitioner.currentStatus(), is(Status.UNINITIALIZED)); }
@Override public void destroy() throws CachePersistenceException { StatusTransitioner.Transition st = statusTransitioner.maintenance(); try { startMaintainableServices(MaintainableService.MaintenanceScope.CACHE_MANAGER); st.succeeded(); } catch (Throwable t) { throw st.failed(t); } destroyInternal(); st = statusTransitioner.exitMaintenance(); try { stopMaintainableServices(); st.succeeded(); } catch (Throwable t) { throw st.failed(t); } LOGGER.info("All persistent data destroyed for {}", simpleName); }
/** * {@inheritDoc} */ @Override public void destroy() throws CachePersistenceException { StatusTransitioner.Transition st = statusTransitioner.maintenance(); try { st.succeeded(); } catch (Throwable t) { throw st.failed(t); } destroyInternal(); // Exit maintenance mode once #934 is solved // statusTransitioner.exitMaintenance().succeeded(); }