protected void checkTransaction() { if (status == TXSTATUS.INVALID) throw new OTransactionException("Invalid state of the transaction. The transaction must be begun."); }
public void begin() { if (txStartCounter < 0) throw new OTransactionException("Invalid value of TX counter."); if (txStartCounter == 0) status = TXSTATUS.BEGUN; txStartCounter++; if (txStartCounter > 1) OLogManager.instance().debug(this, "Transaction was already started and will be reused."); }
protected void beforeCommitOperations() { for (ODatabaseListener listener : browseListeners()) try { listener.onBeforeTxCommit(this); } catch (Exception e) { OLogManager.instance() .error(this, "Cannot commit the transaction: caught exception on execution of %s.onBeforeTxCommit() `%08X`", e, listener.getClass().getName(), System.identityHashCode(e)); throw OException.wrapException(new OTransactionException( "Cannot commit the transaction: caught exception on execution of " + listener.getClass().getName() + "#onBeforeTxCommit()"), e); } }
/** * The transaction is reentrant. If {@code begin()} has been called several times, the actual commit happens only after the same * amount of {@code commit()} calls * * @param force commit transaction even */ @Override public void commit(final boolean force) { checkTransaction(); if (txStartCounter < 0) throw new OStorageException("Invalid value of tx counter"); if (force) txStartCounter = 0; else txStartCounter--; if (txStartCounter == 0) { doCommit(); } else if (txStartCounter > 0) OLogManager.instance().debug(this, "Nested transaction was closed but transaction itself was not committed."); else throw new OTransactionException("Transaction was committed more times than it is started."); }
final OIndex<?> index = indexManager.getIndex(entry.getKey()); if (index == null) throw new OTransactionException("Cannot find index '" + entry.getValue() + "' while committing transaction");
final OIndex<?> index = indexManager.getIndex(entry.getKey()); if (index == null) throw new OTransactionException("Cannot find index '" + entry.getValue() + "' while committing transaction");
@Override public void rollback(boolean force, int commitLevelDiff) { if (txStartCounter < 0) throw new OStorageException("Invalid value of TX counter"); checkTransaction(); txStartCounter += commitLevelDiff; status = TXSTATUS.ROLLBACKING; if (!force && txStartCounter > 0) { OLogManager.instance().debug(this, "Nested transaction was closed but transaction itself was scheduled for rollback."); return; } if (txStartCounter < 0) throw new OTransactionException("Transaction was rolled back more times than it was started."); final OStorage storage = database.getStorage(); if (storage instanceof OStorageProxy) { storage.callInLock((Callable<Void>) () -> { storage.rollback(OTransactionOptimistic.this); return null; }, true); } internalRollback(); }
@Override public void begin() { makeActive(); // XXX: Under some circumstances, auto started transactions are committed outside of the graph using the // underlying database and later restarted using the graph. So we have to check the status of the // database transaction to support this behaviour. if (isAutoStartTx() && getDatabase().getTransaction().isActive()) throw new OTransactionException("A mixture of auto started and manually started transactions is not allowed. " + "Disable auto transactions for the graph before starting a manual transaction."); getDatabase().begin(); getDatabase().getTransaction().setUsingLog(settings.isUseLog()); }
@Override protected void autoStartTransaction() { final boolean txBegun = getDatabase().getTransaction().isActive(); if (!isAutoStartTx()) { if (isRequireTransaction() && !txBegun) throw new OTransactionException("Transaction required to change the Graph"); return; } if (!txBegun) { getDatabase().begin(); getDatabase().getTransaction().setUsingLog(settings.isUseLog()); } }