Package com.persistit.exception

Examples of com.persistit.exception.CorruptJournalException


            startTimestamp = TX.getTimestamp(_support.getReadBuffer());
            commitTimestamp = TX.getCommitTimestamp(_support.getReadBuffer());
            backchainAddress = TX.getBackchainAddress(_support.getReadBuffer());
            if (recordSize < TX.OVERHEAD || recordSize > Transaction.TRANSACTION_BUFFER_SIZE + TX.OVERHEAD
                    || type != TX.TYPE) {
                throw new CorruptJournalException("Transaction record at " + addressToString(address)
                        + " has invalid length " + recordSize + " or type " + type);
            }
            if (startTimestamp != item.getStartTimestamp()) {
                throw new CorruptJournalException("Transaction record at " + addressToString(address)
                        + " has an invalid start timestamp: " + startTimestamp);
            }
            if (backchainAddress == 0) {
                if (address != item.getStartAddress()) {
                    throw new CorruptJournalException("Transaction record at " + addressToString(address)
                            + " has an invalid start " + addressToString(item.getStartAddress()));
                }
                break;
            }
            chainedAddress.add(0, address);
            address = backchainAddress;
        }

        listener.startTransaction(address, startTimestamp, commitTimestamp);
        applyTransactionUpdates(_support.getReadBuffer(), address, recordSize, startTimestamp, commitTimestamp,
                listener);

        for (final Long continuation : chainedAddress) {
            address = continuation.longValue();
            _support.read(address, TX.OVERHEAD);
            recordSize = TX.getLength(_support.getReadBuffer());
            if (recordSize < TX.OVERHEAD || recordSize > Transaction.TRANSACTION_BUFFER_SIZE + TX.OVERHEAD
                    || type != TX.TYPE) {
                throw new CorruptJournalException("Transaction record at " + addressToString(address)
                        + " has invalid length " + recordSize + " or type " + type);
            }
            _support.read(address, recordSize);
            applyTransactionUpdates(_support.getReadBuffer(), address, recordSize, startTimestamp, commitTimestamp,
                    listener);
View Full Code Here


                    appliedUpdates.incrementAndGet();
                    break;
                }

                default: {
                    throw new CorruptJournalException("Invalid record type " + type + " at journal address "
                            + addressToString(address + position - start) + " index of transaction record at "
                            + addressToString(address));
                }
                }
            } catch (final VolumeNotFoundException vnfe) {
View Full Code Here

     */
    private Exchange getExchange(final int treeHandle, final long from, final long timestamp,
            final TransactionPlayerListener listener) throws PersistitException {
        final TreeDescriptor td = _support.getPersistit().getJournalManager().lookupTreeHandle(treeHandle);
        if (td == null) {
            throw new CorruptJournalException("Tree handle " + treeHandle + " is undefined at "
                    + addressToString(from, timestamp));
        }
        final Volume volume = _support.getPersistit().getJournalManager().volumeForHandle(td.getVolumeHandle());
        if (volume == null) {
            throw new CorruptJournalException("Volume handle " + td.getVolumeHandle() + " is undefined at "
                    + addressToString(from, timestamp));
        }
        if (VolumeStructure.DIRECTORY_TREE_NAME.equals(td.getTreeName())) {
            return volume.getStructure().directoryExchange();
        } else {
View Full Code Here

            } catch (final IOException ioe) {
                throw new PersistitIOException(ioe);
            }
            if (count < 0) {
                final File file = addressToFile(address);
                throw new CorruptJournalException(String.format("End of file at %s:%d(%,d)", file, fileAddr, address));
            }
            fileAddr += count;
        }
        bb.limit(bb.position());
        bb.position(position);
View Full Code Here

        final long recordPageAddress = readPageBufferFromJournal(pn, bb);
        _persistit.getIOMeter().chargeReadPageFromJournal(volume, pageAddress, bufferSize, pn.getJournalAddress(),
                buffer.getIndex());

        if (pageAddress != recordPageAddress) {
            throw new CorruptJournalException("Record at " + pn + " is not volume/page " + buffer.toString());
        }

        if (bb.limit() != bufferSize) {
            throw new CorruptJournalException("Record at " + pn + " is wrong size: expected/actual=" + bufferSize + "/"
                    + bb.limit());
        }
        _readPageCount++;
        buffer.getVolume().getStatistics().bumpReadCounter();
        return true;
View Full Code Here

            CorruptJournalException {
        final int at = bb.position();
        bb.limit(at + PA.OVERHEAD);
        readFully(bb, pn.getJournalAddress());
        if (bb.remaining() < PA.OVERHEAD) {
            throw new CorruptJournalException("Record at " + pn.toStringJournalAddress(this) + " is incomplete");
        }
        final int type = JournalRecord.getType(bb);
        final int payloadSize = JournalRecord.getLength(bb) - PA.OVERHEAD;
        final int leftSize = PA.getLeftSize(bb);
        final int bufferSize = PA.getBufferSize(bb);
        final long pageAddress = PA.getPageAddress(bb);

        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() && pn.getPageAddress() != -1) {
            throw new CorruptJournalException("Record at " + pn.toStringJournalAddress(this)
                    + " mismatched page address: expected/actual=" + pn.getPageAddress() + "/" + pageAddress);
        }

        bb.limit(at + payloadSize).position(at);
        readFully(bb, pn.getJournalAddress() + PA.OVERHEAD);
View Full Code Here

            try {
                if (_writeBuffer.position() > 0) {
                    final FileChannel channel = getFileChannel(address);
                    final long size = channel.size();
                    if (size < addressToOffset(address)) {
                        throw new CorruptJournalException(String.format(
                                "Journal file %s size %,d does not match current address %,d", addressToFile(address),
                                size, address));
                    }

                    _writeBuffer.flip();
View Full Code Here

            Debug.$assert0.t(pageAddress == pageNode.getPageAddress());
            pageNode.setOffset(at);

            if (bb.limit() - at != volume.getStructure().getPageSize()) {
                throw new CorruptJournalException(pageNode.toStringPageAddress(this) + " bufferSize " + bb.limit()
                        + " does not match " + volume + " bufferSize " + volume.getPageSize() + " at "
                        + pageNode.toStringJournalAddress(this));
            }

            bb.position(bb.limit());
View Full Code Here

                    offset += readSize;
                }
                _readBufferAddress = address;
                _readBuffer.flip();
                if (_readBuffer.remaining() < size) {
                    throw new CorruptJournalException("End of file at " + addressToString(address));
                }
            } catch (final IOException e) {
                throw new PersistitIOException("Reading from " + addressToString(address), e);
            }
        }
View Full Code Here

        }

        void dumpPageMap(final int count, final long from, final long timestamp, final int recordSize)
                throws PersistitIOException {
            if (count * PM.ENTRY_SIZE + PM.OVERHEAD != recordSize) {
                throw new CorruptJournalException("Invalid record size " + recordSize + " for PM record at "
                        + addressToString(from, timestamp));
            }

            long address = from + PM.OVERHEAD;
            int index = 0;
            int loaded = 0;
            long lastPage = Long.MAX_VALUE;
            int lastVolumeHandle = Integer.MAX_VALUE;
            for (int remaining = count; remaining > 0; remaining--) {
                if (index == loaded) {
                    final int loadedSize = Math.min((_readBuffer.capacity() / PM.ENTRY_SIZE) * PM.ENTRY_SIZE, remaining
                            * PM.ENTRY_SIZE);
                    read(address, loadedSize);
                    address += loadedSize;
                    index = 0;
                    loaded = loadedSize / PM.ENTRY_SIZE;
                    if (loaded <= 0) {
                        throw new CorruptJournalException("Could not load PageMap segment in entry "
                                + (count - remaining + 1) + " at " + addressToString(from, timestamp));
                    }
                }
                final int volumeHandle = PM.getEntryVolumeHandle(_readBuffer, index);
                final long pageAddress = PM.getEntryPageAddress(_readBuffer, index);
View Full Code Here

TOP

Related Classes of com.persistit.exception.CorruptJournalException

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.