com.palantir.atlasdb.transaction.api.TransactionManager.setupRunTaskWithConditionThrowOnConflict()方法的使用及代码示例

x33g5p2x  于2022-01-30 转载在 其他  
字(1.8k)|赞(0)|评价(0)|浏览(148)

本文整理了Java中com.palantir.atlasdb.transaction.api.TransactionManager.setupRunTaskWithConditionThrowOnConflict()方法的一些代码示例,展示了TransactionManager.setupRunTaskWithConditionThrowOnConflict()的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。TransactionManager.setupRunTaskWithConditionThrowOnConflict()方法的具体详情如下:
包路径:com.palantir.atlasdb.transaction.api.TransactionManager
类名称:TransactionManager
方法名:setupRunTaskWithConditionThrowOnConflict

TransactionManager.setupRunTaskWithConditionThrowOnConflict介绍

[英]This method can be used for direct control of a transaction's life cycle. For example, if the work done in the transaction is interactive and cannot be expressed as a TransactionTask ahead of time, this method allows for a long lived transaction object. For the any data read or written to the transaction to be valid, the transaction must be committed, preferably by calling #finishRunTaskWithLockThrowOnConflict(TransactionAndImmutableTsLock,TransactionTask) to also perform additional cleanup.
[中]此方法可用于直接控制事务的生命周期。例如,如果事务中完成的工作是交互式的,并且不能提前表示为TransactionTask,则此方法允许使用寿命较长的事务对象。为了使读写到事务中的任何数据都有效,必须提交事务,最好通过调用#FinishRunTaskWithLockThrowonColflict(TransactionAndImmutableTsLock,TransactionTask)来执行额外的清理。

代码示例

代码示例来源:origin: palantir/atlasdb

@Override
public TransactionToken startTransaction() {
  String id = UUID.randomUUID().toString();
  TransactionToken token = new TransactionToken(id);
  TransactionAndImmutableTsLock txAndLock =
      txManager.setupRunTaskWithConditionThrowOnConflict(PreCommitConditions.NO_OP);
  transactions.put(token, txAndLock);
  return token;
}

代码示例来源:origin: com.palantir.atlasdb/atlasdb-service

@Override
public TransactionToken startTransaction() {
  String id = UUID.randomUUID().toString();
  TransactionToken token = new TransactionToken(id);
  TransactionAndImmutableTsLock txAndLock =
      txManager.setupRunTaskWithConditionThrowOnConflict(PreCommitConditions.NO_OP);
  transactions.put(token, txAndLock);
  return token;
}

相关文章