@Override public void beforeLog(LogManager logManager, INLogItem item, INLogContext context) throws DatabaseException { EnvironmentImpl envImpl = getDatabase().getDbEnvironment(); /* Allow the cleaner to migrate LNs before logging. */ envImpl.getCleaner().lazyMigrateLNs(this, context.proactiveMigration, context.backgroundIO); /* Check for dirty LNs in deferred-write databases. */ if (getDatabase().isDeferredWriteMode()) { logDirtyLNs(logManager); } /* * We can log a delta rather than full version of this BIN if * - this has been called from the checkpointer with allowDeltas=true * - there is a full version on disk * - we meet the percentage heuristics defined by environment params. * - this delta is not prohibited because of cleaning or compression * - this is not a deferred write db * All other logging should be of the full version. */ boolean doDeltaLog = false; BINDelta deltaInfo = null; if (context.allowDeltas && getLastFullVersion() != DbLsn.NULL_LSN && !prohibitNextDelta && !getDatabase().isDeferredWriteMode()) { deltaInfo = new BINDelta(this); doDeltaLog = doDeltaLog(deltaInfo); } if (doDeltaLog) { item.provisional = Provisional.NO; item.oldLsn = DbLsn.NULL_LSN; item.entry = new SingleItemEntry(getBINDeltaType(), deltaInfo); item.isDelta = true; } else { /* Log a full version of the IN. */ super.beforeLog(logManager, item, context); } }
@Override public void afterLog(LogManager logManager, INLogItem item, INLogContext context) throws DatabaseException { if (item.isDelta) { /* * Don't change the dirtiness of the node -- leave it dirty. Deltas * are never provisional, they must be processed at recovery time. */ lastDeltaVersion = item.newLsn; item.newLsn = DbLsn.NULL_LSN; numDeltasSinceLastFull++; } else { super.afterLog(logManager, item, context); lastDeltaVersion = DbLsn.NULL_LSN; numDeltasSinceLastFull = 0; } prohibitNextDelta = false; }