Examples of INList


Examples of com.sleepycat.je.dbi.INList

        throws DatabaseException {

        boolean ret = true;

  EnvironmentImpl env = database.getDbEnvironment();
        INList inMemoryINs = env.getInMemoryINs();

        IN in = search
            (dupKey, SearchType.NORMAL, -1, null, true /*updateGeneration*/);

        assert in.isLatchOwner();
View Full Code Here

Examples of com.sleepycat.je.dbi.INList

         * Create a new root IN, insert the current root IN into it, and then
         * call split.
         */
        EnvironmentImpl env = database.getDbEnvironment();
        LogManager logManager = env.getLogManager();
        INList inMemoryINs = env.getInMemoryINs();

        IN curRoot = null;
        curRoot = (IN) root.fetchTarget(database, null);
        curRoot.latch();
        long curRootLsn = 0;
        long logLsn = 0;
        IN newRoot = null;
        try {

            /*
             * Make a new root IN, giving it an id key from the previous root.
             */
            byte[] rootIdKey = curRoot.getKey(0);
            newRoot = new IN(database, rootIdKey, maxMainTreeEntriesPerNode,
           curRoot.getLevel() + 1);
            newRoot.setIsRoot(true);
            curRoot.setIsRoot(false);

            /*
             * Make the new root IN point to the old root IN. Log the old root
             * provisionally, because we modified it so it's not the root
             * anymore, then log the new root. We are guaranteed to be able to
             * insert entries, since we just made this root.
             */
            try {
                curRootLsn = curRoot.logProvisional(logManager, newRoot);
                boolean insertOk = newRoot.insertEntry
                    (new ChildReference(curRoot, rootIdKey, curRootLsn));
                assert insertOk;

                logLsn = newRoot.log(logManager);
            } catch (DatabaseException e) {
                /* Something went wrong when we tried to log. */
                curRoot.setIsRoot(true);
                throw e;
            }
            inMemoryINs.add(newRoot);

            /*
             * Make the tree's root reference point to this new node. Now the
             * MapLN is logically dirty, but the change hasn't been logged.  Be
             * sure to flush the MapLN if we ever evict the root.
View Full Code Here

Examples of com.sleepycat.je.dbi.INList

        validateInsertArgs(allowDuplicates);

        EnvironmentImpl env = database.getDbEnvironment();
        LogManager logManager = env.getLogManager();
        INList inMemoryINs = env.getInMemoryINs();

        /* Find and latch the relevant BIN. */
        BIN bin = null;
        try {
            bin = findBinForInsert(key, logManager, inMemoryINs, cursor);
View Full Code Here

Examples of com.sleepycat.je.dbi.INList

        if (curRoot.needsSplitting()) {

            EnvironmentImpl env = database.getDbEnvironment();
            LogManager logManager = env.getLogManager();
            INList inMemoryINs = env.getInMemoryINs();

            /*
             * Make a new root DIN, giving it an id key from the previous root.
             */
            byte[] rootIdKey = curRoot.getKey(0);
            DIN newRoot = new DIN(database,
                                  rootIdKey,
                                  maxDupTreeEntriesPerNode,
                                  curRoot.getDupKey(),
                                  curRoot.getDupCountLNRef(),
                                  curRoot.getLevel() + 1);

            newRoot.latch();
            long curRootLsn = 0;
            long logLsn = 0;
            try {
                newRoot.setIsRoot(true);
                curRoot.setDupCountLN(null);
                curRoot.setIsRoot(false);

                /*
                 * Make the new root DIN point to the old root DIN, and then
                 * log. We should be able to insert into the root because the
                 * root is newly created.
                 */
                try {
                    curRootLsn = curRoot.logProvisional(logManager, newRoot);
                    boolean insertOk = newRoot.insertEntry
                        (new ChildReference(curRoot, rootIdKey,
                                            bin.getLsn(index)));
                    assert insertOk;

                    logLsn = newRoot.log(logManager);
                } catch (DatabaseException e) {

                    /* Something went wrong when we tried to log. */
                    curRoot.setIsRoot(true);
                    throw e;
                }

                inMemoryINs.add(newRoot);
                bin.updateEntry(index, newRoot, logLsn);
                curRoot.split(newRoot, 0, maxDupTreeEntriesPerNode);
            } finally {
                curRoot.releaseLatch();
            }
View Full Code Here

Examples of com.sleepycat.je.dbi.INList

     * IN list.
     */
    public void rebuildINList()
        throws DatabaseException {

        INList inMemoryList = database.getDbEnvironment().getInMemoryINs();

        if (root != null) {
            rootLatch.acquire();
            try {
                Node rootIN = root.getTarget();
View Full Code Here

Examples of com.sleepycat.je.dbi.INList

        if (parent == null) {
            parent = (IN) root.getTarget();
        }
        if (parent != null) {
            INList inList = database.getDbEnvironment().getInMemoryINs();
            if (!inList.getINs().contains(parent)) {
                throw new DatabaseException
                    ("IN " + parent.getNodeId() + " missing from INList");
            }
            for (int i = 0;; i += 1) {
                try {
View Full Code Here

Examples of com.sleepycat.je.dbi.INList

                                     boolean flushExtraLevel)
        throws DatabaseException {

        SortedMap newDirtyMap = new TreeMap();

        INList inMemINs = envImpl.getInMemoryINs();
        inMemINs.latchMajor();

        /*
   * Opportunistically recalculate the environment wide memory count.
   * Incurs no extra cost because we're walking the IN list anyway.  Not
   * the best in terms of encapsulation as prefereably all memory
   * calculations are done in MemoryBudget, but done this way to avoid
   * any extra latching.
   */
        long totalSize = 0;
        MemoryBudget mb = envImpl.getMemoryBudget();

        try {
            Iterator iter = inMemINs.iterator();
            while (iter.hasNext()) {
                IN in = (IN) iter.next();
                in.latch(false);
                try {
                    totalSize = mb.accumulateNewUsage(in, totalSize);

                    if (in.getDirty()) {
                        Integer level = new Integer(in.getLevel());
                        Set dirtySet;
                        if (newDirtyMap.containsKey(level)) {
                            dirtySet = (Set) newDirtyMap.get(level);
                        } else {
                            dirtySet = new HashSet();
                            newDirtyMap.put(level, dirtySet);
                        }
                        dirtySet.add
                             (new CheckpointReference(in.getDatabase(),
                                                      in.getNodeId(),
                                                      in.containsDuplicates(),
                                                      in.isDbRoot(),
                                                      in.getMainTreeKey(),
                                                      in.getDupTreeKey()));
                    }
                } finally {
                    in.releaseLatch();
                }
            }

            /* Set the tree cache size. */
            mb.refreshTreeMemoryUsage(totalSize);

            /*
             * If we're flushing all for cleaning, we must flush to the point
             * that there are no nodes with LSNs in the cleaned files.
             */
            if (newDirtyMap.size() > 0) {
                if (flushAll) {
                    highestFlushLevel =
      envImpl.getDbMapTree().getHighestLevel();
                } else {
                    highestFlushLevel =
                        ((Integer) newDirtyMap.lastKey()).intValue();
                    if (flushExtraLevel) {
                        highestFlushLevel += 1;
                    }
                }
            } else {
    highestFlushLevel = IN.MAX_LEVEL;
      }
        } finally {
            inMemINs.releaseMajorLatchIfHeld();
        }

        return newDirtyMap;
    }
View Full Code Here

Examples of com.sleepycat.je.dbi.INList

        long evictBytes = 0;

        /* Evict utilization tracking info without holding the INList latch. */
        evictBytes += envImpl.getUtilizationTracker().evictMemory();

        INList inList = envImpl.getInMemoryINs();
        inList.latchMajor();
        int inListStartSize = inList.getSize();

        try {
            /*
             * Setup the round robin iterator. Note that because critical
             * eviction is now called during recovery, when the INList is
             * sometimes abruptly cleared, nextNode may not be null when
             * the INList is empty.
             */
            if (inListStartSize == 0) {
                nextNode = null;
                return 0;
            } else {
                if (nextNode == null) {
                    nextNode = inList.first();
                }
            }

            ScanIterator scanIter = new ScanIterator(nextNode, inList);

            /*
             * Keep evicting until we've freed enough memory or we've visited
             * the maximum number of nodes allowed. Each iteration of the while
             * loop is called an eviction batch.
             *
             * In order to prevent endless evicting and not keep the INList
             * major latch for too long, limit this run to one pass over the
             * IN list.
             */
            while ((evictBytes < requiredEvictBytes) &&
                   (nNodesScannedThisRun <= inListStartSize)) {

                IN target = selectIN(inList, scanIter);

                if (target == null) {
                    break;
                } else {
                    assert evictProfile.count(target);//intentional side effect
                    evictBytes += evict(inList, target, scanIter);
                }
                nBatchSets++;
            }

            /*
             * At the end of the scan, look at the next element in the INList
             * and put it in nextNode for the next time we scan the INList.
             */
            nextNode = scanIter.mark();
            finished = true;

        } finally {
            nNodesScanned += nNodesScannedThisRun;
            inList.releaseMajorLatch();
      Tracer.trace(detailedTraceLevel, envImpl,
                         "Evictor: pass=" + nEvictPasses +
                         " finished=" + finished +
                         " source=" + source +
                         " requiredEvictBytes=" +
View Full Code Here

Examples of com.sleepycat.je.dbi.INList

                             boolean containsDups,
                             byte[] dupKey,
                             UtilizationTracker tracker)
        throws DatabaseException {

        INList inList = env.getInMemoryINs();
        boolean requeued = false;
        try {
            Tree tree = dbImpl.getTree();
           
            if (containsDups) {
               
                /*
                 * When we delete a BIN or DBIN, we're guaranteed that there
                 * are no cursors at that node. (otherwise, we wouldn't be able
                 * to remove all the entries. However, there's the possibility
                 * that the BIN that is the parent of the duplicate tree has
                 * resident cursors, and in that case, we would not be able
                 * to remove the whole duplicate tree and DIN root. In that
                 * case, we'd requeue.
                 */
                boolean deleteFinished = false;
                inList.latchMajor();
                try {
                    deleteFinished = tree.deleteDup(idKey, dupKey, tracker);
                } finally {
                    inList.releaseMajorLatch();
                }

                if (deleteFinished) {
                    processedBinsThisRun++;
                } else {

                    /*
                     * Requeue, there were cursors on the BIN parent of the
                     * duplicate tree.
                     */
                    addBinRefToQueue(binRef, false);
                    requeued = true;
                    cursorsBinsThisRun++;
                }
            } else {
                boolean deletedRoot = false;
                inList.latchMajor();
                try {
                    deletedRoot = tree.delete(idKey, tracker);
                } finally {
                    inList.releaseMajorLatch();
                }

                /*
                 * modifyDb will grab locks and we can't have the INList Major
                 * Latch held while it tries to acquire locks.  deletedRoot
View Full Code Here

Examples of com.sleepycat.je.dbi.INList

     * BINS on the IN list.
     */
    private void compress()
        throws DatabaseException {

        INList inList = DbInternal.envGetEnvironmentImpl(env).getInMemoryINs();
        inList.latchMajor();
        try {
            Iterator iter = inList.iterator();
            while (iter.hasNext()) {
                IN in = (IN) iter.next();
                if (in instanceof BIN) {
                    in.compress(null, true);
                }
            }
        } finally {
            inList.releaseMajorLatch();
        }
    }
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. 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.