@Override public Void run() { T interceptor = getFirstInterceptorWhichExtends(cache.getAsyncInterceptorChain().getInterceptors(), interceptorClass); if (interceptor != null) { interceptor.resetStatistics(); } return null; } }
/** * This methods should be called only from tests; it removes existing validator from the cache structures * in order to replace it with new one. * * @param cache */ public static PutFromLoadValidator removeFromCache(AdvancedCache cache) { AsyncInterceptorChain chain = cache.getAsyncInterceptorChain(); BasicComponentRegistry cr = cache.getComponentRegistry().getComponent(BasicComponentRegistry.class); chain.removeInterceptor(TxPutFromLoadInterceptor.class); chain.removeInterceptor(NonTxPutFromLoadInterceptor.class); chain.getInterceptors().stream() .filter(BaseInvalidationInterceptor.class::isInstance).findFirst().map(AsyncInterceptor::getClass) .ifPresent(invalidationClass -> { InvalidationInterceptor invalidationInterceptor = new InvalidationInterceptor(); cr.replaceComponent(InvalidationInterceptor.class.getName(), invalidationInterceptor, true); cr.getComponent(InvalidationInterceptor.class).running(); chain.replaceInterceptor(invalidationInterceptor, invalidationClass); }); chain.getInterceptors().stream() .filter(LockingInterceptor.class::isInstance).findFirst().map(AsyncInterceptor::getClass) .ifPresent(invalidationClass -> { NonTransactionalLockingInterceptor lockingInterceptor = new NonTransactionalLockingInterceptor(); cr.replaceComponent(NonTransactionalLockingInterceptor.class.getName(), lockingInterceptor, true); cr.getComponent(NonTransactionalLockingInterceptor.class).running(); chain.replaceInterceptor(lockingInterceptor, LockingInterceptor.class); }); CacheCommandInitializer cci = cr.getComponent(CacheCommandInitializer.class).running(); return cci.removePutFromLoadValidator(cache.getName()); }
@Override public void call() { List<AsyncInterceptor> interceptors = cacheManager.getCache("interceptors").getAdvancedCache().getAsyncInterceptorChain() .getInterceptors(); assertEquals(FooInterceptor.class, interceptors.get(interceptors.size() - 2).getClass()); } });
@Override public void call() { AsyncInterceptorChain interceptorChain = cacheManager.getCache("interceptors").getAdvancedCache().getAsyncInterceptorChain(); assertEquals(interceptorChain.getInterceptors().get(1).getClass(), FooInterceptor.class); } });
private void assertQueryInterceptorPresent(Cache<?, ?> c) { QueryInterceptor i = TestingUtil.findInterceptor(c, QueryInterceptor.class); assert i != null : "Expected to find a QueryInterceptor, only found " + c.getAdvancedCache().getAsyncInterceptorChain().getInterceptors(); }
@Override public void call() { final Cache<Object,Object> cache = cm.getCache(); AsyncInterceptor i = cache.getAdvancedCache().getAsyncInterceptorChain().getInterceptors().get(0); assertTrue("Expecting FooInterceptor in the interceptor chain", i instanceof FooInterceptor); assertEquals("bar", ((FooInterceptor)i).getFoo()); } });
public void testBaseCustomAsyncInterceptorInjection() { AsyncInterceptor interceptor = cache.getAdvancedCache().getAsyncInterceptorChain().getInterceptors().get(0); assertEquals(SomeAsyncInterceptor.class, interceptor.getClass()); SomeAsyncInterceptor someAsyncInterceptor = (SomeAsyncInterceptor) interceptor; assertSame(cache.getAdvancedCache().getLockManager(), someAsyncInterceptor.lm); assertSame(cache.getAdvancedCache().getDataContainer(), someAsyncInterceptor.dc); }
@Override public void call() { List<AsyncInterceptor> interceptors = cacheManager.getCache().getAdvancedCache().getAsyncInterceptorChain() .getInterceptors(); Object o = interceptors.get(interceptors.size() - 2); assertEquals(FooInterceptor.class, o.getClass()); assertFalse(interceptor.putInvoked); cacheManager.getCache().put("k", "v"); assertEquals("v", cacheManager.getCache().get("k")); assertTrue(interceptor.putInvoked); } });
private void printCacheStats(PrintWriter pw, Cache<?, ?> cache) throws StatementException { if (!cache.getCacheConfiguration().jmxStatistics().enabled()) { throw log.statisticsNotEnabled(cache.getName()); } for (AsyncInterceptor interceptor : cache.getAdvancedCache().getAsyncInterceptorChain().getInterceptors()) { printComponentStats(pw, cache, interceptor); } printComponentStats(pw, cache, cache.getAdvancedCache().getLockManager()); printComponentStats(pw, cache, cache.getAdvancedCache().getRpcManager()); }
List<AsyncInterceptor> interceptors = chain.getInterceptors(); log.debugf("Interceptor chain was: ", interceptors); int position = 0;
: t -> t.getClass().equals(op.getCommandClass())); Class<? extends AsyncInterceptor> ewi = cache1.getAsyncInterceptorChain().getInterceptors().stream() .filter(i -> i instanceof EntryWrappingInterceptor).findFirst().orElseThrow(IllegalStateException::new).getClass(); assertTrue(cache1.getAsyncInterceptorChain().addInterceptorAfter(blockingInterceptor1, ewi));