Package com.persistit.JournalManager

Examples of com.persistit.JournalManager.PageNode


            while (exchange.next()) {
                value.setStreamMode(true);
                final int volumeHandle = value.getInt();
                final long pageAddress = value.getLong();
                final PageNode pn = new PageNode(volumeHandle, pageAddress);
                pageNodes.add(pn);
            }

            Collections.sort(pageNodes, PageNode.READ_COMPARATOR);
            for (final PageNode pn : pageNodes) {
                final Volume vol = jman.volumeForHandle(pn.getVolumeHandle());
                if (vol == null) {
                    continue;
                }
                try {
                    final Buffer buff = get(vol, pn.getPageAddress(), false, true);
                    buff.release();
                    count++;
                    final long now = System.nanoTime();
                    if (now - reportTime >= INVENTORY_PRELOAD_LOG_MESSAGE_NS) {
                        _persistit.getLogBase().bufferInventoryProgress
View Full Code Here


                    }
                }
            }

            private void queryPageNode(final int volumeHandle, final long page, final boolean verbose) {
                PageNode pn = _persistit.getJournalManager().queryPageNode(volumeHandle, pageAddress);
                int count = 0;
                while (pn != null && count++ < MAX_PAGE_NODES) {
                    postMessage(String.format("%,5d: %s", count, pn), LOG_NORMAL);
                    if (!verbose) {
                        break;
                    }
                    pn = pn.getPrevious();
                }
            }

            @Override
            public String getStatus() {
View Full Code Here

            while (exchange.next()) {
                value.setStreamMode(true);
                final int volumeHandle = value.getInt();
                final long pageAddress = value.getLong();
                final PageNode pn = new PageNode(volumeHandle, pageAddress);
                pageNodes.add(pn);
            }

            Collections.sort(pageNodes, PageNode.READ_COMPARATOR);
            for (final PageNode pn : pageNodes) {
                final Volume vol = jman.volumeForHandle(pn.getVolumeHandle());
                if (vol == null) {
                    continue;
                }
                try {
                    final Buffer buff = get(vol, pn.getPageAddress(), false, true);
                    buff.release();
                    count++;
                    final long now = System.nanoTime();
                    if (now - reportTime >= INVENTORY_PRELOAD_LOG_MESSAGE_NS) {
                        _persistit.getLogBase().bufferInventoryProgress
View Full Code Here

                    }
                }
            }

            private void queryPageNode(final int volumeHandle, final long page, final boolean verbose) {
                PageNode pn = _persistit.getJournalManager().queryPageNode(volumeHandle, pageAddress);
                int count = 0;
                while (pn != null && count++ < MAX_PAGE_NODES) {
                    postMessage(String.format("%,5d: %s", count, pn), LOG_NORMAL);
                    if (!verbose) {
                        break;
                    }
                    pn = pn.getPrevious();
                }
            }

            @Override
            public String getStatus() {
View Full Code Here

        if (_lastValidCheckpoint != null) {
            final long lastValidTimestamp = _lastValidCheckpoint.getTimestamp();

            for (final PageNode lastPageNode : _pageMap.values()) {
                boolean branched = false;
                PageNode previous = null;
                for (PageNode pageNode = lastPageNode; pageNode != null; pageNode = pageNode.getPrevious()) {
                    if (pageNode.getTimestamp() <= lastValidTimestamp && pageNode.getJournalAddress() >= _baseAddress) {
                        pageNode.setPrevious(null);
                        if (branched) {
                            previous.setPrevious(null);
                        }
                        pageMap.put(pageNode, pageNode);
                        break;
                    } else {
                        if (!branched) {
View Full Code Here

            if (volume == null) {
                throw new CorruptJournalException("PA reference to volume " + volumeHandle
                        + " is not preceded by an IV record for that handle at " + addressToString(address, timestamp));
            }

            final PageNode pageNode = new PageNode(volumeHandle, pageAddress, address, timestamp);
            final PageNode oldPageNode = _pageMap.get(pageNode);
            pageNode.setPrevious(oldPageNode);
            _pageMap.put(pageNode, pageNode);
            _persistit.getLogBase().recoveryRecord.log("PA", pageNode.toStringJournalAddress(this),
                    pageNode.toStringPageAddress(this), timestamp);
        }
View Full Code Here

                        + " in entry " + (count - remaining + 1) + " at " + addressToString(from, timestamp));
            }
            final long pageAddress = PM.getEntryPageAddress(_readBuffer, index);
            final long pageTimestamp = PM.getEntryTimestamp(_readBuffer, index);
            final long journalAddress = PM.getEntryJournalAddress(_readBuffer, index);
            final PageNode pageNode = new PageNode(volumeHandle, pageAddress, journalAddress, pageTimestamp);
            final PageNode lastPageNode;
            boolean linked = false;
            //
            // The following logic places the recovered PageNode in either the
            // page map or the branch map. The timestamp written in the PM
            // record determines which map receives the page, corresponding with
            // two different recovery scenarios.
            //
            // In one scenario, the PM was written as part of a normal rollover,
            // and all pages in it are part of the recovered history. In this
            // the timestamp at the time the PM record is written will be larger
            // than any existing page, and therefore the page will be added to
            // the page map.
            //
            // However, if the PM record was written immediately after a dirty
            // startup, the PM's timestamp will be consistent with the recovery
            // checkpoint, and there will be pages with timestamps after that.
            // Those pages are part of the branch; they are retained in the
            // recovery state solely to allow long-record recovery, and will
            // then be discarded.
            //
            // Because pre-2.4.1 PM records were written with a timestamp of
            // zero, this is handled as a special case. All pages from such
            // journals are recovered.
            //
            if (timestamp != 0 && timestamp < pageTimestamp) {
                lastPageNode = _branchMap.get(pageNode);
                if (lastPageNode == null || journalAddress > lastPageNode.getJournalAddress()) {
                    pageNode.setPrevious(lastPageNode);
                    _branchMap.put(pageNode, pageNode);
                    linked = true;
                }
            } else {
                lastPageNode = _pageMap.get(pageNode);
                if (lastPageNode == null || journalAddress > lastPageNode.getJournalAddress()) {
                    pageNode.setPrevious(lastPageNode);
                    _pageMap.put(pageNode, pageNode);
                    linked = true;
                }
            }
View Full Code Here

        //
        final long startingAddress = generation * _blockSize;
        final long endingAddress = startingAddress + blockSize;
        long lastRequiredJournalAddress = startingAddress;

        PageNode lastRequiredPageNode = null;
        for (final PageNode pageNode : _pageMap.values()) {
            for (PageNode pn = pageNode; pn != null; pn = pn.getPrevious()) {
                if (pn.getJournalAddress() < lastRequiredJournalAddress) {
                    break;
                }
                if (pn.getJournalAddress() < endingAddress) {
                    lastRequiredJournalAddress = pn.getJournalAddress();
                    lastRequiredPageNode = pn;
                }
            }
        }
        if (lastRequiredJournalAddress > startingAddress) {
            read(lastRequiredJournalAddress, PA.OVERHEAD);
            type = getType(_readBuffer);
            validate(type, file, startingAddress, PA.TYPE, "Invalid record type %3$,d at %1$s:%2$d");
            recordSize = getLength(_readBuffer);
            validate(recordSize, file, startingAddress, PA.OVERHEAD + Buffer.HEADER_SIZE, PA.OVERHEAD
                    + Buffer.MAX_BUFFER_SIZE, "PA record size %3$,d not in valid range "
                    + "[%4$,d:%5$,d] at %1$s:%2$,d");
            final long pageAddress = PA.getPageAddress(_readBuffer);
            validate(pageAddress, file, startingAddress, lastRequiredPageNode.getPageAddress(),
                    "Mismatched page address %3$d at %1$s:%2$d");
            // confirm that we can read the data
            read(lastRequiredJournalAddress, recordSize);

        }
View Full Code Here

            }
            //
            // Look for the latest version of the page which precedes the
            // record's timestamp.
            //
            final PageNode key = new PageNode(volumeHandle, page, -1, -1);
            PageNode pn = lastPageNodeBefore(_branchMap.get(key), timestamp);
            if (pn == null) {
                pn = lastPageNodeBefore(_pageMap.get(key), timestamp);
            }

            if (pn == null) {
                throw new CorruptJournalException("Long record chain missing page " + page + " at count " + count
                        + " at " + addressToString(from, timestamp));
            }

            _currentAddress = pn.getJournalAddress();
            read(_currentAddress, PA.OVERHEAD);
            final int type = PA.getType(_readBuffer);
            final int recordSize = PA.getLength(_readBuffer);
            final int payloadSize = recordSize - PA.OVERHEAD;
            final int leftSize = PA.getLeftSize(_readBuffer);
            final int bufferSize = PA.getBufferSize(_readBuffer);
            final long pageAddress = PA.getPageAddress(_readBuffer);
            //
            // Verify that this is the valid and appropriate PA record
            //
            if (type != PA.TYPE) {
                throw new CorruptJournalException("Record at " + pn.toStringJournalAddress(this)
                        + " is not a PAGE record");
            }

            if (leftSize < 0 || payloadSize < leftSize || payloadSize > bufferSize) {
                throw new CorruptJournalException("Record at " + pn.toStringJournalAddress(this)
                        + " invalid sizes: recordSize= " + payloadSize + " leftSize=" + leftSize + " bufferSize="
                        + bufferSize);
            }

            if (pageAddress != pn.getPageAddress()) {
                throw new CorruptJournalException("Record at " + pn.toStringJournalAddress(this)
                        + " mismatched page address: expected/actual=" + pn.getPageAddress() + "/" + pageAddress);
            }

            //
            // Verify that this is a PAGE_TYPE_LONG_RECORD
            //
            read(_currentAddress, recordSize);
            final int pageType = JournalRecord.getByte(_readBuffer, PA.OVERHEAD + Buffer.TYPE_OFFSET);

            if (pageType != Buffer.PAGE_TYPE_LONG_RECORD) {
                throw new CorruptJournalException("Long record chain contains invalid page type " + pageType
                        + " for page " + page + " at " + pn.toStringJournalAddress(this) + " in transaction at "
                        + addressToString(from, timestamp));
            }

            final int segmentSize = Math.min(remainingSize, payloadSize - Buffer.HEADER_SIZE);
View Full Code Here

        }
        value.setEncodedSize(size);
    }

    private PageNode lastPageNodeBefore(final PageNode pageNode, final long timestamp) {
        PageNode pn = pageNode;
        while (pn != null) {
            if (pn.getTimestamp() <= timestamp) {
                break;
            }
            pn = pn.getPrevious();
        }
        return pn;
    }
View Full Code Here

TOP

Related Classes of com.persistit.JournalManager.PageNode

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.