public static void cleanup(AdvancedCache... caches) { for (AdvancedCache c : caches) c.getAsyncInterceptorChain().removeInterceptor(ExpectingInterceptor.class); }
@TestCachePermission(AuthorizationPermission.ADMIN) public void testRemoveInterceptor_Class(SecureCache<String, String> cache) { cache.getAsyncInterceptorChain().removeInterceptor(interceptor.getClass()); }
/** * 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()); }
@AfterMethod public void dropFailPrepare() { cache(0).getAdvancedCache().getAsyncInterceptorChain().removeInterceptor(FailPrepare.class); }
@Override public Void call() throws Exception { final Class<? extends AsyncInterceptor> interceptorClass = interceptor.getClass(); try { log.debug("Wait for all executions paths to be ready to perform calls"); barrier.await(); // test in a loop as the barrier is otherwise not enough to make sure // the different testing threads actually do make changes concurrently // 2000 is still almost nothing in terms of testsuite time. for (int i = 0; i < 2000; i++) { ic.removeInterceptor(interceptorClass); ic.addInterceptor(interceptor, 1); } return null; } finally { log.debug("Wait for all execution paths to finish"); barrier.await(); } } }
@TestCachePermission(AuthorizationPermission.ADMIN) public void testAddInterceptorBefore_CommandInterceptor_Class(SecureCache<String, String> cache) { cache.getAsyncInterceptorChain().addInterceptorBefore(interceptor, InvocationContextInterceptor.class); cache.getAsyncInterceptorChain().removeInterceptor(interceptor.getClass()); }
@TestCachePermission(AuthorizationPermission.ADMIN) public void testAddInterceptorAfter_CommandInterceptor_Class(SecureCache<String, String> cache) { cache.getAsyncInterceptorChain().addInterceptorAfter(interceptor, InvocationContextInterceptor.class); cache.getAsyncInterceptorChain().removeInterceptor(interceptor.getClass()); }
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); } }
@TestCachePermission(AuthorizationPermission.ADMIN) public void testRemoveInterceptor_int(SecureCache<String, String> cache) { cache.getAsyncInterceptorChain().addInterceptor(interceptor, 0); cache.getAsyncInterceptorChain().removeInterceptor(0); }
@TestCachePermission(AuthorizationPermission.ADMIN) public void testAddInterceptor_CommandInterceptor_int(SecureCache<String, String> cache) { cache.getAsyncInterceptorChain().addInterceptor(interceptor, 0); cache.getAsyncInterceptorChain().removeInterceptor(0); }
cache.getAsyncInterceptorChain().removeInterceptor(BlockingInterceptor.class);
throw new IllegalStateException("Misconfigured cache, interceptor chain is " + chain); chain.removeInterceptor(NonTransactionalLockingInterceptor.class); chain.removeInterceptor(NonTxDistributionInterceptor.class); chain.removeInterceptor(TriangleDistributionInterceptor.class);
public void testTimeoutCleanup() throws Exception { final CountDownLatch block = new CountDownLatch(1); final BaseCustomAsyncInterceptor interceptor = new BaseCustomAsyncInterceptor() { @Override public Object visitPrepareCommand(TxInvocationContext ctx, PrepareCommand command) throws Throwable { block.await(); return invokeNext(ctx, command); } }; final AsyncInterceptorChain chain = TestingUtil.extractComponent(cache(1), AsyncInterceptorChain.class); final Object key = new MagicKey(cache(1)); try { chain.addInterceptor(interceptor, 0); tm(0).begin(); cache(0).put(key, "v"); tm(0).commit(); fail("Rollback expected!"); } catch (RollbackException e) { //expected } finally { block.countDown(); chain.removeInterceptor(0); } assertNoTransactions(); assertNoLocks(); }
nonOwner.getAdvancedCache().getAsyncInterceptorChain().removeInterceptor(BlockingInterceptor.class);
interceptorChain.removeInterceptor(CollectionUpdateTestInterceptor.class); interceptorChain.removeInterceptor(AnotherCollectionUpdateTestInterceptor.class);
cache0.getAdvancedCache().getAsyncInterceptorChain().removeInterceptor(BlockingInterceptor.class); cache2.getAdvancedCache().getAsyncInterceptorChain().removeInterceptor(BlockingInterceptor.class); blockingInterceptor0.suspend(true); blockingInterceptor2.suspend(true);
public void testStateTransfer() throws Exception { CyclicBarrier barrier = new CyclicBarrier(2); blockDataContainerIteration(cache(0), barrier); Set<Object> keys = new HashSet<>(); for (int i = 0; i < NUM_KEYS; i++) { Object key = getKeyForCache(0); if (!keys.add(key)) continue; // put a key to have some data in cache cache(0).put(key, key); } log.trace("State transfer happens here"); // add a third node addClusterEnabledCacheManager(dccc); waitForClusterToForm(); // Wait for the stale entries invalidation to block barrier.await(10, TimeUnit.SECONDS); log.trace("Checking the values from caches..."); for (Object key : keys) { // Expect one copy of each entry on the old owner, cache 0 assertEquals(1, checkKey(key, cache(0))); } // Unblock the stale entries invalidation barrier.await(10, TimeUnit.SECONDS); cache(0).getAdvancedCache().getAsyncInterceptorChain().removeInterceptor(BlockingInterceptor.class); for (Object key : keys) { // Check that the stale entries on the old nodes are eventually deleted eventuallyEquals(1, () -> checkKey(key, cache(0), cache(1), cache(2))); } }
nonOwner.getAdvancedCache().getAsyncInterceptorChain().removeInterceptor(BlockingInterceptor.class);