use of org.apache.ignite.internal.processors.cache.persistence.wal.WalSegmentTailReachedException in project ignite by apache.
the class RecordV1Serializer method readWithCrc.
/**
* Reads record from file {@code in0} and validates CRC of record.
*
* @param in0 File input.
* @param expPtr Expected WAL pointer for record. Used to validate actual position against expected from the file.
* @param reader Record reader I/O interface.
* @return WAL record.
* @throws EOFException In case of end of file.
* @throws IgniteCheckedException If it's unable to read record.
*/
static WALRecord readWithCrc(FileInput in0, WALPointer expPtr, RecordIO reader) throws EOFException, IgniteCheckedException {
long startPos = -1;
try (FileInput.Crc32CheckingFileInput in = in0.startRead(skipCrc)) {
startPos = in0.position();
WALRecord res = reader.readWithHeaders(in, expPtr);
assert res != null;
// Account for CRC which will be read afterwards.
res.size((int) (in0.position() - startPos + CRC_SIZE));
return res;
} catch (EOFException | SegmentEofException | WalSegmentTailReachedException e) {
throw e;
} catch (Exception e) {
throw new IgniteCheckedException("Failed to read WAL record at position: " + startPos, e);
}
}
use of org.apache.ignite.internal.processors.cache.persistence.wal.WalSegmentTailReachedException in project ignite by apache.
the class RecordV2Serializer method readPositionAndCheckPoint.
/**
* @param in Data input to read pointer from.
* @param skipPositionCheck Flag for skipping position check.
* @return Read file WAL pointer.
* @throws IOException If failed to write.
*/
@SuppressWarnings("UnusedReturnValue")
private static FileWALPointer readPositionAndCheckPoint(DataInput in, WALPointer expPtr, boolean skipPositionCheck) throws IgniteCheckedException, IOException {
long idx = in.readLong();
int fileOff = in.readInt();
int len = in.readInt();
FileWALPointer p = (FileWALPointer) expPtr;
if (!F.eq(idx, p.index()) || (!skipPositionCheck && !F.eq(fileOff, p.fileOffset())))
throw new WalSegmentTailReachedException("WAL segment tail is reached. [ " + "Expected next state: {Index=" + p.index() + ",Offset=" + p.fileOffset() + "}, " + "Actual state : {Index=" + idx + ",Offset=" + fileOff + "} ]", null);
return new FileWALPointer(idx, fileOff, len);
}
Aggregations