core/src/main/java/com/orientechnologies/orient/core/storage/impl/local/paginated/atomicoperations/OAtomicOperationsManager.java
public OLogSequenceNumber endAtomicOperation(boolean rollback) throws IOException {
    final OAtomicOperation operation = currentOperation.get();

    if (operation == null) {
      OLogManager.instance().error(this, "There is no atomic operation active", null);
      throw new ODatabaseException("There is no atomic operation active");
    }

    int counter = operation.getCounter();
    operation.decrementCounter();

    assert counter > 0;

    final OLogSequenceNumber lsn;
    try {
      if (rollback) {
        operation.rollback();
      }

      if (counter == 1) {
        try {
          final boolean useWal = useWal();

          if (!operation.isRollback()) {
            lsn = operation.commitChanges(useWal ? writeAheadLog : null);
          } else {
            lsn = null;
          }

          if (trackAtomicOperations) {
            activeAtomicOperations.remove(operation.getOperationUnitId());
          }
        } finally {
          final Iterator<String> lockedObjectIterator = operation.lockedObjects().iterator();

          while (lockedObjectIterator.hasNext()) {
            final String lockedObject = lockedObjectIterator.next();
            lockedObjectIterator.remove();

            lockManager.releaseLock(this, lockedObject, OOneEntryPerKeyLockManager.LOCK.EXCLUSIVE);
          }

          currentOperation.set(null);
        }
      } else {
        lsn = null;
      }
    } catch (Error e) {
      final OAbstractPaginatedStorage st = storage;
      if (st != null) {
        st.handleJVMError(e);
      }

      counter = 1;
      throw e;
    } finally {
      if (counter == 1) {
        atomicOperationsCount.decrement();
      }
    }

    return lsn;
  }
public OLogSequenceNumber endAtomicOperation(boolean rollback) throws IOException {
    final OAtomicOperation operation = currentOperation.get();

    if (operation == null) {
      OLogManager.instance().error(this, "There is no atomic operation active", null);
      throw new ODatabaseException("There is no atomic operation active");
    }

    int counter = operation.getCounter();
    operation.decrementCounter();

    assert counter > 0;

    final OLogSequenceNumber lsn;
    try {
      if (rollback) {
        operation.rollback();
      }

      if (counter == 1) {
        try {
          final boolean useWal = useWal();

          if (!operation.isRollback()) {
            lsn = operation.commitChanges(useWal ? writeAheadLog : null);
          } else {
            lsn = null;
          }

          if (trackAtomicOperations) {
            activeAtomicOperations.remove(operation.getOperationUnitId());
          }
        } finally {
          final Iterator<String> lockedObjectIterator = operation.lockedObjects().iterator();

          while (lockedObjectIterator.hasNext()) {
            final String lockedObject = lockedObjectIterator.next();
            lockedObjectIterator.remove();

            lockManager.releaseLock(this, lockedObject, OOneEntryPerKeyLockManager.LOCK.EXCLUSIVE);
          }

          currentOperation.set(null);
        }
      } else {
        lsn = null;
      }
    } catch (Error e) {
      final OAbstractPaginatedStorage st = storage;
      if (st != null) {
        st.handleJVMError(e);
      }

      counter = 1;
      throw e;
    } finally {
      if (counter == 1) {
        atomicOperationsCount.decrement();
      }
    }

    return lsn;
  }
public OLogSequenceNumber endAtomicOperation ( boolean rollback ) throws IOException { final OAtomicOperation operation = currentOperation . get ( ) ; if ( operation == null ) { OLogManager . instance ( ) . error ( this , "There is no atomic operation active" , null ) ; throw new ODatabaseException ( "There is no atomic operation active" ) ; } int counter = operation . getCounter ( ) ; operation . decrementCounter ( ) ; assert counter > 0 ; final OLogSequenceNumber lsn ; try { if ( rollback ) { operation . rollback ( ) ; } if ( counter == 1 ) { try { final boolean useWal = useWal ( ) ; if ( ! operation . isRollback ( ) ) { lsn = operation . commitChanges ( useWal ? writeAheadLog : null ) ; } else { lsn = null ; } if ( trackAtomicOperations ) { activeAtomicOperations . remove ( operation . getOperationUnitId ( ) ) ; } } finally { final Iterator < String > lockedObjectIterator = operation . lockedObjects ( ) . iterator ( ) ; while ( lockedObjectIterator . hasNext ( ) ) { final String lockedObject = lockedObjectIterator . next ( ) ; lockedObjectIterator . remove ( ) ; lockManager . releaseLock ( this , lockedObject , OOneEntryPerKeyLockManager . LOCK . EXCLUSIVE ) ; } currentOperation . set ( null ) ; } } else { lsn = null ; } } catch ( Error e ) { final OAbstractPaginatedStorage st = storage ; if ( st != null ) { st . handleJVMError ( e ) ; } counter = 1 ; throw e ; } finally { if ( counter == 1 ) { atomicOperationsCount . decrement ( ) ; } } return lsn ; }
Ends the current atomic operation on this manager.

@param rollback {@code true} to indicate a rollback, {@code false} for successful commit.

@return the LSN produced by committing the current operation or {@code null} if no commit was done.
Ends the current atomic operation on this manager .