@Override public void accept(Cache<K, V> cache) { cache.stop(); }
@PreDestroy public void destroy() { cache.stop(); }
@Override public void stopService() throws Exception { this.cache.removeListener(this); this.cache.stop(); }
@AfterMethod(alwaysRun = true) public void stopSecondCacheManager() { if (otherCacheManager != null) { otherCacheManager.getCache().stop(); otherCacheManager.stop(); otherCacheManager = null; } }
@Test(timeOut = 10000) public void writeOnStorage() { TestResourceTracker.testThreadStarted(this); cache = cacheManager.getCache(CACHE_NAME); cache.put("key1", "value"); cache.stop(); storeWasRun = true; }
public void testUnhealthyStatusWhenUserCacheIsStopped() throws Exception { Cache testCache = cacheManager.getCache(CACHE_NAME, true); testCache.stop(); HealthStatus healthStatus = clusterHealth.getHealthStatus(); assertEquals(HealthStatus.UNHEALTHY, healthStatus); }
private void killCache() { if (stopCacheOnly) { killedCache.stop(); } else { manager(KILLED_INDEX).stop(); } if (waitForStateTransfer) { TestingUtil.waitForNoRebalance(originatorCache, otherCache); } }
@Test(expectedExceptions = IllegalLifecycleStateException.class) public void testCacheStopFollowedByGetCache() { Cache cache = cacheManager.getCache(); cache.put("k", "v"); cache.stop(); Cache cache2 = cacheManager.getCache(); cache2.put("k", "v2"); }
public void testUnhealthyStatusWhenInternalCacheIsStopped() throws Exception { Cache internalCache = cacheManager.getCache(INTERNAL_CACHE_NAME, true); internalCache.stop(); assertEquals(HealthStatus.UNHEALTHY, clusterHealth.getHealthStatus()); }
@Test(expectedExceptions = CacheException.class, expectedExceptionsMessageRegExp = "Failed looking up TransactionManager: the cache is not running") public void testLuceneIndexLockingWithStoppedCache() throws IOException { final String commonIndexName = "myIndex"; Cache cache1 = cache(0, "lucene"); cache(0, "lucene").stop(); cache(1, "lucene").stop(); TestingUtil.killCacheManagers(cacheManagers); LockFactory lockFactory = makeLockFactory(); lockFactory.obtainLock(new DirectoryBuilderImpl(cache1,cache1,cache1,commonIndexName).create(),"myLock"); }
@Test(expectedExceptions = IllegalLifecycleStateException.class) public void testCacheStopFollowedByCacheOp() { cacheManager.defineConfiguration("big", cacheManager.getDefaultCacheConfiguration()); Cache cache = cacheManager.getCache("big"); cache.put("k", "v"); cache.stop(); cache.put("k", "v2"); }
@Test public void sequantialOvewritingInBatches() { cache = cacheManager.getCache(); AdvancedCache<Object,Object> advancedCache = cache.getAdvancedCache(); for (int i = 0; i < 2000;) { advancedCache.startBatch(); putAValue(advancedCache, i++); putAValue(advancedCache, i++); advancedCache.endBatch(true); } cacheCopy.putAll(cache); cache.stop(); cacheManager.stop(); }
@Test public void testExplicitStop() { cacheManager.defineConfiguration("A", new ConfigurationBuilder().build()); cacheManager.defineConfiguration("B", new ConfigurationBuilder().build()); Cache<?, ?> cacheA = cacheManager.getCache("A"); Cache<?, ?> cacheB = cacheManager.getCache("B"); cacheManager.addCacheDependency("A", "B"); cacheB.stop(); cacheA.stop(); assertAllTerminated(cacheA, cacheB); }
@Test(expectedExceptions = IllegalLifecycleStateException.class) public void testCacheStopManagerStopFollowedByCacheOp() { EmbeddedCacheManager localCacheManager = createCacheManager(false); try { Cache<String, String> cache = localCacheManager.getCache(); cache.put("k", "v"); cache.stop(); localCacheManager.stop(); cache.put("k", "v2"); } finally { TestingUtil.killCacheManagers(localCacheManager); } }
public void testCacheRestart() throws Exception { final Cache<Integer, String> cache0 = cache(0); final Cache<Integer, String> cache1 = cache(1); // Restart the cache cache1.stop(); cache1.start(); cache1.put(1, "value1"); assertEquals("value1", cache0.get(1)); }
@Override public void call() { Cache<Object, Object> cache = cm.getCache(); CacheLoader cacheLoader = TestingUtil.getCacheLoader(cache); assertSame(RestStore.class, cacheLoader.getClass()); cache.put("k", "v"); assertEquals(1, cacheManager.getCache().size()); cache.stop(); assertEquals(1, cacheManager.getCache().size()); } });
@Test public void testDependencyOnStoppedCaches() { cacheManager.defineConfiguration("A", new ConfigurationBuilder().build()); cacheManager.defineConfiguration("B", new ConfigurationBuilder().build()); Cache<?, ?> cacheA = cacheManager.getCache("A"); Cache<?, ?> cacheB = cacheManager.getCache("B"); cacheA.stop(); cacheManager.addCacheDependency("A", "B"); CacheEventListener listener = new CacheEventListener(); cacheManager.addListener(listener); cacheManager.stop(); assertAllTerminated(cacheA, cacheB); assertEquals(Arrays.asList("B", GlobalConfigurationManager.CONFIG_STATE_CACHE_NAME, DEFAULT_CACHE_NAME), listener.stopOrder); }
public void testStoppedCacheForDistributedExecutor() { ConfigurationBuilder config = TestCacheManagerFactory.getDefaultCacheConfiguration(true); config.clustering().cacheMode(CacheMode.REPL_SYNC); EmbeddedCacheManager cacheManager = TestCacheManagerFactory.createClusteredCacheManager(config); try { Cache<Object, Object> cache = cacheManager.getCache(); cache.stop(); expectException(IllegalStateException.class, () -> new DefaultExecutorService(cache)); } finally { TestingUtil.killCacheManagers(cacheManager); } }
@Override public void call() { Cache<Object, Object> cache = cm.getCache(); CacheLoader cacheLoader = TestingUtil.getCacheLoader(cache); assert cacheLoader != null; assert cacheLoader instanceof RemoteStore; cache.put("k", "v"); assertEquals(1, cacheManager.getCache().size()); cache.stop(); assertEquals(1, cacheManager.getCache().size()); } });