Source:
private Object handleLocalPutMapCommand(InvocationContext ctx, PutMapCommand command) { final LocalizedCacheTopology cacheTopology = checkTopologyId(command); final ConsistentHash consistentHash = cacheTopology.getWriteConsistentHash(); final PrimaryOwnerClassifier filter = new PrimaryOwnerClassifier(cacheTopology, command.getMap().size()); final boolean sync = isSynchronous(command); final VisitableCommand.LoadType loadType = command.loadType(); command.getMap().entrySet().forEach(filter::add); if (sync) { commandAckCollector .createMultiKeyCollector(command.getCommandInvocationId().getId(), filter.primaries.keySet(), filter.backups, command.getTopologyId()); final Map<Object, Object> localEntries = filter.primaries.remove(localAddress); forwardToPrimaryOwners(command, filter); if (localEntries != null) { sendToBackups(command, localEntries, cacheTopology); CompletableFuture<?> remoteGet = checkRemoteGetIfNeeded(ctx, command, localEntries.keySet(), cacheTopology, loadType == PRIMARY || loadType == OWNER); return makeStage(asyncInvokeNext(ctx, command, remoteGet)) .andFinally(ctx, command, onPutMapWithLocalEntries); } return invokeNextAndExceptionally(ctx, command, onPutMapNoLocalEntriesException); } final Map<Object, Object> localEntries = filter.primaries.remove(localAddress); forwardToPrimaryOwners(command, filter); if (localEntries != null) { sendToBackups(command, localEntries, cacheTopology); return asyncInvokeNext(ctx, command, checkRemoteGetIfNeeded(ctx, command, localEntries.keySet(), cacheTopology, loadType == PRIMARY || loadType == OWNER)); } return invokeNext(ctx, command); }

Target:
private Object handleLocalPutMapCommand(InvocationContext ctx, PutMapCommand command) { final LocalizedCacheTopology cacheTopology = checkTopologyId(command); final PrimaryOwnerClassifier filter = new PrimaryOwnerClassifier(cacheTopology, command.getMap().size()); final boolean sync = isSynchronous(command); final VisitableCommand.LoadType loadType = command.loadType(); command.getMap().entrySet().forEach(filter::add); if (sync) { Collector<Map<Object, Object>> collector = commandAckCollector .createMultiKeyCollector(command.getCommandInvocationId().getId(), filter.primaries.keySet(), filter.backups, command.getTopologyId()); CompletableFuture<Map<Object, Object>> localResult = new CompletableFuture<>(); final Map<Object, Object> localEntries = filter.primaries.remove(localAddress); forwardToPrimaryOwners(command, filter, localResult).handle((map, throwable) -> { if (throwable != null) { collector.primaryException(throwable); } else { collector.primaryResult(map, true); } return null; }); if (localEntries != null) { sendToBackups(command, localEntries, cacheTopology); CompletableFuture<?> remoteGet = checkRemoteGetIfNeeded(ctx, command, localEntries.keySet(), cacheTopology, loadType == PRIMARY || loadType == OWNER); return makeStage(asyncInvokeNext(ctx, command, remoteGet)) .andHandle(ctx, command, (rCtx, rCommand, rv, throwable) -> { if (throwable != null) { localResult.completeExceptionally(CompletableFutures.extractException(throwable)); } else { localResult.complete((Map<Object, Object>) rv); } return asyncValue(collector.getFuture()); }); } else { localResult.complete(new HashMap<>()); return asyncValue(collector.getFuture()); } } final Map<Object, Object> localEntries = filter.primaries.remove(localAddress); forwardToPrimaryOwners(command, filter); if (localEntries != null) { sendToBackups(command, localEntries, cacheTopology); return asyncInvokeNext(ctx, command, checkRemoteGetIfNeeded(ctx, command, localEntries.keySet(), cacheTopology, loadType == PRIMARY || loadType == OWNER)); } return null; }