* 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();
}
}
}