/** * {@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 testMaintenanceOnlyOwningThreadCanClose() throws InterruptedException { final StatusTransitioner transitioner = new StatusTransitioner(LoggerFactory.getLogger(StatusTransitionerTest.class)); transitioner.maintenance().succeeded(); Thread thread = new Thread() { @Override public void run() { try { transitioner.close(); fail(); } catch (IllegalStateException e) { assertThat(e.getMessage().contains(Status.MAINTENANCE.name()), is(true)); assertThat(e.getMessage().contains("own"), is(true)); } } }; thread.start(); thread.join(); transitioner.close(); }
@Test public void testMaintenanceOnlyLetsTheOwningThreadInteract() throws InterruptedException { final StatusTransitioner transitioner = new StatusTransitioner(LoggerFactory.getLogger(StatusTransitionerTest.class)); transitioner.maintenance().succeeded(); transitioner.checkMaintenance(); Thread thread = new Thread() { @Override public void run() { try { transitioner.checkMaintenance(); fail(); } catch (IllegalStateException e) { assertThat(e.getMessage().contains(Status.MAINTENANCE.name()), is(true)); assertThat(e.getMessage().contains("own"), is(true)); } } }; thread.start(); thread.join(); }
@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); }
maintenance = statusTransitioner.maintenance(); } catch(IllegalStateException e) {
@Test public void testCheckAvailableAccountsForThreadLease() throws InterruptedException { final StatusTransitioner transitioner = new StatusTransitioner(LoggerFactory.getLogger(StatusTransitionerTest.class)); transitioner.maintenance().succeeded(); transitioner.checkAvailable(); Thread thread = new Thread() { @Override public void run() { try { transitioner.checkAvailable(); fail(); } catch (IllegalStateException e) { assertThat(e.getMessage().contains(Status.MAINTENANCE.name()), is(true)); assertThat(e.getMessage().contains("own"), is(true)); } } }; thread.start(); thread.join(); transitioner.close(); }
@Test public void testDestroyCacheFailsIfAlreadyInMaintenanceMode() throws CachePersistenceException, InterruptedException { Map<String, CacheConfiguration<?, ?>> caches = newCacheMap(); DefaultConfiguration config = new DefaultConfiguration(caches, null); final EhcacheManager manager = new EhcacheManager(config, minimumCacheManagerServices()); Thread thread = new Thread(() -> manager.getStatusTransitioner().maintenance().succeeded()); thread.start(); thread.join(1000); expectedException.expect(IllegalStateException.class); expectedException.expectMessage("State is MAINTENANCE, yet you don't own it!"); manager.destroyCache("test"); }
/** * {@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(); }
@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); }
maintenance = statusTransitioner.maintenance(); } catch(IllegalStateException e) {