private ExceptionTrackerInterceptor getInterceptor(Cache cache) { return cache.getAdvancedCache().getAsyncInterceptorChain() .findInterceptorWithClass(ExceptionTrackerInterceptor.class); }
@Override protected final void resetCaches(List<Cache<GroupKey, String>> cacheList) { for (Cache cache : cacheList) { AsyncInterceptorChain chain = cache.getAdvancedCache().getAsyncInterceptorChain(); BlockCommandInterceptor interceptor = chain.findInterceptorWithClass(BlockCommandInterceptor.class); if (interceptor != null) { interceptor.reset(); } } }
public static ExpectingInterceptor get(AdvancedCache cache) { ExpectingInterceptor self = cache.getAsyncInterceptorChain().findInterceptorWithClass(ExpectingInterceptor.class); if (self != null) { return self; } ExpectingInterceptor ei = new ExpectingInterceptor(); // We are adding this after ICI because we want to handle silent failures, too cache.getAsyncInterceptorChain().addInterceptorAfter(ei, InvocationContextInterceptor.class); return ei; }
cache.getAsyncInterceptorChain().findInterceptorWithClass(BlockingInterceptor.class).suspend(true);
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; }
public static CountingInterceptor inject(Cache cache) { AsyncInterceptorChain chain = cache.getAdvancedCache().getAsyncInterceptorChain(); if (chain.containsInterceptorType(CountingInterceptor.class)) { return chain.findInterceptorWithClass(CountingInterceptor.class); } CountingInterceptor interceptor = new CountingInterceptor(); chain.addInterceptorBefore(interceptor, CallInterceptor.class); return interceptor; } }
public static TxCommandInterceptor inject(Cache cache) { AsyncInterceptorChain chain = cache.getAdvancedCache().getAsyncInterceptorChain(); if (chain.containsInterceptorType(TxCommandInterceptor.class)) { return chain.findInterceptorWithClass(TxCommandInterceptor.class); } TxCommandInterceptor interceptor = new TxCommandInterceptor(); chain.addInterceptorBefore(interceptor, CallInterceptor.class); return interceptor; } }
@AfterMethod @Override protected void clearContent() throws Throwable { super.clearContent(); // Call actual clear to reset interceptor counter for (Cache cache : caches()) { cache.clear(); } for (Cache cache : caches()) { long pendingTransactionCount = cache.getAdvancedCache().getAsyncInterceptorChain().findInterceptorWithClass( TransactionalExceptionEvictionInterceptor.class).pendingTransactionCount(); assertEquals(0, pendingTransactionCount); } }
public static TransactionTrackInterceptor injectInCache(Cache<?, ?> cache) { AsyncInterceptorChain chain = cache.getAdvancedCache().getAsyncInterceptorChain(); if (chain.containsInterceptorType(TransactionTrackInterceptor.class)) { return chain.findInterceptorWithClass(TransactionTrackInterceptor.class); } TransactionTrackInterceptor interceptor = new TransactionTrackInterceptor(); cache.getAdvancedCache().getComponentRegistry().wireDependencies(interceptor); TestingUtil.startComponent(interceptor); chain.addInterceptor(interceptor, 0); return interceptor; }
/** * Asserts that number of entries worth of counts is stored in the interceptors */ void assertInterceptorCount() { for (Cache cache : caches()) { // We use eventually as waitForNoRebalance does not wait until old entries are removed - causing random failures eventually(() -> { long expectedCount = convertAmountForStorage(cache.getAdvancedCache().getDataContainer().sizeIncludingExpired()); TransactionalExceptionEvictionInterceptor interceptor = cache.getAdvancedCache().getAsyncInterceptorChain() .findInterceptorWithClass(TransactionalExceptionEvictionInterceptor.class); long size = interceptor.getCurrentSize(); log.debugf("Exception eviction size for cache: %s is: %d", cache.getCacheManager().getAddress(), size); expectedCount += interceptor.getMinSize(); boolean equal = expectedCount == size; if (!equal) { log.fatal("Expected: " + expectedCount + " but was: " + size + " for: " + cache.getCacheManager().getAddress()); } return equal; }); } }