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

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

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

Transaction.isUncommitted介绍

[英]Gets whether the transaction has not been committed.
[中]获取事务是否尚未提交。

代码示例

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

@Override
public void get(long firstBlock, long numBlocks, OutputStream destination) {
  if (parent.isUncommitted()) {
    loadNBlocksToOutputStream(parent, id, firstBlock, numBlocks, destination);
  } else {
    txnMgr.runTaskReadOnly(txn -> {
      loadNBlocksToOutputStream(txn, id, firstBlock, numBlocks, destination);
      return null;
    });
  }
}

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

@Override
public boolean isUncommitted() {
  return delegate().isUncommitted();
}

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

protected final <T, E extends Exception> T runTaskThrowOnConflict(TransactionTask<T, E> task, Transaction txn)
    throws E, TransactionFailedException {
  checkOpen();
  try {
    T ret = task.execute(txn);
    if (txn.isUncommitted()) {
      txn.commit();
    }
    return ret;
  } finally {
    // Make sure that anyone trying to retain a reference to this transaction
    // will not be able to use it.
    if (txn.isUncommitted()) {
      txn.abort();
    }
  }
}

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

@Override
public void get(long firstBlock, long numBlocks, OutputStream destination) {
  if (parent.isUncommitted()) {
    loadNBlocksToOutputStream(parent, id, firstBlock, numBlocks, destination);
  } else {
    txnMgr.runTaskReadOnly(txn -> {
      loadNBlocksToOutputStream(txn, id, firstBlock, numBlocks, destination);
      return null;
    });
  }
}

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

@Override
public boolean isUncommitted() {
  return delegate().isUncommitted();
}

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

protected final <T, E extends Exception> T runTaskThrowOnConflict(TransactionTask<T, E> task, Transaction txn)
    throws E, TransactionFailedException {
  checkOpen();
  try {
    T ret = task.execute(txn);
    if (txn.isUncommitted()) {
      txn.commit();
    }
    return ret;
  } finally {
    // Make sure that anyone trying to retain a reference to this transaction
    // will not be able to use it.
    if (txn.isUncommitted()) {
      txn.abort();
    }
  }
}

相关文章