com.scalar.db.sql.springdata.twopc.ExecutionPhaseOperations Maven / Gradle / Ivy
package com.scalar.db.sql.springdata.twopc;
import com.scalar.db.sql.springdata.exception.ScalarDbNonTransientException;
import com.scalar.db.sql.springdata.exception.ScalarDbTransientException;
import com.scalar.db.sql.springdata.exception.ScalarDbUnknownTransactionStateException;
import javax.annotation.Nullable;
/**
* CRUD operations executed on local and remote participants in `execution` phase before `prepare`
* phase.
*
* @param a return value type
*/
@FunctionalInterface
public interface ExecutionPhaseOperations {
/**
* Execute local and remote operations until `prepare` phase
*
* @param transactionId a transaction ID
* @return a result value of the execution operations
* @throws ScalarDbUnknownTransactionStateException if the execution operations fail due to a
* non-transient cause with an unknown final status. The exception contains {@code
* transactionId}. Note that the final 2PC transaction status is unknown. Whether the
* transaction is actually committed or not needs to be decided by the application side (e.g.
* check if the target record is expectedly updated)
* @throws ScalarDbNonTransientException if the execution operations fail due to a non-transient
* cause. The exception contains {@code transactionId}
* @throws ScalarDbTransientException if the execution operations fail due to a transient cause.
* The exception contains {@code transactionId}
*/
@Nullable
R execute(String transactionId);
}