in priam/src/main/java/com/netflix/priam/backupv2/MetaV1Proxy.java [90:148]
public BackupVerificationResult isMetaFileValid(AbstractBackupPath metaBackupPath) {
BackupVerificationResult result = new BackupVerificationResult();
result.remotePath = metaBackupPath.getRemotePath();
result.snapshotInstant = metaBackupPath.getTime().toInstant();
try {
// Download the meta file.
Path metaFile = downloadMetaFile(metaBackupPath);
// Read the local meta file.
List<String> metaFileList = getSSTFilesFromMeta(metaFile);
FileUtils.deleteQuietly(metaFile.toFile());
result.manifestAvailable = true;
// List the remote file system to validate the backup.
String prefix = fs.getPrefix().toString();
Date strippedMsSnapshotTime =
new Date(result.snapshotInstant.truncatedTo(ChronoUnit.MINUTES).toEpochMilli());
Iterator<AbstractBackupPath> backupfiles =
fs.list(prefix, strippedMsSnapshotTime, strippedMsSnapshotTime);
// Return validation fail if backup filesystem listing failed.
if (!backupfiles.hasNext()) {
logger.warn(
"ERROR: No files available while doing backup filesystem listing. Declaring the verification failed.");
return result;
}
// Convert the remote listing to String.
List<String> remoteListing = new ArrayList<>();
while (backupfiles.hasNext()) {
AbstractBackupPath path = backupfiles.next();
if (path.getType() == AbstractBackupPath.BackupFileType.SNAP)
remoteListing.add(path.getRemotePath());
}
if (metaFileList.isEmpty() && remoteListing.isEmpty()) {
logger.info(
"Uncommon Scenario: Both meta file and backup filesystem listing is empty. Considering this as success");
result.valid = true;
return result;
}
ArrayList<String> filesMatched =
(ArrayList<String>) CollectionUtils.intersection(metaFileList, remoteListing);
result.filesMatched = filesMatched.size();
result.filesInMetaOnly = metaFileList;
result.filesInMetaOnly.removeAll(filesMatched);
// There could be a scenario that backupfilesystem has more files than meta file. e.g.
// some leftover objects
result.valid = (result.filesInMetaOnly.isEmpty());
} catch (Exception e) {
logger.error(
"Error while processing meta file: " + metaBackupPath, e.getLocalizedMessage());
e.printStackTrace();
}
return result;
}