All Downloads are FREE. Search and download functionalities are using the official Maven repository.

com.scalar.db.sql.SqlTwoPhaseCommitTransaction Maven / Gradle / Ivy

There is a newer version: 3.14.0
Show newest version
package com.scalar.db.sql;

import com.scalar.db.sql.exception.SqlException;
import com.scalar.db.sql.exception.TransactionRetryableException;
import com.scalar.db.sql.exception.UnknownTransactionStatusException;

/** A transaction abstraction for two-phase commit transactions for ScalarDB SQL API. */
public interface SqlTwoPhaseCommitTransaction extends SqlStatementExecutable {

  /**
   * Returns the ID of a transaction.
   *
   * @return the ID of a transaction
   */
  String getId();

  /**
   * Prepares a transaction.
   *
   * @throws TransactionRetryableException if the transaction fails to prepare due to retryable
   *     faults (e.g., a transaction conflict). You can retry the transaction from the beginning.
   * @throws SqlException if the transaction fails to prepare due to transient or nontransient
   *     faults. You can try retrying the transaction from the beginning, but the transaction may
   *     still fail if the cause is nontranient
   */
  void prepare();

  /**
   * Validates a transaction.
   *
   * @throws TransactionRetryableException if the transaction fails to validate due to retryable
   *     faults (e.g., a transaction conflict). You can retry the transaction from the beginning.
   * @throws SqlException if the transaction fails to validate due to transient or nontransient
   *     faults. You can try retrying the transaction from the beginning, but the transaction may
   *     still fail if the cause is nontranient
   */
  void validate();

  /**
   * Commits a transaction.
   *
   * @throws TransactionRetryableException if the transaction fails to commit due to retryable
   *     faults (e.g., a transaction conflict). You can retry the transaction from the beginning.
   * @throws UnknownTransactionStatusException if the transaction status (committed or aborted) is
   *     unknown
   * @throws SqlException if the transaction fails to commit due to transient or nontransient
   *     faults. You can try retrying the transaction from the beginning, but the transaction may
   *     still fail if the cause is nontranient
   */
  void commit();

  /** Rolls back a transaction. */
  void rollback();

  /** Aborts a transaction. This method is an alias of {@link #rollback()}. */
  default void abort() {
    rollback();
  }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy