Package com.sleepycat.je.txn

Examples of com.sleepycat.je.txn.AutoTxn


        DbTree dbTree = env.getDbMapTree();
        Locker autoTxn = null;
        boolean operationOk = false;
        try {
            /* This method is used during eviction -- don't recurse. */
            autoTxn = new AutoTxn(env, new TransactionConfig());
            DatabaseImpl db = dbTree.getDb
                (autoTxn, DbTree.UTILIZATION_DB_NAME, null,
                 false /* No eviction allowed. */);
            if (db == null) {
                if (env.isReadOnly()) {
View Full Code Here


                locker.addToHandleMaps(new Long(nameLN.getNodeId()),
                                       databaseHandle);
            }

            /* Insert it into id -> name db, in auto commit mode. */
            autoTxn = new AutoTxn(envImpl, new TransactionConfig());
            idCursor = new CursorImpl(idDatabase, autoTxn);
            idCursor.setAllowEviction(allowEviction);
            idCursor.putLN(newId.getBytes(), new MapLN(newDb), false);
            operationOk = true;
  } catch (UnsupportedEncodingException UEE) {
View Full Code Here

       
        if (db.getId().equals(ID_DB_ID) ||
            db.getId().equals(NAME_DB_ID)) {
            envImpl.logMapTreeRoot();
        } else {
            Locker locker = new AutoTxn(envImpl, new TransactionConfig());
            CursorImpl cursor = new CursorImpl(idDatabase, locker);
            boolean operationOk = false;
            try {
                DatabaseEntry keyDbt =
        new DatabaseEntry(db.getId().getBytes());
    MapLN mapLN = null;

    /*
     * Retry indefinitely in the face of lock timeouts since the
     * lock on the MapLN is only supposed to be held for short
     * periods.
     */
    while (true) {
        try {
      boolean searchOk = (cursor.searchAndPosition
              (keyDbt, new DatabaseEntry(),
               SearchMode.SET, LockType.WRITE) &
              CursorImpl.FOUND) != 0;
      if (!searchOk) {
                            throw new DatabaseException(
                                "can't find database " + db.getId());
                        }
      mapLN = (MapLN)
          cursor.getCurrentLNAlreadyLatched(LockType.WRITE);
                        assert mapLN != null; /* Should be locked. */
        } catch (DeadlockException DE) {
      cursor.close();
      locker.operationEnd(false);
      locker = new AutoTxn(envImpl, new TransactionConfig());
      cursor = new CursorImpl(idDatabase, locker);
      continue;
        } finally {
      cursor.releaseBINs();
        }
        break;
    }

    RewriteMapLN writeMapLN = new RewriteMapLN(cursor);
    mapLN.getDatabase().getTree().withRootLatched(writeMapLN);

                operationOk = true;
            } finally {
                if (cursor != null) {
                    cursor.close();
                }

                locker.operationEnd(operationOk);
            }
        }
    }
View Full Code Here

     */
    long truncate(Locker locker, String databaseName)
        throws DatabaseException {

        CursorImpl nameCursor = null;
        AutoTxn autoTxn = null;
        try {
            NameLockResult result = lockNameLN(locker, databaseName,
                                               "truncate");
            nameCursor = result.nameCursor;
            if (nameCursor == null) {
                return 0;
            } else {

                /*
                 * Make a new database with an empty tree. Make the
                 * nameLN refer to the id of the new database.
                 */
                DatabaseId newId = new DatabaseId(getNextDbId());
                DatabaseImpl newDb = (DatabaseImpl) result.dbImpl.clone();
                newDb.setId(newId);
                newDb.setTree(new Tree(newDb));
           
                /*
                 * Insert the new MapLN into the id tree. Always use
                 * an AutoTxn on the id databaase, because we can not
                 * hold long term locks on the mapLN.
                 */
                CursorImpl idCursor = null;
                boolean operationOk = false;
                try {
                    autoTxn = new AutoTxn(envImpl, new TransactionConfig());
                    idCursor = new CursorImpl(idDatabase, autoTxn);
                    idCursor.putLN(newId.getBytes(),
                                   new MapLN(newDb), false);
                    operationOk = true;
                } finally {
                    if (idCursor != null) {
                        idCursor.close();
                    }

                    if (autoTxn != null) {
                        autoTxn.operationEnd(operationOk);
                    }
                }
                result.nameLN.setId(newDb.getId());

                /*
 
View Full Code Here

     * Remove the mapLN that refers to this database.
     */
    void deleteMapLN(DatabaseId id)
        throws DatabaseException {

        AutoTxn autoTxn = null;
        boolean operationOk = false;
        CursorImpl idCursor = null;
       
        try {
            autoTxn = new AutoTxn(envImpl, new TransactionConfig());
            idCursor = new CursorImpl(idDatabase, autoTxn);
            boolean found =
                (idCursor.searchAndPosition(new DatabaseEntry(id.getBytes()),
                                            null,
                                            SearchMode.SET,
                                            LockType.WRITE) &
                 CursorImpl.FOUND) != 0;
            if (found) {
                idCursor.delete();
            }

            operationOk = true;
        } finally {
            if (idCursor != null) {
                idCursor.close();
            }

            if (autoTxn != null) {
                autoTxn.operationEnd(operationOk);
            }
        }
    }
View Full Code Here

            newDb.setTree(new Tree(newDb));
           
            /* Insert the new db into id -> name map */
            CursorImpl idCursor = null;
            boolean operationOk = false;
            AutoTxn autoTxn = null;
            try {
                autoTxn = new AutoTxn(envImpl, new TransactionConfig());
                idCursor = new CursorImpl(idDatabase, autoTxn);
                idCursor.putLN(newId.getBytes(),
             new MapLN(newDb), false);
                operationOk = true;
            } finally {
                if (idCursor != null) {
                    idCursor.close();
                }

                if (autoTxn != null) {
                    autoTxn.operationEnd(operationOk);
                }
            }
            nameLN.setId(newDb.getId());

            /* Record utilization profile changes for the deleted database. */
 
View Full Code Here

  throws DatabaseException {

  if (envImpl.isNoLocking()) {
      return new BasicLocker(envImpl);
  } else {
      return new AutoTxn(envImpl, new TransactionConfig());
  }
    }
View Full Code Here

        }
        DbTree dbTree = env.getDbMapTree();
        Locker autoTxn = null;
        boolean operationOk = false;
        try {
            autoTxn = new AutoTxn(env, new TransactionConfig());
            DatabaseImpl db = dbTree.getDb
                (autoTxn, DbTree.UTILIZATION_DB_NAME, null,
                 true /* Eviction allowed. */);
            if (db == null) {
                if (env.isReadOnly()) {
View Full Code Here

TOP

Related Classes of com.sleepycat.je.txn.AutoTxn

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.