org.apache.tephra.Transaction.getTransactionId()方法的使用及代码示例

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

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

Transaction.getTransactionId介绍

[英]Returns the initial write pointer assigned to the transaction. This will remain the same for the life of the transaction, and uniquely identifies it with the transaction service. This value should be provided to identify the transaction when calling any transaction lifecycle methods on the transaction service.
[中]返回分配给事务的初始写入指针。这将在事务的生命周期内保持不变,并用事务服务唯一地标识它。在事务服务上调用任何事务生命周期方法时,应提供此值以标识事务。

代码示例

代码示例来源:origin: apache/phoenix

@Override
public long getTransactionId() {
  Transaction tx = getCurrentTransaction();
  return tx == null ? HConstants.LATEST_TIMESTAMP : tx.getTransactionId(); // First write pointer - won't change with checkpointing
}

代码示例来源:origin: org.apache.tephra/tephra-core

@Override
public void canCommitOrThrow(Transaction tx, Collection<byte[]> changeIds)
 throws TransactionFailureException {
 if (!changeIds.isEmpty()) {
  txManager.canCommit(tx.getTransactionId(), changeIds);
 }
}

代码示例来源:origin: com.aliyun.phoenix/ali-phoenix-core

@Override
public long getTransactionId() {
  Transaction tx = getCurrentTransaction();
  return tx == null ? HConstants.LATEST_TIMESTAMP : tx.getTransactionId(); // First write pointer - won't change with checkpointing
}

代码示例来源:origin: co.cask.cdap/cdap-data-fabric

private Location getQuarantineLocation() throws IOException {
 // each transaction must not share its quarantine directory with another transaction
 return files.getBaseLocation().append(QUARANTINE_DIR + "." + tx.getTransactionId());
}

代码示例来源:origin: cdapio/cdap

private Location getQuarantineLocation() throws IOException {
 // each transaction must not share its quarantine directory with another transaction
 return files.getBaseLocation().append(QUARANTINE_DIR + "." + tx.getTransactionId());
}

代码示例来源:origin: org.apache.phoenix/phoenix-core

@Override
public long getTransactionId() {
  Transaction tx = getCurrentTransaction();
  return tx == null ? HConstants.LATEST_TIMESTAMP : tx.getTransactionId(); // First write pointer - won't change with checkpointing
}

代码示例来源:origin: org.apache.tephra/tephra-core

@Override
public Collection<byte[]> getTxChanges() {
 if (tx == null) {
  throw new IllegalStateException("Transaction has not started yet");
 }
 return Collections.singleton(Bytes.concat(fenceId, Longs.toByteArray(tx.getTransactionId())));
}

代码示例来源:origin: org.apache.tephra/tephra-core

@Override
 public Void execute(TransactionServiceThriftClient client) throws Exception {
  client.commit(tx.getTransactionId(), tx.getWritePointer());
  return null;
 }
});

代码示例来源:origin: org.apache.tephra/tephra-core

@Override
public void commitOrThrow(Transaction tx) throws TransactionFailureException {
 txManager.commit(tx.getTransactionId(), tx.getWritePointer());
}

代码示例来源:origin: cdapio/cdap

/**
 * Commits the current transaction.
 */
private void commit() throws TransactionFailureException {
 try {
  txClient.commitOrThrow(currentTx);
 } catch (TransactionFailureException e) {
  abort(e);
 } catch (Throwable e) {
  abort(new TransactionFailureException(
   String.format("Exception from commit for transaction %d.", currentTx.getTransactionId()), e));
 }
}

代码示例来源:origin: org.apache.tephra/tephra-core

private void commit() throws TransactionFailureException {
 try {
  txClient.commitOrThrow(currentTx);
 } catch (TransactionFailureException e) {
  abort(e);
  // abort will rethrow this exception
 } catch (Throwable e) {
  String message = String.format("Exception from commit for transaction %d.", currentTx.getTransactionId());
  abort(new TransactionFailureException(message, e));
  // abort will throw that exception
 }
}

代码示例来源:origin: co.cask.cdap/cdap-data-fabric

/**
 * Commits the current transaction.
 */
private void commit() throws TransactionFailureException {
 try {
  txClient.commitOrThrow(currentTx);
 } catch (TransactionFailureException e) {
  abort(e);
 } catch (Throwable e) {
  abort(new TransactionFailureException(
   String.format("Exception from commit for transaction %d.", currentTx.getTransactionId()), e));
 }
}

代码示例来源:origin: cdapio/cdap

@Override
public TransactionContext newTransactionContext() throws TransactionFailureException {
 if (txContext != null && txContext.getCurrentTransaction() != null) {
  throw new TransactionFailureException("Attempted to start a transaction within active transaction " +
                      txContext.getCurrentTransaction().getTransactionId());
 }
 dismissTransactionContext();
 txContext = new DelayedDiscardingTransactionContext(txClient, activeTxAwares.values());
 return txContext;
}

代码示例来源:origin: co.cask.cdap/cdap-data-fabric

@Override
public TransactionContext newTransactionContext() throws TransactionFailureException {
 if (txContext != null && txContext.getCurrentTransaction() != null) {
  throw new TransactionFailureException("Attempted to start a transaction within active transaction " +
                      txContext.getCurrentTransaction().getTransactionId());
 }
 dismissTransactionContext();
 txContext = new DelayedDiscardingTransactionContext(txClient, activeTxAwares.values());
 return txContext;
}

代码示例来源:origin: cdapio/cdap

private Transaction startTx(Iterable<TransactionAware> txAwares) throws TransactionFailureException {
 Transaction transaction = txClient.startLong();
 for (TransactionAware txAware : txAwares) {
  try {
   txAware.startTx(transaction);
  } catch (Throwable t) {
   txClient.abort(transaction);
   throw new TransactionFailureException(
    String.format("Unable to start transaction-aware '%s' for transaction %d. ",
           txAware.getTransactionAwareName(), transaction.getTransactionId()), t);
  }
 }
 return transaction;
}

代码示例来源:origin: co.cask.cdap/cdap-spark-core2

private Transaction startTx(Iterable<TransactionAware> txAwares) throws TransactionFailureException {
 Transaction transaction = txClient.startLong();
 for (TransactionAware txAware : txAwares) {
  try {
   txAware.startTx(transaction);
  } catch (Throwable t) {
   txClient.abort(transaction);
   throw new TransactionFailureException(
    String.format("Unable to start transaction-aware '%s' for transaction %d. ",
           txAware.getTransactionAwareName(), transaction.getTransactionId()), t);
  }
 }
 return transaction;
}

代码示例来源:origin: caskdata/cdap

@Override
public void canCommitOrThrow(Transaction tx, Collection<byte[]> changeIds) throws TransactionFailureException {
 if (failCanCommitOnce) {
  failCanCommitOnce = false;
  throw new TransactionConflictException(tx.getTransactionId(), null, null);
 } else {
  super.canCommitOrThrow(tx, changeIds);
 }
}

代码示例来源:origin: caskdata/cdap

@Override
public void commitOrThrow(Transaction tx) throws TransactionFailureException {
 if (failCommits-- > 0) {
  throw new TransactionConflictException(tx.getTransactionId(), null, null);
 } else {
  state = CommitState.Committed;
  super.commitOrThrow(tx);
 }
}

代码示例来源:origin: org.apache.tephra/tephra-api

/**
 * Creates a new transaction for a checkpoint operation, copying all members from the original transaction,
 * with the updated checkpoint write pointers.
 *
 * @param toCopy the original transaction containing the state to copy
 * @param writePointer the new write pointer to use for the transaction
 * @param checkpointPointers the list of write pointers added from checkpoints on the transaction
 */
public Transaction(Transaction toCopy, long writePointer, long[] checkpointPointers) {
 this(toCopy.getReadPointer(), toCopy.getTransactionId(), writePointer, toCopy.getInvalids(),
   toCopy.getInProgress(), toCopy.getFirstShortInProgress(), toCopy.getType(), checkpointPointers,
   toCopy.getVisibilityLevel());
}

代码示例来源:origin: org.apache.tephra/tephra-core

public static TTransaction wrap(Transaction tx) {
 return new TTransaction(tx.getTransactionId(), tx.getReadPointer(),
             Longs.asList(tx.getInvalids()), Longs.asList(tx.getInProgress()),
             tx.getFirstShortInProgress(), getTTransactionType(tx.getType()),
             tx.getWritePointer(), Longs.asList(tx.getCheckpointWritePointers()),
             getTVisibilityLevel(tx.getVisibilityLevel()));
}

相关文章