Package com.sleepycat.je.dbi

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


       * 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.logProvisional(logManager, parent);
      long myNewLsn = logProvisional(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.updateEntry(childIndex, newSibling, newSiblingLsn);
                }

    boolean insertOk = parent.insertEntry
        (new ChildReference(this, entryKeyVals[0], 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, entryKeyVals[0]);
    } else {
        parent.updateEntry(childIndex, this, myNewLsn);
    }
    boolean insertOk = parent.insertEntry
        (new ChildReference(newSibling, newIdKey, newSiblingLsn));
    assert insertOk;
      }

      parentLsn = parent.log(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

        throws DatabaseException {

        final DatabaseImpl db = target.getDatabase();
        /* SharedEvictor uses multiple envs, do not use superclass envImpl. */
        final EnvironmentImpl envImpl = db.getDbEnvironment();
        final INList inList = envImpl.getInMemoryINs();

        class RootEvictor implements WithRootLatched {

            boolean flushed = false;
            long evictBytes = 0;

            public IN doWork(ChildReference root)
                throws DatabaseException {

                IN rootIN = (IN) root.fetchTarget(db, null);
                rootIN.latch(CacheMode.UNCHANGED);
                try {
                    /* Re-check that all conditions still hold. */
                    boolean isDirty = rootIN.getDirty();
                    if (rootIN == target &&
                        rootIN.isDbRoot() &&
                        rootIN.isEvictable() &&
                        !(envImpl.isReadOnly() && isDirty)) {

                        /* Flush if dirty. */
                        if (isDirty) {
                            long newLsn = rootIN.log
                                (envImpl.getLogManager(),
                                 false, // allowDeltas
                                 isProvisionalRequired(rootIN),
                                 backgroundIO,
                                 null); // parent
                            root.setLsn(newLsn);
                            flushed = true;
                        }

                        /* Take off the INList and adjust memory budget. */
                        inList.remove(rootIN);
                        evictBytes = rootIN.getBudgetedMemorySize();

                        /* Evict IN. */
                        root.clearTarget();

View Full Code Here

        Map<DatabaseImpl,Integer> highestLevelSeenMap =
            new IdentityHashMap<DatabaseImpl,Integer>();
        DbTree dbTree = envImpl.getDbTree();

        INList inMemINs = envImpl.getInMemoryINs();

        /*
         * Opportunistically recalculate the INList memory budget while
         * traversing the entire INList.
         */
        inMemINs.memRecalcBegin();
        boolean completed = false;

        try {
            for (IN in : inMemINs) {
                in.latchShared(CacheMode.UNCHANGED);
                DatabaseImpl db = in.getDatabase();

                try {
                    inMemINs.memRecalcIterate(in);

                    /* Do not checkpoint temporary databases. */
                    if (db.isTemporary()) {
                        continue;
                    }

                    Integer level =
                        addDirtyIN(in, false /*updateMemoryBudget*/);
                    if (level != null) {

                        /*
                         * IN was added to the dirty map.  Update the highest
                         * level seen for the database.  Use one level higher
                         * when flushExtraLevel is set.  When flushAll is set,
                         * use the maximum level for the database.  Durable
                         * deferred-write databases must be synced, so also use
                         * the maximum level.
                         */
                        if (flushAll || db.isDurableDeferredWrite()) {
                            if (!highestLevelSeenMap.containsKey(db)) {

                                /*
                                 * Null is used as an indicator that
                                 * getHighestLevel should be called below, when
                                 * no latches are held.
                                 */
                                highestLevelSeenMap.put(db, null);
                            }
                        } else {
                            int levelVal = level.intValue();
                            if (flushExtraLevel) {
                                if (in.isRoot()) {
                                    /* No reason to go above DB root. */
                                    if (!in.isDbRoot()) {
                                        /* The level above DIN root is BIN. */
                                        levelVal = IN.BIN_LEVEL;
                                    }
                                } else {
                                    /* Next level up in the same tree. */
                                    levelVal += 1;
                                }
                            }
                            Integer highestLevelSeen =
                                highestLevelSeenMap.get(db);
                            if (highestLevelSeen == null ||
                                levelVal > highestLevelSeen.intValue()) {
                                if (flushExtraLevel) {
                                    level = Integer.valueOf(levelVal);
                                }
                                highestLevelSeenMap.put(db, level);
                            }
                        }
                    }

                    /* Save dirty/temp DBs for later. */
                    saveMapLNsToFlush(in);
                } finally {
                    in.releaseLatch();
                }
            }
            completed = true;
        } finally {
            inMemINs.memRecalcEnd(completed);
        }

        /* Call getHighestLevel only when no latches are held. */
        for (DatabaseImpl db : highestLevelSeenMap.keySet()) {
            if (highestLevelSeenMap.get(db) == null) {
View Full Code Here

     */
    public boolean delete(byte[] idKey,
                          UtilizationTracker tracker)
        throws DatabaseException {

        INList inMemoryINs = database.getDbEnvironment().getInMemoryINs();
        boolean treeEmpty = false;

        IN subtreeRoot = null;

        /*
 
View Full Code Here

        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

         * 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

        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

        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

     * 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

TOP

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

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.