use of org.apache.ignite.internal.processors.cache.persistence.wal.serializer.SegmentHeader in project ignite by apache.
the class AbstractWalRecordsIterator method initReadHandle.
/**
* Assumes file descriptor will be opened in this method. The caller of this method must be responsible for closing
* opened file descriptor File descriptor will be closed ONLY in case of error occurred.
*
* @param desc File descriptor.
* @param start Optional start pointer. Null means read from the beginning
* @return Initialized file read header.
* @throws FileNotFoundException If segment file is missing.
* @throws IgniteCheckedException If initialized failed due to another unexpected error.
*/
protected AbstractReadFileHandle initReadHandle(@NotNull final AbstractFileDescriptor desc, @Nullable final WALPointer start) throws IgniteCheckedException, FileNotFoundException {
SegmentIO fileIO = null;
try {
fileIO = desc.toReadOnlyIO(ioFactory);
SegmentHeader segmentHeader;
try {
segmentHeader = readSegmentHeader(fileIO, segmentFileInputFactory);
} catch (SegmentEofException | EOFException ignore) {
try {
fileIO.close();
} catch (IOException ce) {
throw new IgniteCheckedException(ce);
}
return null;
} catch (IOException | IgniteCheckedException e) {
U.closeWithSuppressingException(fileIO, e);
throw e;
}
return initReadHandle(desc, start, fileIO, segmentHeader);
} catch (FileNotFoundException e) {
U.closeQuiet(fileIO);
throw e;
} catch (IOException e) {
U.closeQuiet(fileIO);
throw new IgniteCheckedException("Failed to initialize WAL segment: " + desc.file().getAbsolutePath(), e);
}
}
use of org.apache.ignite.internal.processors.cache.persistence.wal.serializer.SegmentHeader in project ignite by apache.
the class StandaloneWalRecordsIterator method initReadHandle.
/**
* {@inheritDoc}
*/
@Override
protected AbstractReadFileHandle initReadHandle(@NotNull AbstractFileDescriptor desc, @Nullable WALPointer start) throws IgniteCheckedException, FileNotFoundException {
AbstractFileDescriptor fd = desc;
SegmentIO fileIO = null;
SegmentHeader segmentHeader;
while (true) {
try {
fileIO = fd.toReadOnlyIO(ioFactory);
segmentHeader = readSegmentHeader(fileIO, FILE_INPUT_FACTORY);
break;
} catch (IOException | IgniteCheckedException e) {
log.error("Failed to init segment curWalSegmIdx=" + curWalSegmIdx + ", curIdx=" + curIdx, e);
U.closeQuiet(fileIO);
curIdx++;
if (curIdx >= walFileDescriptors.size())
return null;
fd = walFileDescriptors.get(curIdx);
}
}
return initReadHandle(fd, start, fileIO, segmentHeader);
}
Aggregations