Source:
private Object handleWriteOnOriginPrimary(InvocationContext ctx, DataWriteCommand command, Object rv, RepeatableReadEntry cacheEntry, Object seenValue, EntryVersion seenVersion, CacheTopology cacheTopology, DistributionInfo info) { if (!command.isSuccessful()) { if (trace) log.tracef("Skipping the replication of the command as it did not succeed on primary owner (%s).", command); return rv; } EntryVersion nextVersion = svm.incrementVersion(info.segmentId()); Metadata metadata = addVersion(cacheEntry.getMetadata(), nextVersion); cacheEntry.setMetadata(metadata); if (command.loadType() != DONT_LOAD) { commitSingleEntryIfNoChange(cacheEntry, ctx, command); } else { commitSingleEntryIfNewer(cacheEntry, ctx, command); } WriteCommand backupCommand; long flags = command.getFlagsBitSet() | FlagBitSets.SKIP_OWNERSHIP_CHECK; if (cacheEntry.isRemoved()) { backupCommand = cf.buildRemoveCommand(command.getKey(), null, flags); ((RemoveCommand) backupCommand).setMetadata(cacheEntry.getMetadata()); } else { backupCommand = cf.buildPutKeyValueCommand(command.getKey(), cacheEntry.getValue(), cacheEntry.getMetadata(), flags); } Address backup = getNextMember(cacheTopology); if (backup != null) { List<Address> recipients = Collections.singletonList(backup); assert recipients.size() == 1; CompletableFuture<?> rpcFuture = rpcManager.invokeRemotelyAsync(recipients, backupCommand, defaultSyncOptions); rpcFuture.thenRun(() -> { if (cacheEntry.isCommitted() && !command.hasAnyFlag(FlagBitSets.PUT_FOR_STATE_TRANSFER)) { scheduleKeyInvalidation(command.getKey(), cacheEntry.getMetadata().version(), cacheEntry.isRemoved()); } }); rpcFuture = completeSingleWriteOnPrimaryOriginator(command, backup, rpcFuture); return asyncValue(rpcFuture.thenApply(ignore -> rv)); } else { return rv; } }

Target:
private Object handleWriteOnOriginPrimary(InvocationContext ctx, DataWriteCommand command, Object rv, RepeatableReadEntry cacheEntry, Object seenValue, EntryVersion seenVersion, CacheTopology cacheTopology, DistributionInfo info) { if (!command.isSuccessful()) { if (trace) log.tracef("Skipping the replication of the command as it did not succeed on primary owner (%s).", command); return rv; } EntryVersion nextVersion = svm.incrementVersion(info.segmentId()); Metadata metadata = addVersion(cacheEntry.getMetadata(), nextVersion); cacheEntry.setMetadata(metadata); if (command.loadType() != DONT_LOAD) { commitSingleEntryIfNoChange(cacheEntry, ctx, command); } else { commitSingleEntryIfNewer(cacheEntry, ctx, command); } WriteCommand backupCommand; long flags = command.getFlagsBitSet() | FlagBitSets.SKIP_OWNERSHIP_CHECK; if (cacheEntry.isRemoved()) { backupCommand = cf.buildRemoveCommand(command.getKey(), null, flags); ((RemoveCommand) backupCommand).setMetadata(cacheEntry.getMetadata()); } else { backupCommand = cf.buildPutKeyValueCommand(command.getKey(), cacheEntry.getValue(), cacheEntry.getMetadata(), flags); } Address backup = getNextMember(cacheTopology); if (backup != null) { List<Address> recipients = Collections.singletonList(backup); CompletableFuture<?> rpcFuture = rpcManager.invokeRemotelyAsync(recipients, backupCommand, defaultSyncOptions); rpcFuture.thenRun(() -> { if (cacheEntry.isCommitted() && !command.hasAnyFlag(FlagBitSets.PUT_FOR_STATE_TRANSFER)) { scheduleKeyInvalidation(command.getKey(), cacheEntry.getMetadata().version(), cacheEntry.isRemoved()); } }); rpcFuture = completeSingleWriteOnPrimaryOriginator(command, backup, rpcFuture); return asyncValue(rpcFuture.thenApply(ignore -> rv)); } else { return rv; } }