Examples of UtilizationTracker


Examples of com.sleepycat.je.cleaner.UtilizationTracker

                                     boolean abortKnownDeleted,
                                     TxnNodeId txnNodeId,
                                     Map countedFileSummaries,
                                     Set countedAbortLsnNodes) {

        UtilizationTracker tracker = env.getUtilizationTracker();

        /* Compare the fileSummaryLsn to the logLsn. */
        Long logFileNum = new Long(DbLsn.getFileNumber(logLsn));
        long fileSummaryLsn =
            DbLsn.longToLsn((Long) fileSummaryLsns.get(logFileNum));
        int cmpFsLsnToLogLsn = (fileSummaryLsn != DbLsn.NULL_LSN) ?
            DbLsn.compareTo(fileSummaryLsn, logLsn) : -1;

        /*
         * Count the logLsn as obsolete if it follows the FileSummaryLN for the
         * file of its Lsn.
         */
        if (cmpFsLsnToLogLsn < 0) {
            tracker.countObsoleteNode(logLsn, null);
        }

        /*
         * Consider the latest LSN for the given node that precedes the
         * FileSummaryLN for the file of its LSN.  Count this LSN as obsolete
         * if it is not a deleted LN.
         */
        if (cmpFsLsnToLogLsn > 0) {
            Long countedFile = (Long) countedFileSummaries.get(txnNodeId);
            if (countedFile == null ||
                countedFile.longValue() > logFileNum.longValue()) {

                /*
                 * We encountered a new file number and the FsLsn follows the
                 * logLsn.
                 */
                if (!ln.isDeleted()) {
                    tracker.countObsoleteNode(logLsn, null);
                }
                /* Don't count this file again. */
                countedFileSummaries.put(txnNodeId, logFileNum);
            }
        }
View Full Code Here

Examples of com.sleepycat.je.cleaner.UtilizationTracker

         * database record and copy its data, and then discard the data.
         * Perhaps internal cursor methods should allow passing null for the
         * DatabaseEntry parameters, since parameter checking is done by the
         * public API.
         */
        UtilizationTracker tracker = new UtilizationTracker(envImpl);
        ObsoleteINCounter inCounter = new ObsoleteINCounter(tracker);
        Locker locker = new ThreadLocker(envImpl);
        Cursor cursor = null;
        int count = 0;
  CursorImpl impl = null;
        try {
      EnvironmentImpl.incThreadLocalReferenceCount();
            cursor = DbInternal.newCursor(this, locker, null);

            /* Setup accumulator to count obsolete INs. */
      impl = DbInternal.getCursorImpl(cursor);
      tree.setTreeStatsAccumulator(inCounter);
      impl.setTreeStatsAccumulator(inCounter);

            DatabaseEntry foundData = new DatabaseEntry();
            DatabaseEntry key = new DatabaseEntry();
            OperationStatus status = DbInternal.position
                (cursor, key, foundData, LockMode.READ_UNCOMMITTED, true);
            while (status == OperationStatus.SUCCESS) {
                count++;
                impl = DbInternal.getCursorImpl(cursor);
                long lsn = impl.getBIN().getLsn(impl.getIndex());

                /*
                 * Use inexact counting to avoid the memory overhead of
                 * tracking LSNs for every record in an obsolete database.
                 */
                tracker.countObsoleteNodeInexact(lsn, null);
                status = DbInternal.retrieveNext
                    (cursor, key, foundData, LockMode.READ_UNCOMMITTED,
                     GetMode.NEXT);
            }
        } finally {
      if (impl != null) {
    impl.setTreeStatsAccumulator(null);
      }
      tree.setTreeStatsAccumulator(null);
      EnvironmentImpl.decThreadLocalReferenceCount();
            if (cursor != null) {
                cursor.close();
            }
        }
        deletedTrackingInfo = tracker.getTrackedFiles();
        return count;
    }
View Full Code Here

Examples of com.sleepycat.je.cleaner.UtilizationTracker

             * added in a single call under the log write latch.  We log the
             * info for deleted subtrees immediately because we don't process
             * deleted IN entries during recovery; this reduces the chance of
             * lost info.
             */
            UtilizationTracker tracker = new UtilizationTracker(env);

            DbTree dbTree = env.getDbMapTree();
            BINSearch binSearch = new BINSearch();
            try {
                Iterator it = queueSnapshot.values().iterator();
                while (it.hasNext()) {
                    if (env.isClosed()) {
                        return;
                    }

                    BINReference binRef = (BINReference) it.next();
                    if (!findDBAndBIN(binSearch, binRef, dbTree)) {

                        /*
                         * Either the db is closed, or the BIN doesn't
                         * exist. Don't process this BINReference.
                         */
                        continue;
                    }
                   
                    if (binRef.deletedKeysExist()) {
                        /* Compress deleted slots. */
                        boolean requeued = compressBin
                            (binSearch.db, binSearch.bin, binRef, tracker);

                        if (!requeued) {

                            /*
                             * This BINReference was fully processed, but there
           * may still be deleted slots. If there are still
           * deleted keys in the binref, they were relocated
           * by a split.
                             */
                            checkForRelocatedSlots
                                (binSearch.db, binRef, tracker);
                        }
                    } else {

                        /*
                         * An empty BINReference on the queue was put there by
                         * a lazy compressor to indicate that we should try to
                         * prune an empty BIN.
                         */
                        BIN foundBin = binSearch.bin;

                        byte[] idKey = foundBin.getIdentifierKey();
                        boolean isDBIN = foundBin.containsDuplicates();
                        byte[] dupKey = null;
                        if (isDBIN) {
                            dupKey = ((DBIN) foundBin).getDupKey();
                        }

                        /*
                         * Release the bin latch taken by the initial
                         * search. Pruning starts from the top of the tree
                         * and requires that no latches are held.
                         */
                        foundBin.releaseLatch();
                       
                        pruneBIN(binSearch.db,  binRef, idKey, isDBIN,
                                 dupKey, tracker);
                    }
                }

                /*
                 * Count obsolete nodes and write out modified file summaries
                 * for recovery.  All latches must have been released.
                 */
                TrackedFileSummary[] summaries = tracker.getTrackedFiles();
                if (summaries.length > 0) {
                    env.getUtilizationProfile().countAndLogSummaries
                        (summaries);
                }
               
View Full Code Here

Examples of com.sleepycat.je.cleaner.UtilizationTracker

      return DbLsn.NULL_LSN;
  }

        boolean marshallOutsideLatch = item.marshallOutsideWriteLatch();
        ByteBuffer marshalledBuffer = null;
        UtilizationTracker tracker = envImpl.getUtilizationTracker();
        LogResult logResult = null;

        try {

            /*
             * If possible, marshall this item outside the log write
             * latch to allow greater concurrency by shortening the
             * write critical section.
             */
            if (marshallOutsideLatch) {
                int itemSize = item.getLogSize();
                int entrySize = itemSize + HEADER_BYTES;
    marshalledBuffer = marshallIntoBuffer(item,
                                                      itemSize,
                                                      isProvisional,
                                                      entrySize);
            }

            logResult = logItem(item, isProvisional, flushRequired,
                                forceNewLogFile, oldNodeLsn,
                                marshallOutsideLatch, marshalledBuffer,
                                tracker);

        } catch (BufferOverflowException e) {

            /*
             * A BufferOverflowException may be seen when a thread is
             * interrupted in the middle of the log and the nio direct buffer
             * is mangled is some way by the NIO libraries. JE applications
             * should refrain from using thread interrupt as a thread
             * communications mechanism because nio behavior in the face of
             * interrupts is uncertain. See SR [#10463].
             *
             * One way or another, this type of io exception leaves us in an
             * unworkable state, so throw a run recovery exception.
             */
            throw new RunRecoveryException(envImpl, e);
        } catch (IOException e) {

            /*
             * Other IOExceptions, such as out of disk conditions, should
             * notify the application but leave the environment in workable
             * condition.
             */
            throw new DatabaseException(Tracer.getStackTrace(e), e);
        }

        /*
         * Finish up business outside of the log write latch critical section.
         */

        /*
   * If this logged object needs to be fsynced, do so now using the group
   * commit mechanism.
         */
        if (fsyncRequired) {
            fileManager.groupSync();
        }

        /*
         * Periodically, as a function of how much data is written, ask the
   * checkpointer or the cleaner to wake up.
         */
        if (logResult.wakeupCheckpointer) {
            checkpointMonitor.activate();
        }
        if (logResult.wakeupCleaner) {
            tracker.activateCleaner();
        }

        return logResult.currentLsn;
    }
View Full Code Here

Examples of com.sleepycat.je.cleaner.UtilizationTracker

        throws DatabaseException;

    protected void countObsoleteINsInternal(List lsnList)
        throws DatabaseException {
       
        UtilizationTracker tracker = envImpl.getUtilizationTracker();

        for (int i = 0; i < lsnList.size(); i += 1) {
            Long offset = (Long) lsnList.get(i);
            tracker.countObsoleteNode(offset.longValue(), LogEntryType.LOG_IN);
        }
    }
View Full Code Here

Examples of com.sleepycat.je.cleaner.UtilizationTracker

      return DbLsn.NULL_LSN;
  }

        boolean marshallOutsideLatch = item.marshallOutsideWriteLatch();
        ByteBuffer marshalledBuffer = null;
        UtilizationTracker tracker = envImpl.getUtilizationTracker();
        LogResult logResult = null;

        try {

            /*
             * If possible, marshall this item outside the log write
             * latch to allow greater concurrency by shortening the
             * write critical section.
             */
            if (marshallOutsideLatch) {
                int itemSize = item.getLogSize();
                int entrySize = itemSize + HEADER_BYTES;
    marshalledBuffer = marshallIntoBuffer(item,
                                                      itemSize,
                                                      isProvisional,
                                                      entrySize);
            }

            logResult = logItem(item, isProvisional, flushRequired,
                                forceNewLogFile, oldNodeLsn,
                                marshallOutsideLatch, marshalledBuffer,
                                tracker);

        } catch (BufferOverflowException e) {

            /*
             * A BufferOverflowException may be seen when a thread is
             * interrupted in the middle of the log and the nio direct buffer
             * is mangled is some way by the NIO libraries. JE applications
             * should refrain from using thread interrupt as a thread
             * communications mechanism because nio behavior in the face of
             * interrupts is uncertain. See SR [#10463].
             *
             * One way or another, this type of io exception leaves us in an
             * unworkable state, so throw a run recovery exception.
             */
            throw new RunRecoveryException(envImpl, e);
        } catch (IOException e) {

            /*
             * Other IOExceptions, such as out of disk conditions, should
             * notify the application but leave the environment in workable
             * condition.
             */
            throw new DatabaseException(Tracer.getStackTrace(e), e);
        }

        /*
         * Finish up business outside of the log write latch critical section.
         */

        /*
   * If this logged object needs to be fsynced, do so now using the group
   * commit mechanism.
         */
        if (fsyncRequired) {
            fileManager.groupSync();
        }

        /*
         * Periodically, as a function of how much data is written, ask the
   * checkpointer or the cleaner to wake up.
         */
        if (logResult.wakeupCheckpointer) {
            checkpointMonitor.activate();
        }
        if (logResult.wakeupCleaner) {
            tracker.activateCleaner();
        }

        return logResult.currentLsn;
    }
View Full Code Here

Examples of com.sleepycat.je.cleaner.UtilizationTracker

        throws DatabaseException;

    protected void countObsoleteINsInternal(List lsnList)
        throws DatabaseException {
       
        UtilizationTracker tracker = envImpl.getUtilizationTracker();

        for (int i = 0; i < lsnList.size(); i += 1) {
            Long offset = (Long) lsnList.get(i);
            tracker.countObsoleteNode(offset.longValue(), LogEntryType.LOG_IN);
        }
    }
View Full Code Here

Examples of com.sleepycat.je.cleaner.UtilizationTracker

                 */
                envImpl.getDbMapTree().deleteMapLN(id);

            } else {

                UtilizationTracker snapshot = new UtilizationTracker(envImpl);

                /* Start by recording the lsn of the root IN as obsolete. */
                snapshot.countObsoleteNodeInexact(rootLsn,
                                                  LogEntryType.LOG_IN);
       

                /* Use the tree walker to visit every child lsn in the tree. */
                ObsoleteProcessor obsoleteProcessor =
                    new ObsoleteProcessor(snapshot);
                SortedLSNTreeWalker walker =
                    new SortedLSNTreeWalker(this,
                                            true,  // remove INs from INList
                                            true,  // set INList finish harvest
                                            rootLsn,
                                            obsoleteProcessor);
                /*
                 * Delete MapLN before the walk. Note that the processing of
                 * the naming tree means this MapLN is never actually
                 * accessible from the current tree, but deleting the MapLN
                 * will do two things:
                 * (a) mark it properly obsolete
                 * (b) null out the database tree, leaving the INList the only
                 * reference to the INs.
                 */
                envImpl.getDbMapTree().deleteMapLN(id);

                /*
                 * At this point, it's possible for the evictor to find an IN
                 * for this database on the INList. It should be ignored.
                 */
                walker.walk();

                /*
                 * Count obsolete nodes for a deleted database at transaction
                 * end time.  Write out the modified file summaries for
                 * recovery.
                 */
                envImpl.getUtilizationProfile().countAndLogSummaries
                    (snapshot.getTrackedFiles());
            }
        } finally {
            deleteState = DELETED;
        }
    }
View Full Code Here

Examples of com.sleepycat.je.cleaner.UtilizationTracker

     * @see LogManager#countObsoleteLNs
     */
    public void countObsoleteNode(long lsn, LogEntryType type)
        throws DatabaseException {

        UtilizationTracker tracker = envImpl.getUtilizationTracker();
        synchronized (logWriteLatch) {
            countObsoleteNodeInternal(tracker, lsn, type);
        }
    }
View Full Code Here

Examples of com.sleepycat.je.cleaner.UtilizationTracker

     * @see LogManager#countObsoleteNodes
     */
    public void countObsoleteNodes(TrackedFileSummary[] summaries)
        throws DatabaseException {

        UtilizationTracker tracker = envImpl.getUtilizationTracker();
        synchronized (logWriteLatch) {
            countObsoleteNodesInternal(tracker, summaries);
        }
    }
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.