Package com.sleepycat.je.cleaner

Examples of com.sleepycat.je.cleaner.Cleaner


         * write out the parents of cleaned nodes.  This ensures that the node
         * will contain the LSN of a cleaned files.
         */
        boolean flushExtraLevel = false;
        Set[] cleanerFiles = null;
        Cleaner cleaner = envImpl.getCleaner();
        if (cleaner != null) {
            cleanerFiles = cleaner.getFilesAtCheckpointStart();
            if (cleanerFiles != null) {
                flushExtraLevel = true;
            }
        }

        lastCheckpointMillis = System.currentTimeMillis();
        resetPerRunCounters();

        /* Get the next checkpoint id. */
        checkpointId++;
        nCheckpoints++;
        boolean success = false;
        boolean traced = false;
        int dirtyMapMemSize = 0;
        MemoryBudget mb = envImpl.getMemoryBudget();
        try {

      /*
       * Eviction can run during checkpoint as long as it follows the
       * same rules for using provisional logging and for propagating
       * logging of the checkpoint dirty set up the tree. We have to lock
       * out the evictor after the logging of checkpoint start until
       * we've selected the dirty set and decided on the highest level to
       * be flushed. See SR 11163, 11349.
       */
      long checkpointStart = DbLsn.NULL_LSN;
      long firstActiveLsn = DbLsn.NULL_LSN;
      SortedMap dirtyMap = null;
      synchronized (envImpl.getEvictor()) {
    /* Log the checkpoint start. */
    CheckpointStart startEntry =
        new CheckpointStart(checkpointId, invokingSource);
    checkpointStart = logManager.log(startEntry);

    /*
     * Remember the first active LSN -- before this position in the
     * log, there are no active transactions at this point in time.
     */
    firstActiveLsn = envImpl.getTxnManager().getFirstActiveLsn();

    if (firstActiveLsn == DbLsn.NULL_LSN) {
        firstActiveLsn = checkpointStart;
    } else {
        if (DbLsn.compareTo(checkpointStart, firstActiveLsn) < 0) {
      firstActiveLsn = checkpointStart;
        }
    }
    /* Find the dirty set. */
    dirtyMap = selectDirtyINs(flushAll, flushExtraLevel);
      }

            /* Add each level's references to the budget. */
      int totalSize = 0;
            for (Iterator i = dirtyMap.values().iterator(); i.hasNext();) {
                Set nodeSet = (Set) i.next();
                int size = nodeSet.size() *
                    MemoryBudget.CHECKPOINT_REFERENCE_SIZE;
    totalSize += size;
                dirtyMapMemSize += size;
            }
      mb.updateMiscMemoryUsage(totalSize);

            /* Flush IN nodes. */
            boolean allowDeltas = !config.getMinimizeRecoveryTime();
            flushDirtyNodes(dirtyMap, flushAll, allowDeltas,
                            flushExtraLevel, checkpointStart);

            /*
             * Flush utilization info AFTER flushing IN nodes to reduce the
             * inaccuracies caused by the sequence FileSummaryLN-LN-BIN.
             */
            flushUtilizationInfo();

            CheckpointEnd endEntry =
                new CheckpointEnd(invokingSource,
                                  checkpointStart,
                                  envImpl.getRootLsn(),
                                  firstActiveLsn,
                                  Node.getLastId(),
                                  envImpl.getDbMapTree().getLastDbId(),
                                  envImpl.getTxnManager().getLastTxnId(),
                                  checkpointId);

            /*
             * Log checkpoint end and update state kept about the last
             * checkpoint location. Send a trace message *before* the
             * checkpoint end log entry. This is done so that the normal trace
             * message doesn't affect the time-based isRunnable() calculation,
             * which only issues a checkpoint if a log record has been written
             * since the last checkpoint.
             */
            trace(envImpl, invokingSource, true);
            traced = true;

            /*
             * Always flush to ensure that cleaned files are not referenced,
             * and to ensure that this checkpoint is not wasted if we crash.
             */
            lastCheckpointEnd =
              logManager.logForceFlush(endEntry,
                                  true); // fsync required
            lastFirstActiveLsn = firstActiveLsn;
            lastCheckpointStart = checkpointStart;

      /*
       * Reset the highestFlushLevel so evictor activity knows there's no
       * further requirement for provisional logging. SR 11163.
       */
      highestFlushLevel = IN.MIN_LEVEL;

            success = true;

            if (cleaner != null && cleanerFiles != null) {
                cleaner.updateFilesAtCheckpointEnd(cleanerFiles);
            }
        } catch (DatabaseException e) {
            Tracer.trace(envImpl, "Checkpointer", "doCheckpoint",
                         "checkpointId=" + checkpointId, e);
            throw e;
View Full Code Here


            (EnvironmentParams.COMPRESSOR_WAKEUP_INTERVAL);
        inCompressor = new INCompressor(this, compressorWakeupInterval,
                                        Environment.INCOMP_NAME);

        /* The cleaner is not time-based so no wakeup interval is used. */
        cleaner = new Cleaner(this, Environment.CLEANER_NAME);
    }
View Full Code Here

     * later when latched), but an exception should not occur.
     */
    @Override
    int getChildEvictionType() {

        Cleaner cleaner = getDatabase().getDbEnvironment().getCleaner();

        for (int i = 0; i < getNEntries(); i++) {
            Node node = getTarget(i);
            if (node != null) {
                if (node instanceof LN) {
                    LN ln = (LN) node;

                    /*
                     * If the LN is not evictable, we may neither strip the LN
                     * nor evict the node.  isEvictableInexact is used here as
                     * a fast check, to avoid the overhead of acquiring a
                     * handle lock while selecting an IN for eviction.   See
                     * evictInternal which will call LN.isEvictable to acquire
                     * an handle lock and guarantee that another thread cannot
                     * open the MapLN.  [#13415]
                     */
                    if (!ln.isEvictableInexact()) {
                        return MAY_NOT_EVICT;
                    }

                    /*
                     * If the cleaner allows eviction, then this LN may be
                     * stripped.
                     */
                    if (cleaner.isEvictable(this, i)) {
                        return MAY_EVICT_LNS;
                    }
                } else {
                    return MAY_NOT_EVICT;
                }
View Full Code Here

        throws DatabaseException {

        assert isLatchOwnerForWrite() :
            "BIN must be latched before evicting LNs";

        Cleaner cleaner = getDatabase().getDbEnvironment().getCleaner();

        /*
         * We can't evict an LN which is pointed to by a cursor, in case that
         * cursor has a reference to the LN object. We'll take the cheap choice
         * and avoid evicting any LNs if there are cursors on this BIN. We
View Full Code Here

     * Evict a single LN if allowed and adjust the memory budget.
     */
    public void evictLN(int index)
        throws DatabaseException {

        Cleaner cleaner = getDatabase().getDbEnvironment().getCleaner();
        long removed = evictInternal(index, cleaner);
        updateMemorySize(removed, 0);
    }
View Full Code Here

         * If there are cleaned files to be deleted, flush an extra level to
         * write out the parents of cleaned nodes.  This ensures that the node
         * will contain the LSN of a cleaned files.
         */
        boolean flushExtraLevel = false;
        Cleaner cleaner = envImpl.getCleaner();
        Set[] cleanerFiles = cleaner.getFilesAtCheckpointStart();
        if (cleanerFiles != null) {
            flushExtraLevel = true;
        }

        lastCheckpointMillis = System.currentTimeMillis();
        resetPerRunCounters();

        /* Get the next checkpoint id. */
        checkpointId++;
        nCheckpoints++;
        boolean success = false;
        boolean traced = false;
        int dirtyMapMemSize = 0;
        MemoryBudget mb = envImpl.getMemoryBudget();
        try {

      /*
       * Eviction can run during checkpoint as long as it follows the
       * same rules for using provisional logging and for propagating
       * logging of the checkpoint dirty set up the tree. We have to lock
       * out the evictor after the logging of checkpoint start until
       * we've selected the dirty set and decided on the highest level to
       * be flushed. See SR 11163, 11349.
       */
      long checkpointStart = DbLsn.NULL_LSN;
      long firstActiveLsn = DbLsn.NULL_LSN;
      SortedMap dirtyMap = null;
      synchronized (envImpl.getEvictor()) {
    /* Log the checkpoint start. */
    CheckpointStart startEntry =
        new CheckpointStart(checkpointId, invokingSource);
    checkpointStart = logManager.log(startEntry);

    /*
     * Remember the first active LSN -- before this position in the
     * log, there are no active transactions at this point in time.
     */
    firstActiveLsn = envImpl.getTxnManager().getFirstActiveLsn();

    if (firstActiveLsn == DbLsn.NULL_LSN) {
        firstActiveLsn = checkpointStart;
    } else {
        if (DbLsn.compareTo(checkpointStart, firstActiveLsn) < 0) {
      firstActiveLsn = checkpointStart;
        }
    }
    /* Find the dirty set. */
    dirtyMap = selectDirtyINs(flushAll, flushExtraLevel);
      }

            /* Add each level's references to the budget. */
      int totalSize = 0;
            for (Iterator i = dirtyMap.values().iterator(); i.hasNext();) {
                Set nodeSet = (Set) i.next();
                int size = nodeSet.size() *
                    MemoryBudget.CHECKPOINT_REFERENCE_SIZE;
    totalSize += size;
                dirtyMapMemSize += size;
            }
      mb.updateMiscMemoryUsage(totalSize);

            /* Flush IN nodes. */
            boolean allowDeltas = !config.getMinimizeRecoveryTime();
            flushDirtyNodes(dirtyMap, flushAll, allowDeltas,
                            flushExtraLevel, checkpointStart);

            /*
             * Flush utilization info AFTER flushing IN nodes to reduce the
             * inaccuracies caused by the sequence FileSummaryLN-LN-BIN.
             */
            flushUtilizationInfo();

            CheckpointEnd endEntry =
                new CheckpointEnd(invokingSource,
                                  checkpointStart,
                                  envImpl.getRootLsn(),
                                  firstActiveLsn,
                                  Node.getLastId(),
                                  envImpl.getDbMapTree().getLastDbId(),
                                  envImpl.getTxnManager().getLastTxnId(),
                                  checkpointId);

            /*
             * Log checkpoint end and update state kept about the last
             * checkpoint location. Send a trace message *before* the
             * checkpoint end log entry. This is done so that the normal trace
             * message doesn't affect the time-based isRunnable() calculation,
             * which only issues a checkpoint if a log record has been written
             * since the last checkpoint.
             */
            trace(envImpl, invokingSource, true);
            traced = true;

            /*
             * Always flush to ensure that cleaned files are not referenced,
             * and to ensure that this checkpoint is not wasted if we crash.
             */
            lastCheckpointEnd =
              logManager.logForceFlush(endEntry,
                                  true); // fsync required
            lastFirstActiveLsn = firstActiveLsn;
            lastCheckpointStart = checkpointStart;

      /*
       * Reset the highestFlushLevel so evictor activity knows there's no
       * further requirement for provisional logging. SR 11163.
       */
      highestFlushLevel = IN.MIN_LEVEL;

            success = true;

            if (cleanerFiles != null) {
                cleaner.updateFilesAtCheckpointEnd(cleanerFiles);
            }
        } catch (DatabaseException e) {
            Tracer.trace(envImpl, "Checkpointer", "doCheckpoint",
                         "checkpointId=" + checkpointId, e);
            throw e;
View Full Code Here

       (EnvironmentParams.COMPRESSOR_WAKEUP_INTERVAL));
        inCompressor = new INCompressor(this, compressorWakeupInterval,
                                        "INCompressor");

  /* The cleaner is not time-based so no wakeup interval is used. */
  cleaner = new Cleaner(this, "Cleaner");
    }
View Full Code Here

    /**
     * @Override
     */
    int getChildEvictionType() {

        Cleaner cleaner = getDatabase().getDbEnvironment().getCleaner();

        for (int i = 0; i < getNEntries(); i++) {
            Node node = getTarget(i);
            if (node != null) {
                if (node instanceof LN) {
                    if (cleaner.isEvictable(this, i)) {
                        return MAY_EVICT_LNS;
                    }
                } else {
                    return MAY_NOT_EVICT;
                }
View Full Code Here

        throws DatabaseException {

        assert isLatchOwner() :
            "BIN must be latched before evicting LNs";

        Cleaner cleaner = getDatabase().getDbEnvironment().getCleaner();

        /* We can't evict an LN which is pointed to by a cursor, in case that
         * cursor has a reference to the LN object. We'll take the cheap
         * choice and avoid evicting any LNs if there are cursors on this
         * BIN. We could do a more expensive, precise check to see entries
View Full Code Here

     * Evict a single LN if allowed and adjust the memory budget.
     */
    public void evictLN(int index)
        throws DatabaseException {

        Cleaner cleaner = getDatabase().getDbEnvironment().getCleaner();
        long removed = evictInternal(index, cleaner);
        updateMemorySize(removed, 0);
    }
View Full Code Here

TOP

Related Classes of com.sleepycat.je.cleaner.Cleaner

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.