public CompletionStage<BlockedResponseMap> expectAllResponsesAsync() { request.throwIfFailed(); assertFalse(request.isDone()); return request.finishFuture() .thenApply(responseMap -> new BlockedResponseMap(request, responseMap)); } }
blockedPrepare.send().receiveAll(); } else { blockedPrepareResponses.receive(); rpcManager.expectCommand(VersionedCommitCommand.class).send().receiveAll();
public CompletionStage<Void> replaceAsync(Map<Address, Response> newResponses) { return CompletableFuture.runAsync(() -> replace(newResponses), request.executor); }
for (Map.Entry<Address, Response> rsp : blockedGet.getResponses().entrySet()) { if (rsp.getValue().isSuccessful()) { if (expectSuccessFrom >= 0) { blockedGet.receive(); if (succesful == 0) { rpcManager0.expectCommand(ClusteredGetCommand.class).send().receiveAll();
awaitForTopology(currentTopologyId + 4, cache(0)); blockedPrepare.receive();
firstRemoteGet.expectAllResponses().receiveAsync(); for (int i = 1; i < expectRemoteGets; ++i) { crm2.expectCommand(BaseClusteredReadCommand.class).send().receiveAll(); sentPrepare.expectAllResponses().receiveAsync(); crm0.expectCommand(CommitCommand.class).send().receiveAll(); crm0.expectCommand(TxCompletionNotificationCommand.class).send();
blockedPrepare.send().receiveAll(); } else { blockedPrepareResponses.receive(); rpcManager.expectCommand(VersionedCommitCommand.class).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(); } }
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"); }
/** * Wait for all the responses and process them. */ public void receiveAll() { expectAllResponses().receive(); }