Package com.sleepycat.je.tree

Examples of com.sleepycat.je.tree.IN


             * IN list.
             */
            while ((evictBytes < requiredEvictBytes) &&
                   (nNodesScannedThisRun <= inListStartSize)) {

                IN target = selectIN(inList, scanIter);

                if (target == null) {
                    break;
                } else {
                    assert evictProfile.count(target);//intentional side effect
View Full Code Here


     */
    private IN selectIN(INList inList, ScanIterator scanIter)
        throws DatabaseException {

        /* Find the best target in the next <nodesPerScan> nodes. */
        IN target = null;
        long targetGeneration = Long.MAX_VALUE;
        int targetLevel = Integer.MAX_VALUE;
        boolean targetDirty = true;
  boolean envIsReadOnly = envImpl.isReadOnly();
        int scanned = 0;
        boolean wrapped = false;
        while (scanned < nodesPerScan) {
            if (scanIter.hasNext()) {
                IN in = scanIter.next();
                nNodesScannedThisRun++;

                DatabaseImpl db = in.getDatabase();

                /* If the database was deleted, remove it from the inlist. */
                if (db == null || db.getIsDeleted()) {
                    scanIter.remove();
                    continue;
                }

                /*
                 * Don't evict the DatabaseImpl Id Mapping Tree (db 0), both
                 * for object identity reasons and because the id mapping tree
                 * should stay cached.
                 */
                if (db.getId().equals(DbTree.ID_DB_ID)) {
                    continue;
                }

                /*
                 * If this is a read only database and we have at least one
                 * target, skip any dirty INs (recovery dirties INs even in a
                 * read-only environment). We take at least one target so we
                 * don't loop endlessly if everything is dirty.
                 */
                if (envIsReadOnly && (target != null) && in.getDirty()) {
                    continue;
                }

                /*
                 * Only scan evictable or strippable INs.  This prevents higher
                 * level INs from being selected for eviction, unless they are
                 * part of an unused tree.
                 */
                int evictType = in.getEvictionType();
                if (evictType == IN.MAY_NOT_EVICT) {
                    continue;
                }

                /*
                 * This node is in the scanned node set.  Select according to
                 * the configured eviction policy.
                 */
                if (evictByLruOnly) {

                    /*
                     * Select the node with the lowest generation number,
                     * irrespective of tree level or dirtyness.
                     */
                    if (targetGeneration > in.getGeneration()) {
                        targetGeneration = in.getGeneration();
                        target = in;
                    }
                } else {

                    /*
                     * Select first by tree level, then by dirtyness, then by
                     * generation/LRU.
                     */
                    int level = normalizeLevel(in, evictType);
                    if (targetLevel != level) {
                        if (targetLevel > level) {
                            targetLevel = level;
                            targetDirty = in.getDirty();
                            targetGeneration = in.getGeneration();
                            target = in;
                        }
                    } else if (targetDirty != in.getDirty()) {
                        if (targetDirty) {
                            targetDirty = false;
                            targetGeneration = in.getGeneration();
                            target = in;
                        }
                    } else {
                        if (targetGeneration > in.getGeneration()) {
                            targetGeneration = in.getGeneration();
                            target = in;
                        }
                    }
                }
                scanned++;
View Full Code Here

            /*
             * Get a new reference to the child, in case the reference
             * saved in the selection list became out of date because of
             * changes to that parent.
             */
            IN renewedChild = (IN) parent.getTarget(index);
           
            /*
             * See the evict() method in this class for an explanation for
             * calling latchNoWait(false).
             */
            if ((renewedChild != null) &&
                (renewedChild.getGeneration() <= oldGenerationCount) &&
                renewedChild.latchNoWait(false)) {

                try {
                    if (renewedChild.isEvictable()) {

                        /*
                         * Log the child if dirty and env is not r/o. Remove
                         * from IN list.
                         */
                        long renewedChildLsn = DbLsn.NULL_LSN;
                        boolean newChildLsn = false;
                        if (renewedChild.getDirty()) {
                            if (!envIsReadOnly) {

        /*
                                 * Determine whether provisional logging is
                                 * needed.  The checkpointer can be null if it
                                 * was shutdown or never started.
         */
        boolean logProvisional =
            (envImpl.getCheckpointer() != null &&
             (renewedChild.getLevel() < envImpl.
             getCheckpointer().
              getHighestFlushLevel()));

                                /*
                                 * Log a full version (no deltas) and with
                                 * cleaner migration allowed.
                                 */
                                renewedChildLsn = renewedChild.log
                                    (logManager,
                                     false, // allowDeltas
                                     logProvisional,
                                     true,  // allowMigration
                                     parent);
                                newChildLsn = true;
                            }
                        } else {
                            renewedChildLsn = parent.getLsn(index);
                        }

                        if (renewedChildLsn != DbLsn.NULL_LSN) {
                            /* Take this off the inlist. */
                            scanIter.mark();
                            inlist.removeLatchAlreadyHeld(renewedChild);
                            scanIter.resetToMark();

                            evictBytes = renewedChild.getInMemorySize();
                            if (newChildLsn) {

                                /*
                                 * Update the parent so its reference is
                                 * null and it has the proper LSN.
                                 */
                                parent.updateEntry
                                    (index, null, renewedChildLsn);
                            } else {

                                /*
                                 * Null out the reference, but don't dirty
                                 * the node since only the reference
                                 * changed.
                                 */
                                parent.updateEntry(index, (Node) null);
                            }

                            /* Stats */
                            nNodesEvictedThisRun++;
                            nNodesEvicted++;
                        }
                    }
                } finally {
                    renewedChild.releaseLatch();
                }
            }
        } finally {
            parent.releaseLatch();
        }
View Full Code Here

         * @return true if the in-memory root was replaced.
         */
        public IN doWork(ChildReference root)
            throws DatabaseException {
           
            IN rootIN = (IN) root.fetchTarget(db, null);
            rootLevel = rootIN.getLevel();
            return null;
        }
View Full Code Here

  long targetTime = Long.MAX_VALUE;
  if (maxMillisecs > 0) {
      targetTime = System.currentTimeMillis() + maxMillisecs;
  }
  IN next = tree.getFirstNode();
  if (next == null) {
      return;
  }

  if (maxBytes == 0) {
            maxBytes = envImpl.getMemoryBudget().getCacheBudget();
  }

  try {
      while (true) {
    if (System.currentTimeMillis() > targetTime) {
        break;
    }
    next = tree.getNextBin((BIN) next, null);
    if (next == null) {
        break;
    }

    if (envImpl.getMemoryBudget().getCacheMemoryUsage() >
        maxBytes) {
        break;
    }
      }
  } finally {
      if (next != null) {
    next.releaseLatch();
      }
  }

        assert Latch.countLatchesHeld() == 0;
    }
View Full Code Here

       * pass the LSN of the current log entry and also the LSN of the IN
       * in question. The only time these differ is when the log entry is
       * a BINDelta -- then the IN's LSN is the last full version LSN,
       * and the log LSN is the current log entry.
             */
            IN in = reader.getIN();
            long inLsn = reader.getLsnOfIN();
            in.postRecoveryInit(db, inLsn);
            in.latch();
            replaceOrInsert(db, in, reader.getLastLsn(), inLsn,
                            requireExactMatch);
        }

        /*
 
View Full Code Here

        boolean inserted = false;
        boolean replaced = false;
        long originalLsn = DbLsn.NULL_LSN;

        byte[] mainTreeKey = inFromLog.getMainTreeKey();
        IN parent = null;
        int index = -1;
        boolean success = false;
        try {

            /*
             * Allow splits since the parent BIN of this DIN may be full.
             * [#13435]
             */
            parent = db.getTree().searchSplitsAllowed
                (mainTreeKey, -1, true /*updateGeneration*/);
            assert parent instanceof BIN;

      ChildReference newRef =
    new ChildReference(inFromLog, mainTreeKey, lsn);
      index = parent.insertEntry1(newRef);
      if ((index >= 0 &&
     (index & IN.EXACT_MATCH) != 0)) {

    index &= ~IN.EXACT_MATCH;

    /*
     * Replace whatever's at this entry, whether it's an LN or an
     * earlier root DIN as long as one of the following is true:
     *
     * - the entry is known deleted
     * - or the LSN is earlier than the one we've just read from
     *     the log.
     */
    if (parent.isEntryKnownDeleted(index)) {
        /* Be sure to clear the known deleted bit. */
        parent.setEntry(index, inFromLog, mainTreeKey,
            lsn, (byte) 0);
        replaced = true;
    } else {
        originalLsn = parent.getLsn(index);
        if (DbLsn.compareTo(originalLsn, lsn) < 0) {
      parent.setEntry(index, inFromLog, mainTreeKey, lsn,
          parent.getState(index));
      replaced = true;
        }
    }
      } else {
    found = false;
      }
      success = true;
        } finally {
            if (parent != null) {
                parent.releaseLatch();
            }
            trace(detailedTraceLevel,
                  db,
                  TRACE_DUP_ROOT_REPLACE, success, inFromLog,
                  lsn, parent, found,
View Full Code Here

    }

    private long getINFile(Cursor cursor)
        throws DatabaseException {

        IN in = TestUtils.getIN(TestUtils.getBIN(cursor));
        long lsn = in.getLastFullVersion();
        assertTrue(lsn != DbLsn.NULL_LSN);
        return DbLsn.getFileNumber(lsn);
    }
View Full Code Here

    public void dump() {
        System.out.println("size=" + getSize());
  Iterator iter = ins.iterator();
  while (iter.hasNext()) {
      IN theIN = (IN) iter.next();
      System.out.println("db=" + theIN.getDatabase().getId() +
                               " nid=: " + theIN.getNodeId() + "/" +
             theIN.getLevel());
  }
    }
View Full Code Here

        DatabaseId id = dbImpl.getId();
        majorLatch.acquire();

  Iterator iter = ins.iterator();
  while (iter.hasNext()) {
      IN theIN = (IN) iter.next();
      if (theIN.getDatabase().getId().equals(id)) {
    theIN.setGeneration(0);
      }
  }

        releaseMajorLatch();
    }
View Full Code Here

TOP

Related Classes of com.sleepycat.je.tree.IN

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.