Start line:  
End line:  

Snippet Preview

Snippet HTML Code

Stack Overflow Questions
 /*-
  * See the file LICENSE for redistribution information.
  *
  * Copyright (c) 2002, 2013 Oracle and/or its affiliates.  All rights reserved.
  *
  */
 
 package com.sleepycat.je.txn;
 
Convenience class to package together the different steps and fields needed for reading a log entry for undoing. Is used for both txn aborts and recovery undos.
public class UndoReader {
    public final LNLogEntry logEntry;
    public final LN ln;
    private final long lsn;
    public final DatabaseImpl db;
    
    private UndoReader(LNLogEntry logEntryLN lnlong lsnDatabaseImpl db) {
        this. = logEntry;
        this. = ln;
        this. = lsn;
        this. = db;
    }

    
Set up an UndoReader when doing an undo or txn partial rollback for a live txn.

Never returns null. The DB ID of the LN must be present in undoDatabases, or a fatal exception is thrown.

    public static UndoReader
        create(EnvironmentImpl envImpl,
               long undoLsn,
               Map<DatabaseIdDatabaseImplundoDatabases) {
        final LNLogEntry logEntry = (LNLogEntryenvImpl.getLogManager().
            getLogEntryHandleFileNotFound(undoLsn);
        final DatabaseId dbId = logEntry.getDbId();
        final DatabaseImpl db = undoDatabases.get(dbId);
        if (db == null) {
            throw EnvironmentFailureException.unexpectedState
                (envImpl,
                 "DB not found during non-recovery undo/rollback, id=" + dbId);
        }
        logEntry.postFetchInit(db);
        final LN ln = logEntry.getLN();
        final long lsn = undoLsn;
        ln.postFetchInit(dbundoLsn);
        return new UndoReader(logEntrylnlsndb);
    }

    
Set up an UndoReader when doing a recovery partial rollback. In that case, we have a file reader positioned at the pertinent log entry.

This method calls DbTree.getDb. The caller is responsible for calling DbTree.releaseDb on the db field.

Null is returned if the DB ID of the LN has been deleted.

    public static UndoReader createForRecovery(LNFileReader reader,
                                               DbTree dbMapTree) {
        final LNLogEntry logEntry = reader.getLNLogEntry();
        final DatabaseId dbId = logEntry.getDbId();
        final DatabaseImpl db = dbMapTree.getDb(dbId);
        if (db == null) {
            return null;
        }
        logEntry.postFetchInit(db);
        final LN ln = logEntry.getLN();
        final long lsn = reader.getLastLsn();
        ln.postFetchInit(dblsn);
        return new UndoReader(logEntrylnlsndb);
    }
    @Override
    public String toString() {
        return  + " lsn=" + DbLsn.getNoFormatString();
    }
New to GrepCode? Check out our FAQ X