use of org.apache.ignite.internal.processors.cache.persistence.wal.SegmentEofException 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.SegmentEofException in project ignite by apache.
the class RecordV1Serializer method readRecordType.
/**
* Reads record type from given {@code in}.
*
* @param in Buffer to read record type.
* @return Record type.
* @throws IgniteCheckedException If logical end of segment is reached.
* @throws IOException In case of I/O problems.
*/
static RecordType readRecordType(DataInput in) throws IgniteCheckedException, IOException {
int type = in.readUnsignedByte();
if (type == WALRecord.RecordType.STOP_ITERATION_RECORD_TYPE)
throw new SegmentEofException("Reached logical end of the segment", null);
RecordType recType = RecordType.fromOrdinal(type - 1);
if (recType == null)
throw new IOException("Unknown record type: " + type);
return recType;
}
Aggregations