/** * Expect a command to be invoked remotely and send replies using the {@link BlockedRequest} methods. */ public <T extends ReplicableCommand> CompletableFuture<BlockedRequest> expectCommandAsync(Class<T> expectedCommandClass) { throwGlobalError(); log.tracef("Waiting for command %s", expectedCommandClass); CompletableFuture<ControlledRequest> future = new CompletableFuture<>(); waiters.add(future); return future.thenApply(request -> { log.tracef("Blocked command %s", request.command); assertTrue("Expecting a " + expectedCommandClass.getName() + ", got " + request.getCommand(), expectedCommandClass.isInstance(request.getCommand())); return new BlockedRequest<T>(request); }); }
public <T extends ReplicableCommand> BlockedRequests expectCommands(Class<T> expectedCommandClass, Collection<Address> targets) { Map<Address, BlockedRequest<T>> requests = new HashMap<>(); for (int i = 0; i < targets.size(); i++) { BlockedRequest request = expectCommand(expectedCommandClass); requests.put(request.getTarget(), request); } assertEquals(new HashSet<>(targets), requests.keySet()); return new BlockedRequests(requests); }
if (invokePhase > 0) { assertEquals(Collections.singleton(address(0)), blockedPrefetch.getTargets()); ControlledRpcManager.SentRequest remotePrefetch = blockedPrefetch.send();
blockingRpcManager0.expectCommand(StateRequestCommand.class).send().receiveAll(); blockingRpcManager2.expectCommand(StateRequestCommand.class).send().receiveAll(); blockedStateRequest2.send().receiveAll(); blockedStateResponse0.send().receiveAll(); blockedStateRequest0.send().receiveAll(); blockingRpcManager2.expectCommand(StateResponseCommand.class).send().receiveAll(); checkPoint.awaitStrict("pre_rebalance_confirmation_" + rebalanceTopologyId + "_from_" + primaryOwnerCache.getCacheManager().getAddress(), 10, SECONDS);
ControlledRpcManager.SentRequest sentGet = rpcManager0.expectCommand(ClusteredGetCommand.class).send(); barrier2.await(10, TimeUnit.SECONDS); barrier2.await(10, TimeUnit.SECONDS); ControlledRpcManager.SentRequest sentRetry = rpcManager0.expectCommand(ClusteredGetCommand.class).send(); barrier1.await(10, TimeUnit.SECONDS); barrier1.await(10, TimeUnit.SECONDS);
blockingRpcManager0.expectCommand(StateResponseCommand.class); ControlledRpcManager.SentRequest sentStateResponse = blockedStateResponse.send();
expectStateRequestCommand(crm2, StateRequestCommand.Type.GET_TRANSACTIONS).send().receiveAll(); expectStateRequestCommand(crm2, StateRequestCommand.Type.START_STATE_TRANSFER).send().receiveAll(); ControlledRpcManager.BlockedRequest blockedStateResponse0 = crm0.expectCommand(StateResponseCommand.class); assertTrue(topologyChangeLatch.await(10, TimeUnit.SECONDS)); Future<Void> commitFuture = fork(transaction::commit); ControlledRpcManager.SentRequest sentPrepare = crm0.expectCommand(PrepareCommand.class).send(); ControlledRpcManager.SentRequest firstRemoteGet = crm2.expectCommand(BaseClusteredReadCommand.class).send(); crm2.expectCommand(BaseClusteredReadCommand.class).send().receiveAll(); crm0.expectCommand(CommitCommand.class).send().receiveAll(); crm0.expectCommand(TxCompletionNotificationCommand.class).send(); blockedStateResponse0.send().receiveAll();
nodeARpcManager.expectCommand(VersionedPrepareCommand.class).send().expectAllResponses(); assertEquals(0, nodeC.commandLatch.getCount()); nodeARpcManager.expectCommand(PrepareCommand.class).send().receiveAll(); nodeARpcManager.expectCommand(CommitCommand.class).send().receiveAll(); nodeARpcManager.expectCommand(TxCompletionNotificationCommand.class).send(); assertNull("Wrong put() return value.", tx.get());
ControlledRpcManager.BlockedResponseMap blockedPrepareResponses = null; if (!pessimistic) { blockedPrepareResponses = blockedPrepare.send().expectAllResponses(); blockedPrepare.send().receiveAll(); } else { blockedPrepareResponses.receive(); rpcManager.expectCommand(VersionedCommitCommand.class).send().receiveAll(); rpcManager.expectCommand(TxCompletionNotificationCommand.class).send(); Assert.assertTrue(txOutcome.get()); } finally {
ControlledRpcManager.BlockedResponseMap blockedPrepareResponses = null; if (!pessimistic) { blockedPrepareResponses = blockedPrepare.send().expectAllResponses(); blockedPrepare.send().receiveAll(); } else { blockedPrepareResponses.receive(); rpcManager.expectCommand(VersionedCommitCommand.class).send().receiveAll(); rpcManager.expectCommand(TxCompletionNotificationCommand.class).send(); Assert.assertTrue(txOutcome.get()); } finally {
ControlledRpcManager.BlockedRequest blockedGet = rpcManager0.expectCommand(ClusteredGetCommand.class); blockedGet.send().receiveAll();
controlledRpcManager.expectCommand(ClusteredGetCommand.class).send().receiveAll(); controlledRpcManager.expectCommand(PrepareCommand.class).send().receiveAll(); blockedCommit.send().receiveAll(); controlledRpcManager.expectCommand(CommitCommand.class).send().receiveAll(); controlledRpcManager.expectCommand(TxCompletionNotificationCommand.class).send();