Package com.persistit.exception

Examples of com.persistit.exception.CorruptJournalException


        return type;
    }

    long processOneRecord(final long from, final long timestamp, final int recordSize, final int type) throws Exception {
        if (recordSize >= _blockSize || recordSize < SUB_RECORD_OVERHEAD) {
            throw new CorruptJournalException("Bad JournalRecord length " + recordSize + " at position "
                    + addressToString(from, timestamp));
        }
        long address = from;
        switch (type) {

        case JE.TYPE:
            if (_selectedTypes.get(type)) {
                _action.je(address, timestamp, recordSize);
            }
            break;

        case JH.TYPE:
            read(_currentAddress, recordSize);
            final long blockSize = JH.getBlockSize(_readBuffer);
            if (blockSize != _blockSize) {
                address = _currentAddress = (_currentAddress / _blockSize) * blockSize;
                _readBufferAddress = _currentAddress;
                _blockSize = blockSize;
            }
            if (_selectedTypes.get(type)) {
                _action.jh(address, timestamp, recordSize);
            }
            break;

        case SR.TYPE:
            if (_selectedTypes.get(type) && _selectedTimestamps.isSelected(timestamp)) {
                _action.sr(address, timestamp, recordSize);
            }
            break;

        case DR.TYPE:
            if (_selectedTypes.get(type) && _selectedTimestamps.isSelected(timestamp)) {
                _action.dr(address, timestamp, recordSize);
            }
            break;

        case DT.TYPE:
            if (_selectedTypes.get(type) && _selectedTimestamps.isSelected(timestamp)) {
                _action.dt(address, timestamp, recordSize);
            }
            break;

        case IV.TYPE:
            if (_selectedTypes.get(type)) {
                _action.iv(address, timestamp, recordSize);
            }
            break;

        case IT.TYPE:
            if (_selectedTypes.get(type)) {
                _action.it(address, timestamp, recordSize);
            }
            break;

        case PA.TYPE:
            if (_selectedTypes.get(type) && _selectedTimestamps.isSelected(timestamp)) {
                _action.pa(address, timestamp, recordSize);
            }
            break;

        case PM.TYPE:
            if (_selectedTypes.get(type)) {
                _action.pm(address, timestamp, recordSize);
            }
            break;

        case TM.TYPE:
            if (_selectedTypes.get(type)) {
                _action.tm(address, timestamp, recordSize);
            }
            break;

        case TX.TYPE:
            if (_selectedTypes.get(type) && _selectedTimestamps.isSelected(timestamp)) {
                _action.tx(address, timestamp, recordSize);
            }
            break;

        case CP.TYPE:
            if (_selectedTypes.get(type) && _selectedTimestamps.isSelected(timestamp)) {
                _action.cp(address, timestamp, recordSize);
            }
            break;

        case D0.TYPE:
            if (_selectedTypes.get(type) && _selectedTimestamps.isSelected(timestamp)) {
                _action.d0(address, timestamp, recordSize);
            }
            break;

        case D1.TYPE:
            if (_selectedTypes.get(type) && _selectedTimestamps.isSelected(timestamp)) {
                _action.d1(address, timestamp, recordSize);
            }
            break;

        default:
            if (!isValidType(type)) {
                _currentAddress -= OVERHEAD;
                throw new CorruptJournalException("Invalid record type " + type + " at " + addressToString(address));
            }
        }
        return address + recordSize;

    }
View Full Code Here


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

            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) 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

            final String message) throws CorruptJournalException {
        if (value == expected) {
            return;
        }

        throw new CorruptJournalException(String.format(message, file, address, value, expected));
    }
View Full Code Here

            final String message) throws CorruptJournalException {
        if (value >= min && value <= max) {
            return;
        }

        throw new CorruptJournalException(String.format(message, file, address, value, min, max));
    }
View Full Code Here

        if (files.length == 0) {
            return;
        }

        File rejectedPrimordialFile = null;
        CorruptJournalException savedException = null;

        for (int fileIndex = files.length; --fileIndex >= 0;) {
            final File candidate = files[fileIndex];
            _keystoneFile = candidate;
            final long generation = JournalManager.fileToGeneration(candidate);
            final long size;

            try {
                //
                // Attempt to read and validate a journal file as a candidate
                // keystone.
                //
                final RandomAccessFile raf = new RandomAccessFile(candidate, "r");
                final FileChannel readChannel = raf.getChannel();
                size = Math.min(readChannel.size(), DEFAULT_BUFFER_SIZE);
                if (size < JH.OVERHEAD) {
                    // This file cannot be a valid journal file because
                    // it's too short.
                    throw new CorruptJournalException(String.format(
                            "Invalid Persistit journal file %s - no journal header", candidate));
                }
                _readBufferAddress = 0;
                _readBuffer.limit(JH.MAX_LENGTH);
                readChannel.read(_readBuffer, 0);
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

        final int type = getType(_readBuffer);
        final long timestamp = getTimestamp(_readBuffer);
        _persistit.getTimestampAllocator().updateTimestamp(timestamp);

        if (recordSize >= _blockSize || recordSize < OVERHEAD) {
            throw new CorruptJournalException("Bad JournalRecord length " + recordSize + " at position "
                    + addressToString(from, timestamp));
        }

        switch (type) {

        case JE.TYPE:
            scanJournalEnd(from, timestamp, recordSize);
            break;

        case JH.TYPE:
            break;

        case SR.TYPE:
        case DR.TYPE:
        case DT.TYPE:
        case D0.TYPE:
        case D1.TYPE:
            throw new CorruptJournalException("Unexpected record of type " + type + " at " + addressToString(from));

        case IV.TYPE:
            scanIdentifyVolume(from, timestamp, recordSize);
            break;

        case IT.TYPE:
            scanIdentifyTree(from, timestamp, recordSize);
            break;

        case PA.TYPE:
            scanLoadPage(from, timestamp, recordSize);
            break;

        case PM.TYPE:
            scanLoadPageMap(from, timestamp, recordSize);
            break;

        case TM.TYPE:
            scanLoadTransactionMap(from, timestamp, recordSize);
            break;

        case TX.TYPE:
            scanOneTransaction(from, timestamp, recordSize);
            break;

        case CP.TYPE:
            scanCheckpoint(from, timestamp, recordSize);
            break;

        default:
            if (!isValidType(type)) {
                _currentAddress -= OVERHEAD;
                throw new CorruptJournalException("Invalid record type " + type + " at " + addressToString(from));
            }
        }
        _currentAddress = from + recordSize;
        return type;
    }
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.