in server/src/main/java/org/apache/cassandra/sidecar/restore/RestoreRangeTask.java [420:462]
File validateFilesAction(File directory) throws RestoreJobException, IOException
{
File manifestFile = new File(directory, RestoreSliceManifest.MANIFEST_FILE_NAME);
RestoreSliceManifest manifest = RestoreSliceManifest.read(manifestFile);
if (manifest.isEmpty())
{
throw new RestoreJobFatalException("The downloaded slice has no data. " +
"Directory: " + directory);
}
// validate the SSTable ranges with the owning range of the node and remove the out-of-range sstables
if (range.job().isManagedBySidecar())
{
removeOutOfRangeSSTables(directory, manifest);
}
Map<String, String> checksums = manifest.mergeAllChecksums();
// exclude the manifest file
File[] files = directory.listFiles((dir, name) -> !name.equals(RestoreSliceManifest.MANIFEST_FILE_NAME));
if (files == null || files.length != checksums.size())
{
String msg = "Number of files does not match. Expected: " + checksums.size() +
"; Actual: " + (files == null ? 0 : files.length) +
"; Directory: " + directory;
throw new RestoreJobFatalException(msg);
}
compareChecksums(checksums, files);
// capture the data component size of sstables
for (File file : files)
{
if (file.getName().endsWith("-Data.db"))
{
instanceMetrics.restore().dataSSTableComponentSize.metric.update(file.length());
}
}
// all files match with the provided checksums
return directory;
}