static <T extends AsyncInterceptor> T findInterceptor(Cache<?, ?> cache, Class<T> interceptorClass) { return cache.getAdvancedCache().getAsyncInterceptorChain().findInterceptorExtending(interceptorClass); } }
static <T extends AsyncInterceptor> T findInterceptor(Cache<?, ?> cache, Class<T> interceptorClass) { return cache.getAdvancedCache().getAsyncInterceptorChain().findInterceptorExtending(interceptorClass); } }
public AfterPassivationOrCacheWriter injectThis(Cache<Object, Object> injectInCache) { AsyncInterceptorChain chain = extractComponent(injectInCache, AsyncInterceptorChain.class); AsyncInterceptor interceptor = chain.findInterceptorExtending(CacheWriterInterceptor.class); if (interceptor == null) { interceptor = chain.findInterceptorExtending(CacheLoaderInterceptor.class); } if (interceptor == null) { throw new IllegalStateException("Should not happen!"); } chain.addInterceptorAfter(this, interceptor.getClass()); return this; }
private static CacheLoaderInterceptor cacheLoaderInterceptor(Cache<?, ?> cache) { AsyncInterceptorChain chain = TestingUtil.extractComponent(cache, AsyncInterceptorChain.class); return chain.findInterceptorExtending( CacheLoaderInterceptor.class); }
protected static void removeAllBlockingInterceptorsFromCache(Cache<?, ?> cache) { AsyncInterceptorChain chain = cache.getAdvancedCache().getAsyncInterceptorChain(); BlockingInterceptor blockingInterceptor = chain.findInterceptorExtending(BlockingInterceptor.class); while (blockingInterceptor != null) { blockingInterceptor.suspend(true); chain.removeInterceptor(blockingInterceptor.getClass()); blockingInterceptor = chain.findInterceptorExtending(BlockingInterceptor.class); } }
public static <T extends AsyncInterceptor> T findInterceptor(Cache<?, ?> cache, Class<T> interceptorToFind) { return cache.getAdvancedCache().getAsyncInterceptorChain() .findInterceptorExtending(interceptorToFind); }
public AfterActivationOrCacheLoader injectThis(Cache<Object, Object> injectInCache) { AsyncInterceptorChain chain = TestingUtil.extractComponent(injectInCache, AsyncInterceptorChain.class); AsyncInterceptor loaderInterceptor = chain.findInterceptorExtending(org.infinispan.interceptors.impl.CacheLoaderInterceptor.class); injectInCache.getAdvancedCache().getAsyncInterceptorChain().addInterceptorAfter(this, loaderInterceptor.getClass()); return this; }
protected long loads(Ownership ownership) { Cache<K, V> cache = cache(ownership); if (cache == null) return 0; AsyncInterceptorChain chain = extractComponent(cache, AsyncInterceptorChain.class); CacheLoaderInterceptor interceptor = chain.findInterceptorExtending(CacheLoaderInterceptor.class); return interceptor.getCacheLoaderLoads(); }
private void resetStats(Ownership ownership) { Cache<K, V> cache = cache(ownership); if (cache == null) return; AsyncInterceptorChain chain = extractComponent(cache, AsyncInterceptorChain.class); CacheLoaderInterceptor interceptor = chain.findInterceptorExtending( CacheLoaderInterceptor.class); interceptor.resetStatistics(); } }
@Override protected final void resetCaches(List<Cache<BaseUtilGroupTest.GroupKey, String>> cacheList) { for (Cache cache : cacheList) { AsyncInterceptorChain chain = cache.getAdvancedCache().getAsyncInterceptorChain(); BlockCommandInterceptor interceptor = chain.findInterceptorExtending(BlockCommandInterceptor.class); if (interceptor != null) { interceptor.reset(); } } }
private BlockCommandInterceptor injectIfAbsent(Cache<?, ?> cache) { log.debugf("Injecting BlockCommandInterceptor in %s", cache); AsyncInterceptorChain chain = cache.getAdvancedCache().getAsyncInterceptorChain(); BlockCommandInterceptor interceptor = chain.findInterceptorExtending(BlockCommandInterceptor.class); if (interceptor == null) { interceptor = new BlockCommandInterceptor(log); EntryWrappingInterceptor ewi = chain.findInterceptorExtending(EntryWrappingInterceptor.class); AssertJUnit.assertTrue(chain.addInterceptorAfter(interceptor, ewi.getClass())); } interceptor.reset(); log.debugf("Injected BlockCommandInterceptor in %s. Interceptor=%s", cache, interceptor); return interceptor; }
EntryWrappingInterceptor wrappingInterceptor = ic.findInterceptorExtending(EntryWrappingInterceptor.class); AsyncInterceptor lastLoadingInterceptor = ic.findInterceptorExtending(CacheLoaderInterceptor.class); if (lastLoadingInterceptor == null) { lastLoadingInterceptor = wrappingInterceptor;
private void checkAndDisableStore(EmbeddedCacheManager cm, int count) { Cache<Object, Object> cache = cm.getCache(); PersistenceManager clm = TestingUtil.extractComponent(cache, PersistenceManager.class); Set<DummyInMemoryStore> stores = clm.getStores(DummyInMemoryStore.class); assertEquals(count, stores.size()); stores.forEach(store -> assertTrue(store.isRunning())); clm.disableStore(DummyInMemoryStore.class.getName()); stores.forEach(store -> assertFalse(store.isRunning())); AsyncInterceptor interceptor = cache.getAdvancedCache().getAsyncInterceptorChain() .findInterceptorExtending(CacheLoaderInterceptor.class); assertNull(interceptor); interceptor = cache.getAdvancedCache().getAsyncInterceptorChain() .findInterceptorExtending(CacheWriterInterceptor.class); assertNull(interceptor); }
private static BlockCommandInterceptor injectBlockCommandInterceptorIfAbsent(Cache<GroupKey, String> cache) { AsyncInterceptorChain chain = cache.getAdvancedCache().getAsyncInterceptorChain(); BlockCommandInterceptor interceptor = chain.findInterceptorWithClass(BlockCommandInterceptor.class); if (interceptor == null) { interceptor = new BlockCommandInterceptor(); EntryWrappingInterceptor ewi = chain.findInterceptorExtending(EntryWrappingInterceptor.class); assertNotNull(ewi); chain.addInterceptorAfter(interceptor, ewi.getClass()); } interceptor.reset(); return interceptor; }
private FlagCheckCommandInterceptor init() { AsyncInterceptorChain interceptorChain = cacheManager.getCache(cacheName).getAdvancedCache().getAsyncInterceptorChain(); FlagCheckCommandInterceptor interceptor = interceptorChain.findInterceptorExtending(FlagCheckCommandInterceptor.class); if (interceptor != null) return interceptor; FlagCheckCommandInterceptor ci = new FlagCheckCommandInterceptor(); interceptorChain.addInterceptor(ci, 1); return ci; }