in transaction-client/src/main/java/org/apache/omid/transaction/AbstractTransactionManager.java [128:164]
public final Transaction begin() throws TransactionException {
try {
preBegin();
long startTimestamp, epoch;
// The loop is required for HA scenarios where we get the timestamp
// but when getting the epoch, the client is connected to a new TSOServer
// When this happen, the epoch will be larger than the startTimestamp,
// so we need to start the transaction again. We use the fact that epoch
// is always smaller or equal to a timestamp, and therefore, we first need
// to get the timestamp and then the epoch.
startTimestampTimer.start();
try {
do {
startTimestamp = tsoClient.getNewStartTimestamp().get();
epoch = tsoClient.getEpoch();
} while (epoch > startTimestamp);
} finally {
startTimestampTimer.stop();
}
AbstractTransaction<? extends CellId> tx = transactionFactory.createTransaction(startTimestamp, epoch, this);
postBegin(tx);
return tx;
} catch (TransactionManagerException e) {
throw new TransactionException("An error has occured during PreBegin/PostBegin", e);
} catch (ExecutionException e) {
throw new TransactionException("Could not get new timestamp", e);
} catch (InterruptedException ie) {
Thread.currentThread().interrupt();
throw new TransactionException("Interrupted getting timestamp", ie);
}
}