RecordInfo readRecordInfo(Location location) throws IOException, InvalidRecordLocationException {
LogFileNode logFileState = getLogFileWithId(location.getLogFileId());
// There can be no record at the append offset.
if (logFileState.getAppendOffset() == location.getLogFileOffset()) {
throw new InvalidRecordLocationException("No record at (" + location
+ ") found. Location past end of logged data.");
}
// Is there a record header at the seeked location?
try {
LogFile logFile = logFileState.getLogFile();
Record header = new Record();
logFile.readRecordHeader(location.getLogFileOffset(), header);
return new RecordInfo(location, header, logFileState);
} catch (IOException e) {
throw new InvalidRecordLocationException("No record at (" + location + ") found.");
}
}