@Test public void testOperatesOnDedicatedThread() throws ParseException, IOException { CacheManager manager = new CacheManager(new Configuration().name("testOperatesOnDedicatedThread")); try { final RotatingSnapshotFile rotatingSnapshotFile = mock(RotatingSnapshotFile.class); final TerracottaStore mock = mock(TerracottaStore.class); KeySnapshotter snapshotter = new KeySnapshotter(createFakeTcClusteredCache(manager, mock), 10, true, rotatingSnapshotFile); boolean found = false; for (Thread thread : getAllThreads()) { if (thread != null) { if(thread.getName().equals("KeySnapshotter for cache test")) { found = true; } } } assertThat(found, is(true)); snapshotter.dispose(true); } finally { manager.shutdown(); } }
void dispose(boolean immediately) { if (thread != null) { rotatingWriter.setShutdownOnThreadInterrupted(immediately); thread.interrupt(); try { thread.join(); } catch (InterruptedException e) { Thread.currentThread().interrupt(); } } }
KeySnapshotter implements Runnable { void dispose(boolean immediately) { if (thread != null) { rotatingWriter.setShutdownOnThreadInterrupted(immediately); thread.interrupt(); try { thread.join(); } catch (InterruptedException e) { Thread.currentThread().interrupt(); } } } }
KeySnapshotter implements Runnable { void dispose(boolean immediately) { if (thread != null) { rotatingWriter.setShutdownOnThreadInterrupted(immediately); thread.interrupt(); try { thread.join(); } catch (InterruptedException e) { Thread.currentThread().interrupt(); } } } KeySnapshotter(final Ehcache cache, final long interval,
                   final boolean doKeySnapshotOnDedicatedThread,
                   final RotatingSnapshotFile rotatingWriter); }
KeySnapshotter implements Runnable { void dispose(boolean immediately) { if (thread != null) { rotatingWriter.setShutdownOnThreadInterrupted(immediately); thread.interrupt(); try { thread.join(); } catch (InterruptedException e) { Thread.currentThread().interrupt(); } } } KeySnapshotter(final Ehcache cache, final long interval,
                   final boolean doKeySnapshotOnDedicatedThread,
                   final RotatingSnapshotFile rotatingWriter); void run(); String getCacheName(); }
KeySnapshotter implements Runnable { void dispose(boolean immediately) { if (thread != null) { rotatingWriter.setShutdownOnThreadInterrupted(immediately); thread.interrupt(); try { thread.join(); } catch (InterruptedException e) { Thread.currentThread().interrupt(); } } } KeySnapshotter(final Ehcache cache, final long interval,
                   final boolean doKeySnapshotOnDedicatedThread,
                   final RotatingSnapshotFile rotatingWriter); void run(); String getCacheName();  }