protected BlockingInterceptor addBlockingInterceptor(Cache<?, ?> cache, final CyclicBarrier barrier, Class<? extends VisitableCommand> commandClass, Class<? extends AsyncInterceptor> interceptorPosition, boolean blockAfterCommand) { BlockingInterceptor bi = new BlockingInterceptor<>(barrier, commandClass, blockAfterCommand, false); AsyncInterceptorChain interceptorChain = cache.getAdvancedCache().getAsyncInterceptorChain(); assertTrue(interceptorChain.addInterceptorBefore(bi, interceptorPosition)); return bi; }
private Future<?> blockedPutFromLoad(CyclicBarrier putFromLoadBarrier) throws InterruptedException, BrokenBarrierException, TimeoutException { BlockingInterceptor blockingInterceptor = new BlockingInterceptor(putFromLoadBarrier, ReadWriteKeyCommand.class, false, true); entityCache.getAsyncInterceptorChain().addInterceptor(blockingInterceptor, 0); cleanup.add(() -> entityCache.removeInterceptor(BlockingInterceptor.class)); // the putFromLoad should be blocked in the interceptor Future<?> putFromLoad = executor.submit(() -> withTxSessionApply(s -> { assertEquals("Original item", s.load(Item.class, itemId).getDescription()); return null; })); putFromLoadBarrier.await(WAIT_TIMEOUT, TimeUnit.SECONDS); blockingInterceptor.suspend(true); return putFromLoad; }
BlockingInterceptor bi = new BlockingInterceptor<>(barrier, ReadWriteKeyCommand.class, true, false); cache.getAsyncInterceptorChain().addInterceptorBefore(bi, EntryWrappingInterceptor.class);
public void test() throws Exception { MagicKey key = new MagicKey(cache(0), cache(1)); cache(2).put(key, "value"); CyclicBarrier barrier0 = new CyclicBarrier(2); cache(0).getAdvancedCache().getAsyncInterceptorChain().addInterceptorBefore( new BlockingInterceptor<>(barrier0, GetCacheEntryCommand.class, false, false), EntryWrappingInterceptor.class); Future<Object> f = fork(() -> cache(2).get(key)); barrier0.await(10, TimeUnit.SECONDS); cache(0).stop(); barrier0.await(10, TimeUnit.SECONDS); assertEquals("value", f.get(10, TimeUnit.SECONDS)); } }
BlockingInterceptor blockingInterceptor = new BlockingInterceptor<>(distInterceptorBarrier, PutKeyValueCommand.class, false, false); cache0.getAsyncInterceptorChain().addInterceptorBefore(blockingInterceptor, TriangleDistributionInterceptor.class);
.addInterceptorAfter(new BlockingInterceptor<>(barrier, InvalidateL1Command.class, true, false), EntryWrappingInterceptor.class);
BlockingInterceptor blockingInterceptor0 = new BlockingInterceptor<>(barrier, PutKeyValueCommand.class, true, false); cache0.getAdvancedCache().getAsyncInterceptorChain().addInterceptorBefore(blockingInterceptor0, EntryWrappingInterceptor.class); BlockingInterceptor blockingInterceptor2 = new BlockingInterceptor<>(barrier, PutKeyValueCommand.class, true, false); cache2.getAdvancedCache().getAsyncInterceptorChain().addInterceptorBefore(blockingInterceptor2, EntryWrappingInterceptor.class);
BlockingInterceptor blockingInterceptor = new BlockingInterceptor<>(barrier, PutKeyValueCommand.class, true, false); cache1.getAdvancedCache().getAsyncInterceptorChain().addInterceptorBefore(blockingInterceptor, TriangleDistributionInterceptor.class);
.interceptor(new BlockingInterceptor<>(barrier2, GetCacheEntryCommand.class, true, false))); .addInterceptor(new BlockingInterceptor<>(barrier1, GetCacheEntryCommand.class, false, false), 0);
BlockingInterceptor blockingInterceptor1 = new BlockingInterceptor<>(beforeCommitCache1Barrier, true, false, cacheMode.isScattered() ? t -> t instanceof PutKeyValueCommand || t instanceof RemoveCommand : t -> t.getClass().equals(op.getCommandClass()));
BlockingInterceptor blockingInterceptor1 = new BlockingInterceptor<>(beforeCache1Barrier, op.getCommandClass(), false, false); cache1.getAsyncInterceptorChain().addInterceptorBefore(blockingInterceptor1, TriangleDistributionInterceptor.class); BlockingInterceptor blockingInterceptor2 = new BlockingInterceptor<>(afterCache2Barrier, op.getCommandClass(), true, false, cmd -> !(cmd instanceof FlagAffectedCommand) || !((FlagAffectedCommand) cmd).hasAnyFlag(FlagBitSets.PUT_FOR_STATE_TRANSFER));
BlockingInterceptor blockingInterceptor1 = new BlockingInterceptor<>(beforeCommitCache1Barrier, getVisitableCommand(op), false, false); primaryOwnerCache.getAsyncInterceptorChain().addInterceptorAfter(blockingInterceptor1, StateTransferInterceptor.class);
BlockingInterceptor blockingInterceptor0 = new BlockingInterceptor<>(beforeCache0Barrier, op.getCommandClass(), false, true); cache0.getAsyncInterceptorChain().addInterceptorBefore(blockingInterceptor0, EntryWrappingInterceptor.class);
new BlockingInterceptor<>(cyclicBarrier, getVisitableCommand(op), true, false), StateTransferInterceptor.class); return op.perform(primaryOwnerCache, key);
BlockingInterceptor oteInterceptor = new BlockingInterceptor(oteBarrier, GetKeyValueCommand.class, true, true); cache(2).getAdvancedCache().getAsyncInterceptorChain().addInterceptorAfter(oteInterceptor, StateTransferInterceptor.class);
BlockingInterceptor blockingInterceptor1 = new BlockingInterceptor<>(beforeCommitCache1Barrier, op.getCommandClass(), true, false); nonOwnerCache.getAsyncInterceptorChain().addInterceptorAfter(blockingInterceptor1, EntryWrappingInterceptor.class);