Examples of LSN


Examples of org.chaidb.db.log.Lsn

        txnChain = new Hashtable(maxTxns);
        freePool = new Queue();

        /* Initialize lastCkp Lsn to 'zero'. */
        lastCkp = new Lsn(LogManager.FIRSTREC_LSN);


        timeCkp = 0;
        nAbortedTxns = 0;
        nCommittedTxns = 0;
View Full Code Here

Examples of org.chaidb.db.log.Lsn

     * Gets the Lsn of the last checkpoint.
     *
     * @return The Lsn of the last checkpoint.
     */
    public Lsn getLastCkp() {
        return new Lsn(this.lastCkp);
    }
View Full Code Here

Examples of org.chaidb.db.log.Lsn

    /**
     * get smallest Lsn of all active txn begin_lsn
     */
    public Lsn getSmallestLsnOfAllActiveTxn() {
        if ((txnChain == null) || (txnChain.isEmpty())) return null;
        Lsn tempLsn = null;
        Enumeration txnEnum = txnChain.elements();
        Lsn txnBeginLsn = null;
        TransactionImpl tempTxn;
        while (txnEnum.hasMoreElements()) {
            tempTxn = (TransactionImpl) txnEnum.nextElement();
            txnBeginLsn = tempTxn.getBeginLsn();

            /* modified by marriane 2002-6-18 ignore transactions which just
                began and no log records during these txns,so its beginLsn is
                equals to (-1,-1). */
            if (txnBeginLsn.compare(new Lsn(LogManager.INVALID_LSN_FILE_ID, LogManager.INVALID_LSN_OFFSET)) == 0) {
                continue;
            }

            /*modified by marriane 2002-6-20,new Lsn, for not using the beginLsn
                reference,because it'll be set to (-1,-1) while txn end. Or it
                will cause recover couldn't find log file because the log file
                has been moved by archive,but the second-to-last checkpoint's
                smallest lsn is (-1,-1),and it leads to recover doing to
                (-1,-1)*/
            if (tempLsn == null) {
                tempLsn = new Lsn(txnBeginLsn);
            } else if (tempLsn.compare(txnBeginLsn) > 0) {
                /* tempLsn is larger than txnBeginLsn */
                tempLsn = new Lsn(txnBeginLsn);//new Lsn
            }
        }
        return tempLsn;
    }
View Full Code Here

Examples of org.chaidb.db.log.Lsn

        this.mins = mins;
        this.flags = flags;
        this.checkpoint = new Checkpoint(txnManager, flags);

        /* Initialize checkpoint LSN to 'zero'. */
        ckpLsn = new Lsn(LogManager.FIRSTREC_LSN);
    }
View Full Code Here

Examples of org.chaidb.db.log.Lsn

     */
    public TransactionImpl(TransactionManager txnManager) {
        lnkTransactionManager = txnManager;
        childs = new Hashtable();
        //initialize beginLsn ans lastLsn.
        beginLsn = new Lsn(LogManager.INVALID_LSN_FILE_ID, LogManager.INVALID_LSN_OFFSET);
        lastLsn = new Lsn(LogManager.INVALID_LSN_FILE_ID, LogManager.INVALID_LSN_OFFSET);

        this.flags = 0;
        this.status = 0;

    }
View Full Code Here

Examples of org.chaidb.db.log.Lsn

    /**
     * Undo the transaction.
     */
    private void undo() throws ChaiDBException {
        Lsn keyLsn;
        LogRecord logRecord;

        keyLsn = this.lastLsn;
        if (keyLsn.equals(_INVALID_LSN)) return;
        logRecord = lnkTransactionManager.getLogManager().get(keyLsn);

        /* Allocate a transaction list for children or aborted page creates. */
        for (keyLsn = this.lastLsn; !keyLsn.equals(_INVALID_LSN); keyLsn = logRecord.getPrevLsn()) {
            logRecord = lnkTransactionManager.getLogManager().get(keyLsn);
            try {
                logRecord.recover(LogRecord.UNDO);
            } catch (ChaiDBException ie) {
                logger.error(ie);
View Full Code Here

Examples of org.chaidb.db.log.Lsn

    protected boolean getNextStack() {
        File dir = new File(RECOVERY_TMP);
        String[] fname;
        String tmp0, tmp1, tmp2;
        Lsn lsn = new Lsn();
        Lsn minLsn = new Lsn(Short.MAX_VALUE, Integer.MAX_VALUE);
        if (dir.exists() && dir.isDirectory()) {
            fname = dir.list();
            for (int i = 0; i < fname.length; i++)
                if (fname[i].startsWith("redo_")) {
                    tmp0 = fname[i].substring(5);
                    int index = tmp0.indexOf("-");
                    if (index > -1) {
                        tmp1 = tmp0.substring(0, index);
                        tmp2 = tmp0.substring(index + 1);
                        lsn.setFileId(Integer.parseInt(tmp1));
                        lsn.setOffset(Integer.parseInt(tmp2));
                        if (lsn.compare(minLsn) == -1) {
                            minLsn.setFileId(lsn.getFileId());
                            minLsn.setOffset(lsn.getOffset());
                        }
                    }
                }//end for
            if (fname.length == 0) return false;
            File f0;
            ObjectInputStream in = null;
            try {
                f0 = new File(RECOVERY_TMP + File.separator + "redo_" + colon2sub(minLsn.toString()));
                in = new ObjectInputStream(new BufferedInputStream(new FileInputStream(f0)));
                redoStack = (Stack) in.readObject();
                in.close();
                return f0.delete();
            } catch (Exception e) {
View Full Code Here

Examples of org.chaidb.db.log.Lsn

     * 2.do undo to checkpoint in V3.0
     * V3.1 should be compatible to V3.0
     */
    protected boolean undo() throws ChaiDBException {
        this.status = UNDO_STAGE;
        Lsn cursorLsn = null;
        LogRecord cursorLogRecord = null;
        int countCkp = 0; //checkpoint count number

        //Gets the lastest lsn in lsn.idb file.
        cursorLsn = txnManager.getLogManager().getLastLsnInFlush();
        boolean isEnd = false;
        Lsn smallestLsn = null;
        while (!isEnd) {
            try {
                cursorLogRecord = txnManager.getLogManager().get(cursorLsn);
            } catch (ChaiDBException e) {
                logger.error(e);
                throw e;
            }
            /* according to different log type to do different handling */
            switch (cursorLogRecord.getType()) {
                case LogRecord.LOG_TXN_CHILD:
                    break;
                case LogRecord.LOG_TXN_CHECKPOINT://V3.0 standard checkpoint consistent state
                    countCkp++;
                    if (countCkp == 1) {
                        this.txnManager.setLastCkp(cursorLsn);
                    } else if (countCkp == 2) {
                        isEnd = true;
                    }
                    break;
                case LogRecord.LOG_TXN_FUZZY_CHECKPOINT://V3.1 fuzzy checkpoint
                    countCkp++;
                    if (countCkp == 1) {
                        this.txnManager.setLastCkp(cursorLsn);
                    } else if (countCkp == 2) {
                        TxnFuzzyCkpLogRecord fuzzyCkpLog = (TxnFuzzyCkpLogRecord) cursorLogRecord;
                        /* V3.1, if no active txn while doing fuzzy checkpoint,
                            smallestLsn is equals to current checkpoint log lsn,if
                            has active txns,it's euqals to smallest first_lsn of all
                            active txns. */
                        smallestLsn = fuzzyCkpLog.getSmallestLsn();
                    }
                    break;
                default:
                    //Adding TxnRegopLogRecord to redostack,and do its redo function for release txn resource of btree.
                    if (cursorLogRecord.getType() == LogRecord.LOG_TXN_REGOP) {
                        Integer txnid = new Integer(cursorLogRecord.getTxnId());
                        redoTable.put(txnid, txnid);
                    }

                    boolean doUNDO = false;
                    if (!redoTable.containsKey(new Integer(cursorLogRecord.getTxnId()))) {
                        doUNDO = true;
                    }

                    if (cursorLogRecord.getType() == LogRecord.LOG_DELETE_FILES) {
                        if (!redoTable.containsKey(new Integer(cursorLogRecord.getTxnId()))) {
                            Integer txnid = new Integer(cursorLogRecord.getTxnId());
                            redoTable.put(txnid, txnid);
                        }
                        doUNDO = false;
                    }

                    if (doUNDO) {
                        try {
                            cursorLogRecord.recover(LogRecord.UNDO);
                        } catch (ChaiDBException ie11) {
                            logger.error(ie11);
                            continue;
                        }
                    } else { //push into redo stack
                        redoStack.push(cursorLogRecord);
                        if (redoStack.size() == STACK_MAXSIZE) {
                            logger.info("Stack change. " + redoStack.size());

                            saveStack(cursorLsn);
                            logger.info(", New=" + redoStack.size() + " Stack" + (++stacks));
                        }

                    }
            }//switch

            if (cursorLsn.getOffset() == LogManager.FIRSTREC_PREVOFFSET || //current lsn is the first lsn of all log files
                    (smallestLsn != null && cursorLsn.compare(smallestLsn) == 0)//current lsn is equal to smallest lsn
                    ) {
                isEnd = true;
            }

            cursorLsn = new Lsn(cursorLsn.getFileId(), cursorLogRecord.getHeader().getPrevOffset());

        }//while

        if (countCkp == 0) {
            this.txnManager.setLastCkp(new Lsn(LogManager.FIRSTREC_LSN));
        }
        return true;
    }
View Full Code Here

Examples of org.chaidb.db.log.Lsn

     * user interface to add a log record and put it to buffer pool
     */
    public Lsn log() throws ChaiDBException {
        super.log();
        LogManager logMgr = Db.getLogManager();
        Lsn newLsn = logMgr.put(this, LogManager.LOG_DATA);

        return newLsn;
    }
View Full Code Here

Examples of org.chaidb.db.log.Lsn

    /**
     * user interface to add a log record and put it to buffer pool
     */
    public Lsn log() throws ChaiDBException {
        super.log();
        Lsn newLsn = Db.getLogManager().put(this, LogManager.LOG_DATA);

        return newLsn;
    }
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.