Package org.apache.directory.server.log

Examples of org.apache.directory.server.log.InvalidLogException


            currentLogFileNumber = lastGoodLogFileNumber;

            if ( ( lastGoodLogFileNumber < LogAnchor.MIN_LOG_NUMBER ) ||
                ( lastGoodLogFileOffset < LogAnchor.MIN_LOG_OFFSET ) )
            {
                throw new InvalidLogException( I18n.err( I18n.ERR_750 ) );
            }

            scanPoint.resetLogAnchor( lastGoodLogFileNumber, lastGoodLogFileOffset,
                LogAnchor.UNKNOWN_LSN );

            if ( anchorComparator.compare( scanPoint, minLogAnchor ) < 0 )
            {
                throw new InvalidLogException( I18n.err( I18n.ERR_750 ) );
            }

            /*
             * If invalid content at the end of file:
             * if we are past the header of file, then
             * truncate the file to the end of the last
             * read log record, otherwise we read a partially
             * written log file header, in this case reformat the log file.
             * Also check next for the existence of next file to make
             * sure we really read the last log file.
             */
            if ( invalidLog )
            {
                // Check if next log file exists
                reader = null;
                try
                {
                    reader = logFileManager.getReaderForLogFile( ( lastGoodLogFileNumber + 1 ) );

                }
                catch ( FileNotFoundException e )
                {
                    // Fine, this is what we want
                }
                finally
                {
                    if ( reader != null )
                    {
                        reader.close();
                    }
                }

                if ( reader != null )
                {
                    throw new InvalidLogException( I18n.err( I18n.ERR_750 ) );
                }

                if ( lastGoodLogFileOffset >= LogFileRecords.LOG_FILE_HEADER_SIZE )
                {
                    logFileManager.truncateLogFile( lastGoodLogFileNumber, lastGoodLogFileOffset );
                }
                else
                {
                    // Reformat the existing log file
                    this.createNextLogFile( true );
                }
            }

        }
        {
            /*
             * Control file does not exist. Either we are at the very beginning or
             * maybe we crashed in the middle of creating the first log file.
             * We  should have the min log file at most with the file header formatted.
             */
            reader = null;
            boolean fileExists = false;
            currentLogFileNumber = LogAnchor.MIN_LOG_NUMBER;
            try
            {
                reader = logFileManager.getReaderForLogFile( LogAnchor.MIN_LOG_NUMBER );

                if ( reader.getLength() > LogFileRecords.LOG_FILE_HEADER_SIZE )
                {
                    throw new InvalidLogException( I18n.err( I18n.ERR_750 ) );
                }
                fileExists = true;
            }
            catch ( FileNotFoundException e )
            {
View Full Code Here


        {
            controlFileReader.read( controlFileBuffer, 0, CONTROLFILE_RECORD_SIZE );
        }
        catch ( EOFException e )
        {
            throw new InvalidLogException( I18n.err( I18n.ERR_750 ), e );
        }
        finally
        {
            controlFileReader.close();
        }

        controlFileMarker.rewind();
        controlFileRecord.minExistingLogFile = controlFileMarker.getLong();
        controlFileRecord.minNeededLogFile = controlFileMarker.getLong();
        controlFileRecord.minNeededLogFileOffset = controlFileMarker.getLong();
        controlFileRecord.minNeededLSN = controlFileMarker.getLong();
        controlFileRecord.checksum = controlFileMarker.getLong();
        int magicNumber = controlFileMarker.getInt();

        if ( controlFileRecord.minExistingLogFile < LogAnchor.MIN_LOG_NUMBER )
        {
            invalidControlFile = true;
        }

        if ( ( controlFileRecord.minNeededLogFile < LogAnchor.MIN_LOG_NUMBER ) ||
            ( controlFileRecord.minNeededLogFileOffset < LogAnchor.MIN_LOG_OFFSET ) )
        {
            invalidControlFile = true;
        }

        if ( controlFileRecord.minExistingLogFile > controlFileRecord.minNeededLogFile )
        {
            invalidControlFile = true;
        }

        if ( magicNumber != this.CONTROLFILE_MAGIC_NUMBER )
        {
            invalidControlFile = true;
        }

        // TODO compute and compare checksum

        if ( invalidControlFile == true )
        {
            throw new InvalidLogException( I18n.err( I18n.ERR_750 ) );
        }

    }
View Full Code Here

        boolean fileAlreadyExists = logFileManager.createLogFile( logFileNumber );

        if ( ( reformatExistingFile == false ) && ( fileAlreadyExists == true ) )
        {
            // Didnt expect the file to be around
            throw new InvalidLogException( I18n.err( I18n.ERR_750 ) );
        }

        if ( ( reformatExistingFile == true ) && ( fileAlreadyExists == false ) )
        {
            // Didnt expect the file to be around
            throw new InvalidLogException( I18n.err( I18n.ERR_750 ) );
        }

        if ( reformatExistingFile )
        {
            logFileManager.truncateLogFile( logFileNumber, LogAnchor.MIN_LOG_OFFSET );
View Full Code Here

        checkIfClosed();

        if ( invalidLog )
        {
            throw new InvalidLogException( I18n.err( I18n.ERR_750 ) );
        }

        long fileLength;
        long fileOffset;
View Full Code Here


    private void markScanInvalid() throws InvalidLogException
    {
        invalidLog = true;
        throw new InvalidLogException( I18n.err( I18n.ERR_750 ) );
    }
View Full Code Here

TOP

Related Classes of org.apache.directory.server.log.InvalidLogException

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.