Package com.sleepycat.je.log

Examples of com.sleepycat.je.log.FileHandle


             * b - it's not a valid offset, because the log file flipped.
             * In both cases, go to the FileManager and see if there's more log
             * to be found.
             */

            FileHandle fileHandle = null;
            try {

                /* Get a file handle to read in more log. */
                fileHandle = fileManager.getFileHandle(currentFileNum());

                /* Attempt to read more from this file. */
                startOffset = endOffset;
                if (fillFromFile(fileHandle, startOffset)) {
                    /*
                     * Successfully filled the read buffer, but didn't move to
                     * a new file.
                     */
                    return false;
                }

                fileHandle.release();
                fileHandle = null;

                /* This file is done -- can we read in the next file? */
                if (singleFile) {
                    throw new EOFException();
                }

                /*
                 * Remember that the nextFile may not be fileNum + 1 if
                 * there has been log cleaning.
                 */
                Long nextFile =
                    fileManager.getFollowingFileNum(currentFileNum(),
                                                    true /* forward */);

                /*
                 * But if there's no next file, let's assume that the desired
                 * data is still in the log buffers, and the next lsn is the
                 * first entry in the subsequent file number.  Start the read
                 * from the first real log entry, because the file header entry
                 * is not in the log buffers.
                 */
                if (nextFile == null) {
                    nextFile = currentFileNum() + 1;
                }

                if (fillFromLogBuffer(nextFile,
                                      FileManager.firstLogEntryOffset())) {
                    /*
                     * We filled the read buffer, and jumped to a new
                     * file.
                     */
                    return true;
                }

                /*
                 * Didn't find the next bytes in the log buffer, go look on
                 * disk.
                 */
                fileHandle = fileManager.getFileHandle(nextFile);
                setFileNum(nextFile, fileHandle.getLogVersion());
                startOffset = 0;
                boolean moreData = fillFromFile(fileHandle, 0);
                assert moreData :
                   "FeederReader should find more data in next file";
                return true;
            } catch (IOException e) {
                e.printStackTrace();
                throw EnvironmentFailureException.unexpectedException
                    ("Problem in ReadWindow.fill, reading from  = " +
                     currentFileNum(), e);

            } finally {
                if (fileHandle != null) {
                    fileHandle.release();
                }
            }
        }
View Full Code Here


             * b - it's not a valid offset, because the log file flipped.
             * In both cases, go to the file and see if there's more log to be
             * found.
             */

            FileHandle fileHandle = null;
            boolean movedToNewFile = false;
            try {

                /* Get a file handle to read in more log. */
                fileHandle = fileManager.getFileHandle(currentFileNum());

                /*
                 * Check to see if we've come to the end of the file.  If so,
                 * get the next file.
                 */
                if (endOffset < fileHandle.getFile().length()) {
                    /* There's more in the current file to read. */
                    startOffset = endOffset;
                    fillFromFile(fileHandle, startOffset);
                } else {

                    fileHandle.release();
                    fileHandle = null;

                    /* This file is done -- can we read in the next file? */
                    if (singleFile) {
                        throw new EOFException();
                    }

                    /*
                     * Remember that the nextFile may not be fileNum + 1 if
                     * there has been log cleaning.
                     */
                    Long nextFile =
                        fileManager.getFollowingFileNum(currentFileNum(),
                                                        true /* forward */);

                    /*
                     * But if there's no next file, let's assume that the next
                     * lsn is the first entry in the subsequent file number.
                     * Start the read from the first real log entry, because
                     * the file header entry is not in the log buffers.
                     */
                    if (nextFile == null) {
                        nextFile = currentFileNum() + 1;
                    }
                    if (fillFromLogBuffer(nextFile,
                                          FileManager.firstLogEntryOffset())) {
                        /*
                         * We filled the read buffer, and jumped to a new
                         * file.
                         */
                        return true;
                    }

                    /*
                     * Didn't find the next bytes in the log buffer, go look on
                     * disk.
                     */
                    fileHandle = fileManager.getFileHandle(nextFile);
                    setFileNum(nextFile, fileHandle.getLogVersion());
                    startOffset = 0;
                    fillFromFile(fileHandle, 0);
                    movedToNewFile = true;
                }
            } catch (IOException e) {
                e.printStackTrace();
                throw EnvironmentFailureException.unexpectedException
                    ("Problem in ReadWindow.fill, reading from  = " +
                     currentFileNum(), e);

            } finally {
                if (fileHandle != null) {
                    fileHandle.release();
                }
            }

            return movedToNewFile;
        }
View Full Code Here

TOP

Related Classes of com.sleepycat.je.log.FileHandle

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.