Beispiel #1
0
  @Override
  public void commit()
      throws RollbackException, HeuristicMixedException, HeuristicRollbackException,
          IllegalStateException, SystemException {
    assertTmOk("tx commit");
    Thread thread = Thread.currentThread();
    TransactionImpl tx = txThreadMap.get(thread);
    if (tx == null) {
      throw logAndReturn("TM error tx commit", new IllegalStateException("Not in transaction"));
    }

    boolean hasAnyLocks = false;
    boolean successful = false;
    try {
      hasAnyLocks = finishHook.hasAnyLocks(tx);
      if (tx.getStatus() != Status.STATUS_ACTIVE
          && tx.getStatus() != Status.STATUS_MARKED_ROLLBACK) {
        throw logAndReturn(
            "TM error tx commit",
            new IllegalStateException("Tx status is: " + getTxStatusAsString(tx.getStatus())));
      }
      tx.doBeforeCompletion();
      // delist resources?
      if (tx.getStatus() == Status.STATUS_ACTIVE) {
        comittedTxCount.incrementAndGet();
        commit(thread, tx);
      } else if (tx.getStatus() == Status.STATUS_MARKED_ROLLBACK) {
        rolledBackTxCount.incrementAndGet();
        rollbackCommit(thread, tx);
      } else {
        throw logAndReturn(
            "TM error tx commit",
            new IllegalStateException("Tx status is: " + getTxStatusAsString(tx.getStatus())));
      }
      successful = true;
    } finally {
      if (hasAnyLocks) {
        finishHook.finishTransaction(tx.getEventIdentifier(), successful);
      }
    }
  }
Beispiel #2
0
 public synchronized void commit()
     throws RollbackException, HeuristicMixedException, HeuristicRollbackException,
         IllegalStateException, SystemException {
   // make sure tx not suspended
   txManager.commit();
 }
Beispiel #3
0
 private void commit(HighlyAvailableGraphDatabase db, javax.transaction.Transaction tx)
     throws Exception {
   TxManager txManager = db.getDependencyResolver().resolveDependency(TxManager.class);
   txManager.resume(tx);
   txManager.commit();
 }