static DiscardHandler replaceOn(Cache<?, ?> cache) { return wrapInboundInvocationHandler(cache, DiscardHandler::new); }
static FailureHandler replaceOn(Cache<?, ?> cache) { return wrapInboundInvocationHandler(cache, FailureHandler::new); }
private PerCacheInboundInvocationHandler spyInvocationHandler(Cache cache) { return wrapInboundInvocationHandler(cache, Mockito::spy); } }
private void replaceInboundInvocationHandler() { if (ourHandler == null) { ourHandler = wrapInboundInvocationHandler(cache, handler -> new SequencerPerCacheInboundInvocationHandler(handler, stateSequencer, matcher)); } }
protected CountDownLatch expectAfterEndInvalidation(AdvancedCache cache, int numInvalidates) { CountDownLatch latch = new CountDownLatch(numInvalidates); wrapInboundInvocationHandler(cache, handler -> new ExpectingInboundInvocationHandler(handler, latch)); return latch; }
private void dropClusteredGetCommands() { IntStream.range(0, numMembersInCluster).forEach(i -> wrapInboundInvocationHandler(getCache(i), DropClusteredGetCommandHandler::new)); }
private static void wrapAndApplyFilter(Cache<?, ?> cache, Filter filter) { ControlledInboundHandler controlledInboundHandler = wrapInboundInvocationHandler(cache, delegate -> new ControlledInboundHandler(delegate, filter)); }
private void dropLockCommandInPrimary() { TestingUtil.wrapInboundInvocationHandler(cache(1), DropLockCommandHandler::new); }
protected void removeAfterEndInvalidationHandler(AdvancedCache cache) { wrapInboundInvocationHandler(cache, handler -> ((ExpectingInboundInvocationHandler) handler).getDelegate()); }
private void delayStateTransferCompletion(CountDownLatch latch) { IntStream.range(0, numMembersInCluster).forEach(i -> wrapInboundInvocationHandler(getCache(i), delegate -> new DelayStateResponseCommandHandler(latch, delegate))); }
private CompletableFuture<StateRequestCommand> createStateRequestFuture() { int segment = PARTITIONER.getSegment(DURING_CR_CRASH_KEY); CompletableFuture<StateRequestCommand> future = new CompletableFuture<>(); wrapInboundInvocationHandler(cache(2), handler -> new CompleteFutureOnStateRequestHandler(handler, segment, manager(2), future)); return future; }
public void testRehashOnJoin() throws InterruptedException { Cache<Object, Object> firstNode = cache(0); final CountDownLatch txsStarted = new CountDownLatch(3), txsReady = new CountDownLatch(3), joinEnded = new CountDownLatch(1), rehashStarted = new CountDownLatch(1); wrapInboundInvocationHandler(firstNode, original -> new ListeningHandler(original, txsReady, joinEnded, rehashStarted));
try { IntStream.range(0, numMembersInCluster).forEach(i -> { wrapInboundInvocationHandler(cache(i), handler -> new BlockStateResponseCommandHandler(handler, conflictLatch)); EmbeddedCacheManager manager = manager(i); InboundInvocationHandler handler = extractGlobalComponent(manager, InboundInvocationHandler.class);
@Override protected void createCacheManagers() throws Throwable { ConfigurationBuilder builder = getDefaultClusteredCacheConfig(CacheMode.SCATTERED_SYNC, false); builder.clustering().biasAcquisition(BiasAcquisition.ON_WRITE); // Scan biases frequently builder.expiration().wakeUpInterval(100); createCluster(builder, 3); waitForClusterToForm(); Arrays.stream(managers()).forEach( cm -> TestingUtil.replaceComponent(cm, TimeService.class, timeService, true)); rpcManager0 = ControlledRpcManager.replaceRpcManager(cache(0)); rpcManager1 = CountingRpcManager.replaceRpcManager(cache(1)); TestingUtil.wrapInboundInvocationHandler(cache(0), handler -> handler0 = new RenewWaitingInvocationHandler(handler)); }
public void testReplay() throws Exception { final Object key = new MagicKey("TxReplay3Test", cache(0)); final StateSequencer sequencer = new StateSequencer(); sequencer.logicalThread("tx1", TX1_LOCKED, TX1_UNSURE); sequencer.logicalThread("tx2", TX2_PENDING); sequencer.logicalThread("join", JOIN_NEW_NODE); sequencer.logicalThread("main", MAIN_ADVANCE); sequencer.order(TX1_LOCKED, MAIN_ADVANCE, TX2_PENDING, JOIN_NEW_NODE, TX1_UNSURE); wrapComponent(cache(1), RpcManager.class, (wrapOn, current) -> new UnsureResponseRpcManager(current, sequencer), true); Handler handler = wrapInboundInvocationHandler(cache(0), current -> new Handler(current, sequencer)); handler.setOrigin(address(cache(2))); Future<Void> tx1 = fork(() -> { cache(1).put(key, VALUE_1); return null; }); sequencer.advance(MAIN_ADVANCE); Future<Void> tx2 = fork(() -> { cache(2).put(key, VALUE_2); return null; }); sequencer.enter(JOIN_NEW_NODE); addClusterEnabledCacheManager(config()).getCache(); waitForClusterToForm(); sequencer.exit(JOIN_NEW_NODE); tx1.get(30, TimeUnit.SECONDS); tx2.get(30, TimeUnit.SECONDS); assertEquals(VALUE_2, cache(0).get(key)); }
ControllerInboundInvocationHandler handler = wrapInboundInvocationHandler(cache(0), ControllerInboundInvocationHandler::new); BackupOwnerInterceptor backupOwnerInterceptor = injectBackupOwnerInterceptor(cache(0)); backupOwnerInterceptor.blockCommit(true);