Examples of INList


Examples of com.sleepycat.je.dbi.INList

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

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

        if (root != null) {
            rootLatch.acquireShared();
            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.contains(parent)) {
                throw EnvironmentFailureException.unexpectedState
                    ("IN " + parent.getNodeId() + " missing from INList");
            }
            for (int i = 0;; i += 1) {
                try {
View Full Code Here

Examples of com.sleepycat.je.dbi.INList

             * as a unit. Recovery skips provisional entries, so the changed
             * children are only used if the parent makes it out to the log.
             */
            EnvironmentImpl env = databaseImpl.getDbEnvironment();
            LogManager logManager = env.getLogManager();
            INList inMemoryINs = env.getInMemoryINs();

            long newSiblingLsn =
                newSibling.optionalLogProvisional(logManager, parent);

            long myNewLsn = optionalLogProvisional(logManager, parent);

            /*
             * When we update the parent entry, we use updateEntryCompareKey so
             * that we don't replace the parent's key that points at 'this'
             * with a key that is > than the existing one.  Replacing the
             * parent's key with something > would effectively render a piece
             * of the subtree inaccessible.  So only replace the parent key
             * with something <= the existing one.  See tree/SplitTest.java for
             * more details on the scenario.
             */
            if (low == 0) {

                /*
                 * Change the original entry to point to the new child and add
                 * an entry to point to the newly logged version of this
                 * existing child.
                 */
                if (childIndex == 0) {
                    parent.updateEntryCompareKey(childIndex, newSibling,
                                                 newSiblingLsn, newIdKey);
                } else {
                    parent.updateNode(childIndex, newSibling, newSiblingLsn,
                                      null /*lnSlotKey*/);
                }

                byte[] ourKey = getKey(0);
                boolean insertOk = parent.insertEntry
                    (new ChildReference(this, ourKey, myNewLsn));
                assert insertOk;
            } else {

                /*
                 * Update the existing child's LSN to reflect the newly logged
                 * version and insert new child into parent.
                 */
                if (childIndex == 0) {

                    /*
                     * this's idkey may be < the parent's entry 0 so we need to
                     * update parent's entry 0 with the key for 'this'.
                     */
                    parent.updateEntryCompareKey
                        (childIndex, this, myNewLsn, getKey(0));
                } else {
                    parent.updateNode(childIndex, this, myNewLsn,
                                      null /*lnSlotKey*/);
                }
                boolean insertOk = parent.insertEntry
                    (new ChildReference(newSibling, newIdKey, newSiblingLsn));
                assert insertOk;
            }

            /*
             * If this node has no key prefix, calculate it now that it has
             * been split.
             */
            byte[] newKeyPrefix = computeKeyPrefix(-1);
            recalcSuffixes(newKeyPrefix, null, -1);

            /* Only recalc if there are multiple entries in newSibling. */
            if (newSibling.getNEntries() > 1) {
                byte[] newSiblingPrefix = newSibling.getKeyPrefix();
                newSiblingPrefix = newSibling.computeKeyPrefix(-1);
                newSibling.recalcSuffixes(newSiblingPrefix, null, -1);
                newSibling.initMemorySize();
            }

            parentLsn = parent.optionalLog(logManager);

            /*
             * Maintain dirtiness if this is the root, so this parent will be
             * checkpointed. Other parents who are not roots are logged as part
             * of the propagation of splits upwards.
             */
            if (parent.isRoot()) {
                parent.setDirty(true);
            }

            /*
             * Update size. newSibling and parent are correct, but this IN has
             * had its entries shifted and is not correct.
             */
            long newSize = computeMemorySize();
            updateMemorySize(oldMemorySize, newSize);
            inMemoryINs.add(newSibling);

            /* Debug log this information. */
            traceSplit(Level.FINE, parent,
                       newSibling, parentLsn, myNewLsn,
                       newSiblingLsn, splitIndex, idKeyIndex, childIndex);
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();

            Logger logger = envImpl.getLogger();
            if (logger.isLoggable(detailedTraceLevel)) {
                /* Ugh, only create trace message when logging. */
                Tracer.trace(detailedTraceLevel, envImpl,
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

            /*
             * Count obsolete nodes after logging the delete. We can do
             * this without having the nodes of the subtree latched because the
             * subtree has been detached from the tree.
             */
            INList inList = envImpl.getInMemoryINs();
            accountForSubtreeRemoval(inList, subtreeRootIN, tracker);
        }
    }
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.acquireShared();
            try {
                Node rootIN = root.getTarget();
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.