OLogManager.instance().info(this, "Checkpoints are absent, the restore will start from the beginning.");
restoreFromBegging();
return;
}
OWALRecord checkPointRecord;
try {
checkPointRecord = writeAheadLog.read(lastCheckPoint);
} catch (OWALPageBrokenException e) {
checkPointRecord = null;
}
if (checkPointRecord == null) {
OLogManager.instance().info(this, "Checkpoints are absent, the restore will start from the beginning.");
restoreFromBegging();
return;
}
if (checkPointRecord instanceof OFuzzyCheckpointStartRecord) {
OLogManager.instance().info(this, "Found FUZZY checkpoint.");
boolean fuzzyCheckPointIsComplete = checkFuzzyCheckPointIsComplete(lastCheckPoint);
if (!fuzzyCheckPointIsComplete) {
OLogManager.instance().warn(this, "FUZZY checkpoint is not complete.");
OLogSequenceNumber previousCheckpoint = ((OFuzzyCheckpointStartRecord) checkPointRecord).getPreviousCheckpoint();
checkPointRecord = null;
if (previousCheckpoint != null)
checkPointRecord = writeAheadLog.read(previousCheckpoint);
if (checkPointRecord != null) {
OLogManager.instance().warn(this, "Restore will start from the previous checkpoint.");
restoreFromCheckPoint((OAbstractCheckPointStartRecord) checkPointRecord);
} else {
OLogManager.instance().warn(this, "Restore will start from the beginning.");
restoreFromBegging();
}
} else
restoreFromCheckPoint((OAbstractCheckPointStartRecord) checkPointRecord);
return;
}
if (checkPointRecord instanceof OFullCheckpointStartRecord) {
OLogManager.instance().info(this, "FULL checkpoint found.");
boolean fullCheckPointIsComplete = checkFullCheckPointIsComplete(lastCheckPoint);
if (!fullCheckPointIsComplete) {
OLogManager.instance().warn(this, "FULL checkpoint has not completed.");
OLogSequenceNumber previousCheckpoint = ((OFullCheckpointStartRecord) checkPointRecord).getPreviousCheckpoint();
checkPointRecord = null;
if (previousCheckpoint != null)
checkPointRecord = writeAheadLog.read(previousCheckpoint);
if (checkPointRecord != null) {
OLogManager.instance().warn(this, "Restore will start from the previous checkpoint.");
} else {
OLogManager.instance().warn(this, "Restore will start from the beginning.");
restoreFromBegging();
}
} else
restoreFromCheckPoint((OAbstractCheckPointStartRecord) checkPointRecord);
return;
}
throw new OStorageException("Unknown checkpoint record type " + checkPointRecord.getClass().getName());
}