Package com.sleepycat.je.dbi

Examples of com.sleepycat.je.dbi.DbTree


            UtilizationTracker tracker = new UtilizationTracker(env);

            /* Use local caching to reduce DbTree.getDb overhead. */
            Map dbCache = new HashMap();

            DbTree dbTree = env.getDbMapTree();
            BINSearch binSearch = new BINSearch();
            try {
                Iterator it = queueSnapshot.values().iterator();
                while (it.hasNext()) {
                    if (env.isClosed()) {
View Full Code Here


        /* Validate all entries in at least one full recovery pass. */
        reader.setAlwaysValidateChecksum(true);

        try {
            info.numMapINs = 0;
            DbTree dbMapTree = env.getDbMapTree();

            /*
       * Process every IN, INDeleteInfo, and INDupDeleteInfo in the
       * mapping tree.
       */
            while (reader.readNextEntry()) {
                DatabaseId dbId = reader.getDatabaseId();
                if (dbId.equals(DbTree.ID_DB_ID)) {
                    DatabaseImpl db = dbMapTree.getDb(dbId);
                    replayOneIN(reader, db, false);
                    info.numMapINs++;
                }
            }

View Full Code Here

            /*
             * Read all non-provisional INs, and process if they don't belong
             * to the mapping tree.
             */
            DbTree dbMapTree = env.getDbMapTree();
            while (reader.readNextEntry()) {
                DatabaseId dbId = reader.getDatabaseId();
                boolean isMapDb = dbId.equals(DbTree.ID_DB_ID);
                boolean isTarget = false;

                if (mapDbOnly && isMapDb) {
                    isTarget = true;
                } else if (!mapDbOnly && !isMapDb) {
                    isTarget = true;
                }
                if (isTarget) {
                    DatabaseImpl db = dbMapTree.getDb(dbId);
                    if (db == null) {
                        // This db has been deleted, ignore the entry.
                    } else {
                        replayOneIN(reader, db, requireExactMatch);
                        numINsSeen++;
View Full Code Here

        }

        Map countedFileSummaries = new HashMap(); // TxnNodeId -> file number
        Set countedAbortLsnNodes = new HashSet(); // set of TxnNodeId

        DbTree dbMapTree = env.getDbMapTree();
        TreeLocation location = new TreeLocation();
        try {

            /*
             * Iterate over the target LNs and commit records, constructing
             * tree.
             */
            while (reader.readNextEntry()) {
                if (reader.isLN()) {

                    /* Get the txnId from the log entry. */
                    Long txnId = reader.getTxnId();

                    /*
                     * If this node is not in a committed txn, examine it to
                     * see if it should be undone.
                     */
                    if (txnId != null &&
      !committedTxnIds.contains(txnId)) {

      /*
       * Invoke the evictor to reduce memory consumption.
       */
      env.invokeEvictor();

      LN ln = reader.getLN();
      long logLsn = reader.getLastLsn();
      long abortLsn = reader.getAbortLsn();
      boolean abortKnownDeleted =
          reader.getAbortKnownDeleted();
      DatabaseId dbId = reader.getDatabaseId();
      DatabaseImpl db = dbMapTree.getDb(dbId);
                       
      /* Database may be null if it's been deleted. */
      if (db != null) {
          ln.postFetchInit(db, logLsn);
          try {
View Full Code Here

            reader.addTargetType(lnType);
        }

        Set countedAbortLsnNodes = new HashSet(); // set of TxnNodeId

        DbTree dbMapTree = env.getDbMapTree();
        TreeLocation location = new TreeLocation();
        try {

            /* Iterate over the target LNs and construct in- memory tree. */
            while (reader.readNextEntry()) {
                if (reader.isLN()) {

                    /* Get the txnId from the log entry. */
                    Long txnId = reader.getTxnId();
               
                    /*
                     * If this LN is in a committed txn, or if it's a
                     * non-transactional LN, redo it.
                     */
        boolean processThisLN = false;
        boolean lnIsCommitted = false;
        boolean lnIsPrepared = false;
        Txn preparedTxn = null;
        if (txnId == null) {
      processThisLN = true;
        } else {
      lnIsCommitted = committedTxnIds.contains(txnId);
      if (!lnIsCommitted) {
          preparedTxn = (Txn) preparedTxns.get(txnId);
          lnIsPrepared = preparedTxn != null;
      }
      if (lnIsCommitted || lnIsPrepared) {
          processThisLN = true;
      }
        }
        if (processThisLN) {

                        /* Invoke the evictor to reduce memory consumption. */
                        env.invokeEvictor();

                        LN ln = reader.getLN();
                        DatabaseId dbId = reader.getDatabaseId();
                        DatabaseImpl db = dbMapTree.getDb(dbId);
                        long logLsn = reader.getLastLsn();
                        long treeLsn = DbLsn.NULL_LSN;

                        /* Database may be null if it's been deleted. */
                        if (db != null) {
View Full Code Here

                 true); // doFetch

            if (result.parent == null) {
                /* It's null -- we actually deleted the root. */
                tree.withRootLatchedExclusive(new RootDeleter(tree));
                DbTree dbTree = db.getDbEnvironment().getDbMapTree();
                dbTree.modifyDbRoot(db);
                traceRootDeletion(Level.FINE, db);
                deleted = true;
            } else if (result.exactParentFound) {
                /* Exact match was found -- delete the parent entry. */
                found = true;
View Full Code Here

        throws DatabaseException {

        if (fileSummaryDb != null) {
            return true;
        }
        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()) {
                    return false;
                }
                db = dbTree.createDb
                    (autoTxn, DbTree.UTILIZATION_DB_NAME,
                     new DatabaseConfig(), null,
                     true /* Eviction allowed */);
            }
            fileSummaryDb = db;
View Full Code Here

     * often enough to prevent the pending LN set from growing too large.
     */
    void processPending()
        throws DatabaseException {

        DbTree dbMapTree = env.getDbMapTree();

        LNInfo[] pendingLNs = fileSelector.getPendingLNs();
        if (pendingLNs != null) {
            TreeLocation location = new TreeLocation();

            for (int i = 0; i < pendingLNs.length; i += 1) {
                LNInfo info = pendingLNs[i];

                DatabaseId dbId = info.getDbId();
                DatabaseImpl db = dbMapTree.getDb(dbId, lockTimeout);

                byte[] key = info.getKey();
                byte[] dupKey = info.getDupKey();
                LN ln = info.getLN();

                /* Evict before processing each entry. */
                if (DO_CRITICAL_EVICTION) {
                    env.getEvictor().doCriticalEviction();
                }

                processPendingLN
                    (ln, db, key, dupKey, location);
            }
        }

        DatabaseId[] pendingDBs = fileSelector.getPendingDBs();
        if (pendingDBs != null) {
            for (int i = 0; i < pendingDBs.length; i += 1) {
                DatabaseId dbId = pendingDBs[i];
                DatabaseImpl db = dbMapTree.getDb(dbId, lockTimeout);
                if (db == null || db.isDeleteFinished()) {
                    fileSelector.removePendingDB(dbId);
                }
            }
        }
View Full Code Here

            if (rootNeedsUpdating) {
                /*
                 * modifyDbRoot will grab locks and we can't have the INList
                 * latches or root latch held while it tries to acquire locks.
                 */
                DbTree dbTree = envImpl.getDbMapTree();
                dbTree.modifyDbRoot(database);
                RecoveryManager.traceRootDeletion(Level.FINE, database);
            }

            /*
             * Count obsolete nodes after logging the delete. We can do
View Full Code Here

        EnvironmentImpl envImpl = DbInternal.getEnvironmentImpl(env);

        /* If no database is specified, verify all. */
        List<String> dbNameList = null;
        List<String> internalDbs = null;
        DbTree dbMapTree = envImpl.getDbTree();

        if (dbName == null) {
            dbNameList = env.getDatabaseNames();

            dbNameList.addAll(dbMapTree.getInternalNoRepDbNames());
            if (envImpl.isReplicated()) {
                dbNameList.addAll(dbMapTree.getInternalRepDbNames());
            }
            internalDbs = dbMapTree.getInternalNoLookupDbNames();
        } else {
            dbNameList = new ArrayList<String>();
            dbNameList.add(dbName);
            internalDbs = new ArrayList<String>();
        }

        /* Check application data. */
        Iterator<String> iter = dbNameList.iterator();
        while (iter.hasNext()) {
            String targetDb = iter.next();
            LoggerUtils.envLogMsg(Level.INFO, envImpl,
                                  "DbVerify.verify of " + targetDb + " starting");

            DatabaseConfig dbConfig = new DatabaseConfig();
            dbConfig.setReadOnly(true);
            dbConfig.setAllowCreate(false);
            DbInternal.setUseExistingConfig(dbConfig, true);
            Database db;
            try {
                db = env.openDatabase(null, targetDb, dbConfig);
            } catch (DatabaseNotFoundException e) {
                /* DB was removed after getting names -- ignore it. */
                continue;
            } catch (DatabaseExistsException e) {
                /* Should never happen, ExclusiveCreate is false. */
                throw EnvironmentFailureException.unexpectedException(e);
            }

            try {
                if (!verifyOneDbImpl(DbInternal.getDatabaseImpl(db),
                                     targetDb,
                                     verifyConfig,
                                     out)) {
                    ret = false;
                }
            } finally {
                if (db != null) {
                    db.close();
                }
                LoggerUtils.envLogMsg(Level.INFO, envImpl,
                                   "DbVerify.verify of " + targetDb +
                                   " ending");
            }
        }

        /*
         * Check internal databases, which don't have to be opened
         * through a Database handle.
         */
        iter = internalDbs.iterator();
        while (iter.hasNext()) {
            String targetDb = iter.next();
            LoggerUtils.envLogMsg(Level.INFO, envImpl,
                               "DbVerify.verify of " + targetDb + " starting");

            try {
                DatabaseImpl dbImpl = dbMapTree.getDb(null, targetDb,
                                                      null);
                try {
                    if (!verifyOneDbImpl(dbImpl,  targetDb,
                                         verifyConfig, out)) {
                        ret = false;
                    }
                } finally {
                    dbMapTree.releaseDb(dbImpl);
                }
            } finally {
                LoggerUtils.envLogMsg(Level.INFO, envImpl,
                                   "DbVerify.verify of " + targetDb +
                                   " ending");
View Full Code Here

TOP

Related Classes of com.sleepycat.je.dbi.DbTree

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.