}
}
System.out.println(String.format("Pre-scrub sstables snapshotted into snapshot %s", snapshotName));
// If leveled, load the manifest
LeveledManifest manifest = null;
if (cfs.directories.tryGetLeveledManifest() != null)
{
cfs.directories.snapshotLeveledManifest(snapshotName);
System.out.println(String.format("Leveled manifest snapshotted into snapshot %s", snapshotName));
int maxSizeInMB = (int)((cfs.getCompactionStrategy().getMaxSSTableSize()) / (1024L * 1024L));
manifest = LeveledManifest.create(cfs, maxSizeInMB, sstables);
}
if (!options.manifestCheckOnly)
{
for (SSTableReader sstable : sstables)
{
try
{
Scrubber scrubber = new Scrubber(cfs, sstable, handler, true);
try
{
scrubber.scrub();
}
finally
{
scrubber.close();
}
if (manifest != null)
{
if (scrubber.getNewInOrderSSTable() != null)
manifest.add(scrubber.getNewInOrderSSTable());
List<SSTableReader> added = scrubber.getNewSSTable() == null
? Collections.<SSTableReader>emptyList()
: Collections.singletonList(scrubber.getNewSSTable());
manifest.replace(Collections.singletonList(sstable), added);
}
// Remove the sstable (it's been copied by scrub and snapshotted)
sstable.markCompacted();
sstable.releaseReference();