/** * Unblock the request, sending it to its targets. * <p> * It will block again when waiting for responses. */ public SentRequest send(Address target) { return requests.get(target).send(); }
ControlledRpcManager.SentRequest remotePrefetch = blockedPrefetch.send();
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();
TestingUtil.waitForNoRebalance(c); blockedReplace.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();
blockedGet.send().receiveAll();
blockedGet.send().receiveAll();
public void testNoEntryInL1PutReplacedNullValueConcurrently() throws InterruptedException, ExecutionException, TimeoutException { final Cache<Object, String> nonOwnerCache = getFirstNonOwner(key); final Cache<Object, String> ownerCache = getFirstOwner(key); ControlledRpcManager crm = ControlledRpcManager.replaceRpcManager(nonOwnerCache); crm.excludeCommands(ClusteredGetCommand.class); try { Future<String> future = fork(() -> nonOwnerCache.putIfAbsent(key, firstValue)); // Now wait for the get to return and block it for now ControlledRpcManager.BlockedResponseMap blockedPutResponses = crm.expectCommand(PutKeyValueCommand.class).send().expectAllResponses(); // Owner should have the new value assertEquals(firstValue, ownerCache.remove(key)); // Now let owner key->updateValue go through blockedPutResponses.receive(); // This should be originalValue still as we did the get assertNull(future.get(5, TimeUnit.SECONDS)); // Remove the interceptor now since we don't want to block ourselves - if using phaser this isn't required removeAllBlockingInterceptorsFromCache(nonOwnerCache); assertIsNotInL1(nonOwnerCache, key); // The nonOwnerCache should retrieve new value as it isn't in L1 assertNull(nonOwnerCache.get(key)); assertIsNotInL1(nonOwnerCache, key); } finally { crm.revertRpcManager(); } }
public void testReplicationFailure() throws Exception { Cache<?, ?> cache = cache(0); ControlledRpcManager controlledRpcManager = ControlledRpcManager.replaceRpcManager(cache); try { Future<Void> future = fork(() -> { controlledRpcManager.expectCommand(VersionedPrepareCommand.class).fail(); controlledRpcManager.expectCommand(RollbackCommand.class).send().receiveAll(); }); TransactionManager tm = cache(0).getAdvancedCache().getTransactionManager(); tm.begin(); cache(0).put("k0", "v"); Exceptions.expectException(RollbackException.class, tm::commit); future.get(30, TimeUnit.SECONDS); } finally { controlledRpcManager.revertRpcManager(); } } }
blockedStateResponse.send().receiveAll(); Cache cache2 = future.get();
private void performTestOn(final Operation operation) throws Exception { final Object key = getKeyForCache(cache(0), cache(1)); cache(0).put(key, "v1"); assertKeyValue(key, "v1"); final ControlledRpcManager controlledRpcManager = ControlledRpcManager.replaceRpcManager(cache(1)); Future<Void> future = fork(() -> { operation.execute(cache(1), key, "v2"); return null; }); ControlledRpcManager.BlockedResponseMap blockedResponses = operation.expectCommand(controlledRpcManager) .send().expectAllResponses(); cache(0).put(key, "v3"); blockedResponses.receive(); future.get(); controlledRpcManager.stopBlocking(); assertKeyValue(key, "v3"); }
public void testBiasTimesOut() throws Exception { rpcManager0.excludeCommands(ExceptionAckCommand.class); MagicKey key = new MagicKey(cache(0)); cache(1).put(key, "v0"); assertTrue(biasManager(1).hasLocalBias(key)); timeService.advance(BIAS_LIFESPAN + 1); rpcManager0.expectCommand(RevokeBiasCommand.class).send().receiveAll(); // The local bias is invalidated synchronously with the sync command, but it may take few moments // to remove the remote bias. assertFalse(biasManager(1).hasLocalBias(key)); eventuallyEquals(null, () -> biasManager(0).getRemoteBias(key)); }