@Test public void testBootstrapsWhenSnapshotPresent() throws IOException { RotatingSnapshotFile file = new RotatingSnapshotFile(DIRECTORY, MOCKED_CACHE_NAME); final List<Integer> localKeys = Arrays.asList(0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 9); file.writeAll(localKeys); final Ehcache cache = mockCacheToBootStrap(); cacheLoader.load(cache); verify(cache, times(new HashSet<Integer>(localKeys).size())).get(Matchers.anyObject()); for (Integer localKey : localKeys) { verify(cache, times(1)).get((Object) localKey); } file.currentSnapshotFile().delete(); }
public void load(final Ehcache cache) throws CacheException { if (!cache.getCacheConfiguration().isTerracottaClustered()) { LOG.error("You're trying to bootstrap a non Terracotta clustered cache with a TerracottaBootstrapCacheLoader! Cache " + "'{}' will not be bootstrapped and no keySet snapshot will be recorded...", cache.getName()); return; } if (cache.getStatus() != Status.STATUS_ALIVE) { throw new CacheException("Cache '" + cache.getName() + "' isn't alive yet: " + cache.getStatus()); } if (isAsynchronous()) { BootstrapThread thread = new BootstrapThread(cache); thread.start(); } else { doLoad(cache); } }
TerracottaBootstrapCacheLoader extends MemoryLimitedCacheLoader implements Disposable { public void load(final Ehcache cache) throws CacheException { if (!cache.getCacheConfiguration().isTerracottaClustered()) { LOG.error("You're trying to bootstrap a non Terracotta clustered cache with a TerracottaBootstrapCacheLoader! Cache " + "'{}' will not be bootstrapped and no keySet snapshot will be recorded...", cache.getName()); return; } if (cache.getStatus() != Status.STATUS_ALIVE) { throw new CacheException("Cache '" + cache.getName() + "' isn't alive yet: " + cache.getStatus()); } if (isAsynchronous()) { BootstrapThread thread = new BootstrapThread(cache); thread.start(); } else { doLoad(cache); } } }
TerracottaBootstrapCacheLoader extends MemoryLimitedCacheLoader implements Disposable { public void load(final Ehcache cache) throws CacheException { if (!cache.getCacheConfiguration().isTerracottaClustered()) { LOG.error("You're trying to bootstrap a non Terracotta clustered cache with a TerracottaBootstrapCacheLoader! Cache " + "'{}' will not be bootstrapped and no keySet snapshot will be recorded...", cache.getName()); return; } if (cache.getStatus() != Status.STATUS_ALIVE) { throw new CacheException("Cache '" + cache.getName() + "' isn't alive yet: " + cache.getStatus()); } if (isAsynchronous()) { BootstrapThread thread = new BootstrapThread(cache); thread.start(); } else { doLoad(cache); } } private  TerracottaBootstrapCacheLoader(final boolean doKeySnapshot, final boolean aSynchronous,
                                           final String directory, final long interval, final boolean doKeySnapshotOnDedicatedThread);  TerracottaBootstrapCacheLoader(final boolean asynchronous, String directory, boolean doKeySnapshots);  TerracottaBootstrapCacheLoader(final boolean asynchronous, String directory, long interval);  TerracottaBootstrapCacheLoader(final boolean asynchronous, String directory, long interval, boolean onDedicatedThread); }
TerracottaBootstrapCacheLoader extends MemoryLimitedCacheLoader implements Disposable { public void load(final Ehcache cache) throws CacheException { if (!cache.getCacheConfiguration().isTerracottaClustered()) { LOG.error("You're trying to bootstrap a non Terracotta clustered cache with a TerracottaBootstrapCacheLoader! Cache " + "'{}' will not be bootstrapped and no keySet snapshot will be recorded...", cache.getName()); return; } if (cache.getStatus() != Status.STATUS_ALIVE) { throw new CacheException("Cache '" + cache.getName() + "' isn't alive yet: " + cache.getStatus()); } if (isAsynchronous()) { BootstrapThread thread = new BootstrapThread(cache); thread.start(); } else { doLoad(cache); } } private  TerracottaBootstrapCacheLoader(final boolean doKeySnapshot, final boolean aSynchronous,
                                           final String directory, final long interval, final boolean doKeySnapshotOnDedicatedThread);  TerracottaBootstrapCacheLoader(final boolean asynchronous, String directory, boolean doKeySnapshots);  TerracottaBootstrapCacheLoader(final boolean asynchronous, String directory, long interval);  TerracottaBootstrapCacheLoader(final boolean asynchronous, String directory, long interval, boolean onDedicatedThread); boolean isImmediateShutdown(); void setImmediateShutdown(final boolean immediateShutdown); void load(final Ehcache cache); boolean isAsynchronous(); void dispose(); void doLocalKeySnapshot(); @Override Object clone(); void setSnapshotOnDispose(final boolean doKeySnapshotOnDispose); }
TerracottaBootstrapCacheLoader extends MemoryLimitedCacheLoader implements Disposable { public void load(final Ehcache cache) throws CacheException { if (!cache.getCacheConfiguration().isTerracottaClustered()) { LOG.error("You're trying to bootstrap a non Terracotta clustered cache with a TerracottaBootstrapCacheLoader! Cache " + "'{}' will not be bootstrapped and no keySet snapshot will be recorded...", cache.getName()); return; } if (cache.getStatus() != Status.STATUS_ALIVE) { throw new CacheException("Cache '" + cache.getName() + "' isn't alive yet: " + cache.getStatus()); } if (isAsynchronous()) { BootstrapThread thread = new BootstrapThread(cache); thread.start(); } else { doLoad(cache); } } private  TerracottaBootstrapCacheLoader(final boolean doKeySnapshot, final boolean aSynchronous,
                                           final String directory, final long interval, final boolean doKeySnapshotOnDedicatedThread);  TerracottaBootstrapCacheLoader(final boolean asynchronous, String directory, boolean doKeySnapshots);  TerracottaBootstrapCacheLoader(final boolean asynchronous, String directory, long interval);  TerracottaBootstrapCacheLoader(final boolean asynchronous, String directory, long interval, boolean onDedicatedThread); boolean isImmediateShutdown(); void setImmediateShutdown(final boolean immediateShutdown); void load(final Ehcache cache); boolean isAsynchronous(); void dispose(); void doLocalKeySnapshot(); @Override Object clone(); void setSnapshotOnDispose(final boolean doKeySnapshotOnDispose); static final long DEFAULT_INTERVAL; static final boolean DEFAULT_DEDICATED_THREAD; }