public Object visitPutKeyValueCommand(InvocationContext ctx, PutKeyValueCommand command) throws Throwable {
// needed by the stat transfer.
if (command.hasFlag(Flag.SKIP_LOCKING))
return invokeNextInterceptor(ctx, command);
final TxInvocationContext txContext = (TxInvocationContext) ctx;
try {
// The primary owner check doesn't work for preload, as we don't have a topology yet
boolean localOnly = command.hasFlag(Flag.CACHE_MODE_LOCAL);
boolean localLock = localOnly || cdl.localNodeIsPrimaryOwner(command.getKey());
acquireRemoteIfNeeded(ctx, command, localLock);
if (localLock) {
boolean skipLocking = hasSkipLocking(command);
long lockTimeout = getLockAcquisitionTimeout(command, skipLocking);
lockKeyAndCheckOwnership(ctx, command.getKey(), lockTimeout, skipLocking);
} else if (cdl.localNodeIsOwner(command.getKey())) {
txContext.getCacheTransaction().addBackupLockForKey(command.getKey());
}
return invokeNextInterceptor(ctx, command);
} catch (Throwable te) {
releaseLocksOnFailureBeforePrepare(ctx);
throw te;