コード例 #1
0
  // We need this method in here because of putForExternalRead
  protected final BasicInvocationStage visitNonTxDataWriteCommand(
      InvocationContext ctx, DataWriteCommand command) throws Throwable {
    if (hasSkipLocking(command) || !shouldLockKey(command.getKey())) {
      return invokeNext(ctx, command);
    }

    try {
      lockAndRecord(ctx, command.getKey(), getLockTimeoutMillis(command));
    } catch (Throwable t) {
      lockManager.unlockAll(ctx);
      throw t;
    }
    return invokeNext(ctx, command).handle(unlockAllReturnHandler);
  }
コード例 #2
0
 /**
  * Locks the value for the keys accessed by the command to avoid being override from a remote get.
  */
 private CompletableFuture<Void> setSkipRemoteGetsAndInvokeNextForDataCommand(
     InvocationContext context, DataWriteCommand command, Metadata metadata) throws Throwable {
   Object retVal = invokeNextAndApplyChanges(context, command, metadata);
   if (context.isInTxScope()) {
     CacheEntry entry = context.lookupEntry(command.getKey());
     if (entry != null) {
       entry.setSkipLookup(true);
     }
   }
   return context.shortCircuit(retVal);
 }